From gitlab at gitlab.haskell.org Tue Nov 1 00:08:35 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 31 Oct 2022 20:08:35 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] Don't export bases trace Message-ID: <63606383cc054_815bc514281862b1@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: 2f3727c4 by Andreas Klebinger at 2022-11-01T01:06:14+01:00 Don't export bases trace - - - - - 1 changed file: - compiler/GHC/Prelude.hs Changes: ===================================== compiler/GHC/Prelude.hs ===================================== @@ -63,7 +63,6 @@ import {-# SOURCE #-} GHC.Utils.Trace , pprSTrace , warnPprTrace , pprTraceUserWarning - , trace ) #if MIN_VERSION_base(4,16,0) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2f3727c4167263a5548f7ee3fd103cfc0cd35d33 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2f3727c4167263a5548f7ee3fd103cfc0cd35d33 You're receiving 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 Nov 1 00:37:53 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 31 Oct 2022 20:37:53 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <63606a619ebb5_815bc514dc18855a@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: f7eb28b2 by Andreas Klebinger at 2022-11-01T01:35:20+01:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 17 changed files: - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - testsuite/driver/testlib.py - + testsuite/tests/unboxedsums/GenManyUbxSums.hs - + testsuite/tests/unboxedsums/ManyUbxSums.stdout - + testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs - + testsuite/tests/unboxedsums/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,213 @@ +{- +This module contains helpers to cast variables +between different Int/WordReps in StgLand. + +-} + +module GHC.Builtin.PrimOps.Casts + ( getCasts ) +where + +import GHC.Prelude + +import GHC.Core.TyCon +import GHC.Utils.Outputable +import GHC.Utils.Panic +import GHC.Utils.Panic.Plain +import GHC.Types.RepType +import GHC.Core.Type +import GHC.Builtin.Types.Prim +import GHC.Builtin.Types + +import GHC.Builtin.PrimOps +import GHC.Plugins (HasDebugCallStack) + +{- Note [PrimRep based casting] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This module contains a number of utility functions useful when +converting between variables of differing PrimReps. + +The general pattern is: +* We have two primReps `from_rep` and `to_rep`. +* We want a list of PrimOps we can apply to a variable of rep `from_rep`. +Applying the list of primOps in order takes us to `to_rep` from `from_rep` giving +us a variable of the returned type at each step. + +E.g. we call `getCasts from_rep to_rep` and get back [(op1#,ty1),(op2#,ty2)]. +We can use this list of primOps to construct a function of type +`StgExpr -> StgExpr` by construction an expression + + case op1# of (x' :: ty1) -> case op2# x' of x' -> + +Ideally backends will compile the sequence of PrimOps to a no-op. E.g. by reusing +the same register but just relabeling it as another width. +However this is might not always be possible or the required optimizations +simply not implemented in the backend. This means currently many of these casts +will be cheap but not all of them will be completely zero-cost. + +-} + +-- | `getCasts from_rep to_rep` gives us a list of primops which when applied in order convert from_rep to to_rep. +-- See Note [PrimRep based casting] +getCasts :: PrimRep -> PrimRep -> [(PrimOp,Type)] +getCasts from_rep to_rep + -- No-op + | -- pprTrace "getCasts" (ppr (from_rep,to_rep)) $ + to_rep == from_rep + = [] + + -- Float <-> Double + | to_rep == FloatRep = + assertPpr (from_rep == DoubleRep) (ppr from_rep <+> ppr to_rep) $ + [(DoubleToFloatOp,floatPrimTy)] + | to_rep == DoubleRep = + assertPpr (from_rep == FloatRep) (ppr from_rep <+> ppr to_rep) $ + [(FloatToDoubleOp,doublePrimTy)] + + -- Addr <-> Word/Int + | to_rep == AddrRep = wordOrIntToAddrRep from_rep + | from_rep == AddrRep = addrToWordOrIntRep to_rep + + -- Int* -> Int* + | primRepIsInt from_rep + , primRepIsInt to_rep + = sizedIntToSizedInt from_rep to_rep + + -- Word* -> Word* + | primRepIsWord from_rep + , primRepIsWord to_rep + = sizedWordToSizedWord from_rep to_rep + + -- Word* -> Int* + | primRepIsWord from_rep + , primRepIsInt to_rep + = let (op1,r1) = wordToIntRep from_rep + in (op1,primRepToType r1):sizedIntToSizedInt r1 to_rep + + -- Int* -> Word* + | primRepIsInt from_rep + , primRepIsWord to_rep + = let (op1,r1) = intToWordRep from_rep + in (op1,primRepToType r1):sizedWordToSizedWord r1 to_rep + + | otherwise = pprPanic "getCasts:Unexpect rep combination" + (ppr (from_rep,to_rep)) + +wordOrIntToAddrRep :: HasDebugCallStack => PrimRep -> [(PrimOp,Type)] +wordOrIntToAddrRep AddrRep = [] -- No-op argument is already AddrRep +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r1) = wordToIntRep r + in (op1, primRepToType r1):[(intToMachineInt r1,intPrimTy), (IntToAddrOp,addrPrimTy)] + | otherwise = pprPanic "Rep not word or int rep" (ppr r) + +addrToWordOrIntRep :: HasDebugCallStack => PrimRep -> [(PrimOp,Type)] +-- Machine sizes +addrToWordOrIntRep IntRep = [(AddrToIntOp, intPrimTy)] +addrToWordOrIntRep WordRep = [(AddrToIntOp,intPrimTy), (IntToWordOp,wordPrimTy)] +-- Explicitly sized reps +addrToWordOrIntRep r + | primRepIsWord r = (AddrToIntOp,intPrimTy) : (IntToWordOp,wordPrimTy) : sizedWordToSizedWord WordRep r + | primRepIsInt r = (AddrToIntOp,intPrimTy) : sizedIntToSizedInt IntRep r + | otherwise = pprPanic "Target rep not word or int rep" (ppr r) + + +-- WordX# -> IntX# (same size), argument is source rep +wordToIntRep :: HasDebugCallStack => PrimRep -> (PrimOp,PrimRep) +wordToIntRep rep + = case rep of + (WordRep) -> (WordToIntOp, IntRep) + (Word8Rep) -> (Word8ToInt8Op, Int8Rep) + (Word16Rep) -> (Word16ToInt16Op, Int16Rep) + (Word32Rep) -> (Word32ToInt32Op, Int32Rep) + (Word64Rep) -> (Word64ToInt64Op, Int64Rep) + _ -> pprPanic "Rep not a wordRep" (ppr rep) + +-- IntX# -> WordX#, argument is source rep +intToWordRep :: HasDebugCallStack => PrimRep -> (PrimOp,PrimRep) +intToWordRep rep + = case rep of + (IntRep) -> (IntToWordOp, WordRep) + (Int8Rep) -> (Int8ToWord8Op, Word8Rep) + (Int16Rep) -> (Int16ToWord16Op, Word16Rep) + (Int32Rep) -> (Int32ToWord32Op, Word32Rep) + (Int64Rep) -> (Int64ToWord64Op, Word64Rep) + _ -> pprPanic "Rep not a wordRep" (ppr rep) + +-- Casts between any size int to any other size of int +sizedIntToSizedInt :: HasDebugCallStack => PrimRep -> PrimRep -> [(PrimOp,Type)] +sizedIntToSizedInt r1 r2 + | r1 == r2 = [] +-- Cast to Int# +sizedIntToSizedInt r IntRep = [(intToMachineInt r,intTy)] +-- Cast from Int# +sizedIntToSizedInt IntRep r = [(intFromMachineInt r,primRepToType r)] +-- Sized to differently sized must go over machine word. +sizedIntToSizedInt r1 r2 = (intToMachineInt r1,intTy) : [(intFromMachineInt r2,primRepToType r2)] + +-- Casts between any size Word to any other size of Word +sizedWordToSizedWord :: HasDebugCallStack => PrimRep -> PrimRep -> [(PrimOp,Type)] +sizedWordToSizedWord r1 r2 + | r1 == r2 = [] +-- Cast to Word# +sizedWordToSizedWord r WordRep = [(wordToMachineWord r,wordPrimTy)] +-- Cast from Word# +sizedWordToSizedWord WordRep r = [(wordFromMachineWord r, primRepToType r)] +-- Conversion between different non-machine sizes must go via machine word. +sizedWordToSizedWord r1 r2 = (wordToMachineWord r1,wordPrimTy) : [(wordFromMachineWord r2, primRepToType r2)] + + +-- Prefer the definitions above this line if possible +---------------------- + + +-- Int*# to Int# +{-# INLINE intToMachineInt #-} +intToMachineInt :: HasDebugCallStack => PrimRep -> PrimOp +intToMachineInt r = + assertPpr (primRepIsInt r) (ppr r) $ + case r of + (Int8Rep) -> Int8ToIntOp + (Int16Rep) -> Int16ToIntOp + (Int32Rep) -> Int32ToIntOp + (Int64Rep) -> Int64ToIntOp + _ -> pprPanic "Source rep not int" $ ppr r + +-- Int# to Int*# +{-# INLINE intFromMachineInt #-} +intFromMachineInt :: HasDebugCallStack => PrimRep -> PrimOp +intFromMachineInt r = + assertPpr (primRepIsInt r) (ppr r) $ + case r of + Int8Rep -> IntToInt8Op + Int16Rep -> IntToInt16Op + Int32Rep -> IntToInt32Op + Int64Rep -> IntToInt64Op + _ -> pprPanic "Dest rep not sized int" $ ppr r + +-- Word# to Word*# +{-# INLINE wordFromMachineWord #-} +wordFromMachineWord :: HasDebugCallStack => PrimRep -> PrimOp +wordFromMachineWord r = + assert (primRepIsWord r) $ + case r of + Word8Rep -> WordToWord8Op + Word16Rep -> WordToWord16Op + Word32Rep -> WordToWord32Op + Word64Rep -> WordToWord64Op + _ -> pprPanic "Dest rep not sized word" $ ppr r + +-- Word*# to Word# +{-# INLINE wordToMachineWord #-} +wordToMachineWord :: HasDebugCallStack => PrimRep -> PrimOp +wordToMachineWord r = + assertPpr (primRepIsWord r) (text "Not a word rep:" <> ppr r) $ + case r of + Word8Rep -> Word8ToWordOp + Word16Rep -> Word16ToWordOp + Word32Rep -> Word32ToWordOp + Word64Rep -> Word64ToWordOp + _ -> pprPanic "Dest rep not sized word" $ ppr r \ No newline at end of file ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -1399,7 +1399,10 @@ instance OutputableP Platform CLabel where pdoc !platform lbl = getPprStyle $ \pp_sty -> case pp_sty of PprDump{} -> pprCLabel platform CStyle lbl - _ -> pprPanic "Labels in code should be printed with pprCLabel" (pprCLabel platform CStyle lbl) + -- Workaround for #22218 + _ -> (pprCLabel platform CStyle lbl) + -- _ -> pprPanic "Labels in code should be printed with pprCLabel" (pprCLabel platform CStyle lbl) + pprCLabel :: Platform -> LabelStyle -> CLabel -> SDoc pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel] ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -129,6 +129,7 @@ module GHC.Core.TyCon( primRepIsFloat, primRepsCompatible, primRepCompatible, + primRepIsWord, primRepIsInt, ) where @@ -1785,6 +1786,24 @@ primRepIsFloat DoubleRep = Just True primRepIsFloat (VecRep _ _) = Nothing primRepIsFloat _ = Just False +-- Rep is one of the word reps. +primRepIsWord :: PrimRep -> Bool +primRepIsWord WordRep = True +primRepIsWord (Word8Rep) = True +primRepIsWord (Word16Rep) = True +primRepIsWord (Word32Rep) = True +primRepIsWord (Word64Rep) = True +primRepIsWord _ = False + +-- Rep is one of the int reps. +primRepIsInt :: PrimRep -> Bool +primRepIsInt (IntRep) = True +primRepIsInt (Int8Rep) = True +primRepIsInt (Int16Rep) = True +primRepIsInt (Int32Rep) = True +primRepIsInt (Int64Rep) = True +primRepIsInt _ = False + {- ************************************************************************ * * ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -422,6 +422,7 @@ data GeneralFlag -- variables that have otherwise identical names. | Opt_SuppressUniques | Opt_SuppressStgExts + | Opt_SuppressStgReps | Opt_SuppressTicks -- Replaces Opt_PprShowTicks | Opt_SuppressTimestamps -- ^ Suppress timestamps in dumps | Opt_SuppressCoreSizes -- ^ Suppress per binding Core size stats in dumps ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2393,6 +2393,7 @@ dynamic_flags_deps = [ setGeneralFlag Opt_SuppressIdInfo setGeneralFlag Opt_SuppressTicks setGeneralFlag Opt_SuppressStgExts + setGeneralFlag Opt_SuppressStgReps setGeneralFlag Opt_SuppressTypeSignatures setGeneralFlag Opt_SuppressCoreSizes setGeneralFlag Opt_SuppressTimestamps) @@ -3344,6 +3345,7 @@ dFlagsDeps = [ depFlagSpec' "suppress-stg-free-vars" Opt_SuppressStgExts (useInstead "-d" "suppress-stg-exts"), flagSpec "suppress-stg-exts" Opt_SuppressStgExts, + flagSpec "suppress-stg-reps" Opt_SuppressStgReps, flagSpec "suppress-coercions" Opt_SuppressCoercions, flagSpec "suppress-coercion-types" Opt_SuppressCoercionTypes, flagSpec "suppress-idinfo" Opt_SuppressIdInfo, @@ -3796,7 +3798,8 @@ defaultFlags settings Opt_VersionMacros, Opt_RPath, Opt_DumpWithWays, - Opt_CompactUnwind + Opt_CompactUnwind, + Opt_SuppressStgReps ] ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns] @@ -5020,6 +5023,7 @@ initSDocContext dflags style = SDC , sdocSuppressUniques = gopt Opt_SuppressUniques dflags , sdocSuppressModulePrefixes = gopt Opt_SuppressModulePrefixes dflags , sdocSuppressStgExts = gopt Opt_SuppressStgExts dflags + , sdocSuppressStgReps = gopt Opt_SuppressStgReps dflags , sdocErrorSpans = gopt Opt_ErrorSpans dflags , sdocStarIsType = xopt LangExt.StarIsType dflags , sdocLinearTypes = xopt LangExt.LinearTypes dflags ===================================== compiler/GHC/Stg/Syntax.hs ===================================== @@ -87,7 +87,7 @@ import GHC.Core.Ppr( {- instances -} ) import GHC.Builtin.PrimOps ( PrimOp, PrimCall ) import GHC.Core.TyCon ( PrimRep(..), TyCon ) import GHC.Core.Type ( Type ) -import GHC.Types.RepType ( typePrimRep1 ) +import GHC.Types.RepType ( typePrimRep1, typePrimRep ) import GHC.Utils.Panic.Plain {- @@ -740,12 +740,23 @@ pprStgTopBinding = pprGenStgTopBinding pprStgTopBindings :: OutputablePass pass => StgPprOpts -> [GenStgTopBinding pass] -> SDoc pprStgTopBindings = pprGenStgTopBindings +pprIdWithRep :: Id -> SDoc +pprIdWithRep v = ppr v <> pprTypeRep (idType v) + +pprTypeRep :: Type -> SDoc +pprTypeRep ty = + ppUnlessOption sdocSuppressStgReps $ + char ':' <> case typePrimRep ty of + [r] -> ppr r + r -> ppr r + + instance Outputable StgArg where ppr = pprStgArg pprStgArg :: StgArg -> SDoc -pprStgArg (StgVarArg var) = ppr var -pprStgArg (StgLitArg con) = ppr con +pprStgArg (StgVarArg var) = pprIdWithRep var +pprStgArg (StgLitArg con) = ppr con <> pprTypeRep (literalType con) instance OutputablePass pass => Outputable (GenStgExpr pass) where ppr = pprStgExpr panicStgPprOpts ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -186,6 +186,132 @@ So we pass type arguments of the DataCon's TyCon in StgConApp to decide what layout to use. Note that unlifted values can't be let-bound, so we don't need types in StgRhsCon. +Note [Casting slot arguments] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this function which selects between Float# and Double# from a unboxed sum. + + foo :: (# Float# | Double# #) -> FD + foo x = case x of + (# x1 | #) -> F x1 + (# | x2 #) -> D x2 + +Naturally we would expect x1 to have a PrimRep of FloatRep and x2 of DoubleRep. +However we used to generate this (bogus) code after Unarise giving rise to #22208: + + M.foo :: (# GHC.Prim.Float# | GHC.Prim.Double# #) -> M.FD + [GblId, Arity=1, Unf=OtherCon []] = + {} \r [sum_tag sum_field] + case sum_tag of tag_gsc { + __DEFAULT -> M.F [sum_field]; + 2# -> M.D [sum_field]; + }; + +Where sum_field is used both as Float# and Double# depending on the branch +because they share the same SlotTy. +This usually works out since we put floats/doubles in the same sort of register. +However this caused issues down the road where we would assign between variables +of different reps causing lint errors or in the case of #22208 even compiler panics. +For now our solution is to construct proper casts between the PrimRep of the slot and +the variables we want to store in, or read out of these slots. + +This means when we have a sum (# Float# | Double# #) if we want to store a float +we convert it to a double on construction of the tuple value, and convert it back +to a float once when want to use the field. +Conversion for values coming out of a strict field happen in mapSumIdBinders. While +conversion during the construction of sums happen inside mkUbxSum. + +------------- A full example of casting during sum construction ---------------- + +To give a full example if we *construct* a unboxed sum of +type (# Int32# | Int64# ) in an expression like `let sum = (# | #) x` +Then we will call mkUbxSum to determine which arguments we have to pass in which +order to the unboxed tuple that represents the unboxed sum. + +Int32# and Int# in this case will share the same slot in the unboxed sum. This +means we want to upcast the argument in order to match up the reps of the +variables. To do this mkUbxSum will produce a casting expression with a hole for +the original rhs to go into. That is the call to mkUbxSum and it's result will +look something like: + + >>> mkUbxSum (#|#) [Int32#, Int#] (x::Int32#) us(x') + ([x'::Double#], case int32ToInt# x of x' -> <_hole_> ) + +We will use the returned arguments to construct an application to an unboxed tuple: + + (# #) 1# x' + +Which we will then use to construct an expression that casts `x` to the right type +and places it into x': + + >>> (\_hole_ -> case int32ToInt# x of x' -> _hole_) ((# #) 1# x') + case int32ToInt# x of x' -> (# #) 1# x' + +Which results in the this definition for `sum` after all is said and done: + + let sum = case int32ToInt# x of { x' -> (# #) 1# x' } + +You might wonder why we bother renaming `x` to `x'`. It's quite subtle. Consider +a definition like this: + + let sum_shadow :: (# (# Int32#, Int32# ) | Int64# #) + let sum_shadow = (# |#) (# x, x #) + +We compute the required slots for the tuple and come up with +`[WordSlot, Word64Slot]`. For the first sum constructor we will place `x` both +in a Word and a Word64Slot. If we would not rename the constructor what we would +get would be: + + let sum_shadow = case int32ToInt# x of + { x -> + (# #) 1# x x -- With the unboxed tuple having type (# #) :: (# Int#, Int#, Int64 #) + } + +Clearly this is somewhat bogus, we would end up using the same `x` as a +Int# and a Int64# value! + +------------- A full example of casting during sum matching -------------------- + +When matching on the same unboxed sum constructor as above we start out with +something like this the pre-unarise: + + f sum = case sum of + (# x |#) -> ... x ... -- (# x |#) :: (# Int32, Int#) + ... + +We start desugaring and get: + + f sum_tag sum_slot_arg_1 = case sum_tag of + 1# -> ??? + +Now we need to match the slot arguments to binders in the original case +alternative. This is done by mapSumIdBinders which we we call for our +example alternative like this: + + >>> mapSumIdBinders [x] [sum_slot_arg_1] alt_rhs env + (env', alt_rhs') + +mapSumIdBinders first matches up the list of binders with the slots passed to +the function which is trivial in this case. Then we check if the slot and the +variable residing inside it agree on their Rep. If all binders and slot reps +agree we just extend the environment with a mapping from `x` to `sum_slot_arg_1` +and we return the rhs as is. +If the reps do not agree then we wrap the whole RHS in a case which casts the +bound variable to a type of the correct representation. Here `x` is of Int32Rep +while `sum_slot_arg_1` will be of IntRep. This means instead of retuning the +original alt_rhs we will return: + + case intToInt32# (x :: Int#) of + (x :: Int32#) -> original_alt_rhs + +We then run unarise on this expression, which will replace the first occurence +of `x` with sum_slot_arg_1 giving us post-unarise: + + f sum_tag sum_slot_arg_1 = + case sum_tag of + 1# -> case intToInt32# sum_slot_arg_1 of + x -> ... x ... + ... + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +384,8 @@ import GHC.Prelude import GHC.Types.Basic import GHC.Core import GHC.Core.DataCon -import GHC.Core.TyCon ( isVoidRep ) -import GHC.Data.FastString (FastString, mkFastString) +import GHC.Core.TyCon +import GHC.Data.FastString (FastString, mkFastString, fsLit, appendFS) import GHC.Types.Id import GHC.Types.Literal import GHC.Core.Make (aBSENT_SUM_FIELD_ERROR_ID) @@ -281,6 +407,10 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name -------------------------------------------------------------------------------- @@ -306,8 +436,10 @@ import qualified Data.IntMap as IM -- INVARIANT: OutStgArgs in the range only have NvUnaryTypes -- (i.e. no unboxed tuples, sums or voids) -- -type UnariseEnv = VarEnv UnariseVal +newtype UnariseEnv = UnariseEnv { ue_rho :: (VarEnv UnariseVal) } +initUnariseEnv :: VarEnv UnariseVal -> UnariseEnv +initUnariseEnv = UnariseEnv data UnariseVal = MultiVal [OutStgArg] -- MultiVal to tuple. Can be empty list (void). | UnaryVal OutStgArg -- See Note [Renaming during unarisation]. @@ -320,25 +452,27 @@ instance Outputable UnariseVal where -- The id is mapped to one or more things. -- See Note [UnariseEnv] extendRho :: UnariseEnv -> Id -> UnariseVal -> UnariseEnv -extendRho rho x (MultiVal args) +extendRho env x (MultiVal args) = assert (all (isNvUnaryType . stgArgType) args) - extendVarEnv rho x (MultiVal args) -extendRho rho x (UnaryVal val) + env { ue_rho = extendVarEnv (ue_rho env) x (MultiVal args) } +extendRho env x (UnaryVal val) = assert (isNvUnaryType (stgArgType val)) - extendVarEnv rho x (UnaryVal val) + env { ue_rho = extendVarEnv (ue_rho env) x (UnaryVal val) } -- Properly shadow things from an outer scope. -- See Note [UnariseEnv] -- The id stands for itself so we don't record a mapping. -- See Note [UnariseEnv] extendRhoWithoutValue :: UnariseEnv -> Id -> UnariseEnv -extendRhoWithoutValue rho x = delVarEnv rho x +extendRhoWithoutValue env x = env { ue_rho = delVarEnv (ue_rho env) x } +lookupRho :: UnariseEnv -> Id -> Maybe UnariseVal +lookupRho env v = lookupVarEnv (ue_rho env) v -------------------------------------------------------------------------------- unarise :: UniqSupply -> [StgTopBinding] -> [StgTopBinding] -unarise us binds = initUs_ us (mapM (unariseTopBinding emptyVarEnv) binds) +unarise us binds = initUs_ us (mapM (unariseTopBinding (initUnariseEnv emptyVarEnv)) binds) unariseTopBinding :: UnariseEnv -> StgTopBinding -> UniqSM StgTopBinding unariseTopBinding rho (StgTopLifted bind) @@ -366,7 +500,7 @@ unariseRhs rho (StgRhsCon ccs con mu ts args) unariseExpr :: UnariseEnv -> StgExpr -> UniqSM StgExpr unariseExpr rho e@(StgApp f []) - = case lookupVarEnv rho f of + = case lookupRho rho f of Just (MultiVal args) -- Including empty tuples -> return (mkTuple args) Just (UnaryVal (StgVarArg f')) @@ -379,7 +513,7 @@ unariseExpr rho e@(StgApp f []) unariseExpr rho e@(StgApp f args) = return (StgApp f' (unariseFunArgs rho args)) where - f' = case lookupVarEnv rho f of + f' = case lookupRho rho f of Just (UnaryVal (StgVarArg f')) -> f' Nothing -> f err -> pprPanic "unariseExpr - app2" (pprStgExpr panicStgPprOpts e $$ ppr err) @@ -390,12 +524,17 @@ unariseExpr _ (StgLit l) = return (StgLit l) unariseExpr rho (StgConApp dc n args ty_args) - | Just args' <- unariseMulti_maybe rho dc args ty_args - = return (mkTuple args') - - | otherwise - , let args' = unariseConArgs rho args - = return (StgConApp dc n args' (map stgArgType args')) + | isUnboxedSumDataCon dc || isUnboxedTupleDataCon dc + = do + us <- getUniqueSupplyM + case unariseUbxSumOrTupleArgs rho us dc args ty_args of + (args', Just cast_wrapper) + -> return $ cast_wrapper (mkTuple args') + (args', Nothing) + -> return $ (mkTuple args') + | otherwise = + let args' = unariseConArgs rho args in + return $ (StgConApp dc n args' (map stgArgType args')) unariseExpr rho (StgOpApp op args ty) = return (StgOpApp op (unariseFunArgs rho args) ty) @@ -403,15 +542,19 @@ unariseExpr rho (StgOpApp op args ty) unariseExpr rho (StgCase scrut bndr alt_ty alts) -- tuple/sum binders in the scrutinee can always be eliminated | StgApp v [] <- scrut - , Just (MultiVal xs) <- lookupVarEnv rho v + , Just (MultiVal xs) <- lookupRho rho v = elimCase rho xs bndr alt_ty alts -- Handle strict lets for tuples and sums: -- case (# a,b #) of r -> rhs -- and analogously for sums | StgConApp dc _n args ty_args <- scrut - , Just args' <- unariseMulti_maybe rho dc args ty_args - = elimCase rho args' bndr alt_ty alts + , isUnboxedSumDataCon dc || isUnboxedTupleDataCon dc + = do + us <- getUniqueSupplyM + case unariseUbxSumOrTupleArgs rho us dc args ty_args of + (args',Just wrapper) -> wrapper <$> elimCase rho args' bndr alt_ty alts + (args',Nothing) -> elimCase rho args' bndr alt_ty alts -- See (3) of Note [Rubbish literals] in GHC.Types.Literal | StgLit lit <- scrut @@ -436,17 +579,21 @@ unariseExpr rho (StgTick tick e) = StgTick tick <$> unariseExpr rho e -- Doesn't return void args. -unariseMulti_maybe :: UnariseEnv -> DataCon -> [InStgArg] -> [Type] -> Maybe [OutStgArg] -unariseMulti_maybe rho dc args ty_args +unariseUbxSumOrTupleArgs :: UnariseEnv -> UniqSupply -> DataCon -> [InStgArg] -> [Type] + -> ( [OutStgArg] -- Arguments representing the unboxed sum + , Maybe (StgExpr -> StgExpr)) -- Transformation to apply to the arguments, to bring them + -- into the right Rep +unariseUbxSumOrTupleArgs rho us dc args ty_args | isUnboxedTupleDataCon dc - = Just (unariseConArgs rho args) + = (unariseConArgs rho args, Nothing) | isUnboxedSumDataCon dc , let args1 = assert (isSingleton args) (unariseConArgs rho args) - = Just (mkUbxSum dc ty_args args1) + = let (args2, cast_wrapper) = mkUbxSum dc ty_args args1 us + in (args2, Just cast_wrapper) | otherwise - = Nothing + = panic "unariseUbxSumOrTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +620,15 @@ elimCase rho args bndr (MultiValAlt _) [GenStgAlt{ alt_con = _ , alt_bndrs = bndrs , alt_rhs = rhs}] = do let rho1 = extendRho rho bndr (MultiVal args) - rho2 + (rho2, rhs') | isUnboxedTupleBndr bndr - = mapTupleIdBinders bndrs args rho1 + = (mapTupleIdBinders bndrs args rho1, rhs) | otherwise = assert (isUnboxedSumBndr bndr) $ - if null bndrs then rho1 - else mapSumIdBinders bndrs args rho1 + if null bndrs then (rho1, rhs) + else mapSumIdBinders bndrs args rhs rho1 - unariseExpr rho2 rhs + unariseExpr rho2 rhs' elimCase rho args bndr (MultiValAlt _) alts | isUnboxedSumBndr bndr @@ -576,12 +723,12 @@ unariseSumAlt rho args GenStgAlt{ alt_con = DataAlt sumCon , alt_bndrs = bs , alt_rhs = e } - = do let rho' = mapSumIdBinders bs args rho - lit_case = LitAlt (LitNumber LitNumInt (fromIntegral (dataConTag sumCon))) - GenStgAlt lit_case mempty <$> unariseExpr rho' e + = do let (rho',e') = mapSumIdBinders bs args e rho + lit_case = LitAlt (LitNumber LitNumInt (fromIntegral (dataConTag sumCon))) + GenStgAlt lit_case mempty <$> unariseExpr rho' e' unariseSumAlt _ scrt alt - = pprPanic "unariseSumAlt" (ppr scrt $$ pprPanicAlt alt) + = pprPanic "unariseSumAlt3" (ppr scrt $$ pprPanicAlt alt) -------------------------------------------------------------------------------- @@ -623,24 +770,80 @@ mapSumIdBinders -- only have one binder, so this list should be a singleton) -> [OutStgArg] -- Arguments that form the sum (NOT including the tag). -- Can't have void args. + -> InStgExpr -> UnariseEnv - -> UnariseEnv + -> (UnariseEnv, OutStgExpr) -mapSumIdBinders [id] args rho0 +mapSumIdBinders [id] args rhs rho0 = assert (not (any (isZeroBitTy . stgArgType) args)) $ let + -- Slots representing the whole sum arg_slots = map primRepSlot $ concatMap (typePrimRep . stgArgType) args + -- The slots representing the field of the sum we bind. id_slots = map primRepSlot $ typePrimRep (idType id) layout1 = layoutUbxSum arg_slots id_slots + + -- See Note [Casting slot arguments] + -- Arg id's which make up the field. + id_arg_exprs = [ args !! i | i <- layout1 ] + id_vars = [v | StgVarArg v <- id_arg_exprs] + + update_id_type v ty + | (typePrimRep $ idType v) == (typePrimRep ty) = v + | otherwise = setIdType v ty + + -- types for the field binders based on their rep + id_tys = map primRepToType $ typePrimRep (idType id) + -- Arg id's with the typ set to one matching the fields rep. + typed_id_args = zipWithEqual "typed_id_args" (\var t -> StgVarArg (update_id_type var t)) id_vars id_tys + -- We can shadow the original argument id here since the binder for the field will only be used + -- at one specific type in this branch. + (rhs_with_casts) = foldr castArgShadow rhs $ zip id_vars id_tys in + -- pprTrace "mapSumIdBinders" + -- (text "id_tys" <+> ppr id_tys $$ + -- text "id_args" <+> ppr id_arg_exprs $$ + -- text "rhs" <+> ppr rhs $$ + -- text "rhs_with_casts" <+> ppr rhs_with_casts + -- ) $ if isMultiValBndr id - then extendRho rho0 id (MultiVal [ args !! i | i <- layout1 ]) - else assert (layout1 `lengthIs` 1) - extendRho rho0 id (UnaryVal (args !! head layout1)) + then (extendRho rho0 id (MultiVal typed_id_args), rhs_with_casts) + else assert (typed_id_args `lengthIs` 1) + (extendRho rho0 id (UnaryVal (head typed_id_args)), rhs_with_casts) -mapSumIdBinders ids sum_args _ +mapSumIdBinders ids sum_args _rhs _ = pprPanic "mapSumIdBinders" (ppr ids $$ ppr sum_args) +-- Convert the argument to the given type, and wrap the case doing the +-- conversion around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, target_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 target_ty) + in foldr (mkCast (StgVarArg arg) arg) (in_rhs) ops + +-- Convert the argument to the given type, and wrap the conversion +-- around the given expression. Use the given Id as a name for the +-- converted value. +castArgRename :: StgArg -> Id -> StgExpr -> StgExpr +castArgRename in_arg out_id in_rhs = + case ops of + [] -> in_rhs + op1:rest_ops -> + mkCast in_arg out_id op1 $ + foldr (mkCast (StgVarArg out_id) out_id) in_rhs rest_ops + -- pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + where ops = getCasts (typePrimRep1 $ stgArgType in_arg) $ typePrimRep1 (idType out_id) + -- in foldr (mkCast in_arg out_id) (in_rhs) ops + +-- Variable to cast, (type to cast to, result_ty), rhs +mkCast :: StgArg -> OutId -> (PrimOp,Type) -> (StgExpr) -> (StgExpr) +mkCast arg_in out_id (cast_op,ty2) (in_rhs) = + let r2 = typePrimRep1 ty2 + scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + alt_ty = PrimAlt r2 + in (StgCase scrut (setIdType out_id ty2) alt_ty [alt]) + -- | Build a unboxed sum term from arguments of an alternative. -- -- Example, for (# x | #) :: (# (# #) | Int #) we call @@ -655,8 +858,11 @@ mkUbxSum :: DataCon -- Sum data con -> [Type] -- Type arguments of the sum data con -> [OutStgArg] -- Actual arguments of the alternative. - -> [OutStgArg] -- Final tuple arguments -mkUbxSum dc ty_args args0 + -> UniqSupply + -> ([OutStgArg] -- Final tuple arguments + ,(StgExpr->StgExpr) -- We might need to cast the args first + ) +mkUbxSum dc ty_args args0 us = let (_ : sum_slots) = ubxSumRepType (map typePrimRep ty_args) -- drop tag slot @@ -667,16 +873,50 @@ mkUbxSum dc ty_args args0 tag_arg = StgLitArg (LitNumber LitNumInt (fromIntegral tag)) arg_idxs = IM.fromList (zipEqual "mkUbxSum" layout' args0) - mkTupArgs :: Int -> [SlotTy] -> IM.IntMap StgArg -> [StgArg] - mkTupArgs _ [] _ - = [] - mkTupArgs arg_idx (slot : slots_left) arg_map - | Just stg_arg <- IM.lookup arg_idx arg_map - = stg_arg : mkTupArgs (arg_idx + 1) slots_left arg_map - | otherwise - = ubxSumRubbishArg slot : mkTupArgs (arg_idx + 1) slots_left arg_map + ((_idx,_idx_map,_us,wrapper),slot_args) + = assert (length arg_idxs <= length sum_slots ) $ + mapAccumL mkTupArg (0,arg_idxs,us,id) sum_slots + + mkTupArg :: (Int, IM.IntMap StgArg,UniqSupply,StgExpr->StgExpr) + -> SlotTy + -> ((Int,IM.IntMap StgArg,UniqSupply,StgExpr->StgExpr), StgArg) + mkTupArg (arg_idx, arg_map, us, wrapper) slot + | Just stg_arg <- IM.lookup arg_idx arg_map + = case castArg us slot stg_arg of + Just (casted_arg,us',wrapper') -> + ( (arg_idx+1, arg_map, us', wrapper') + , casted_arg) + Nothing -> + ( (arg_idx+1, arg_map, us, wrapper) + , stg_arg) + | otherwise + = ( (arg_idx+1, arg_map, us, wrapper) + , ubxSumRubbishArg slot) + + castArg :: UniqSupply -> SlotTy -> StgArg -> Maybe (StgArg,UniqSupply,StgExpr -> StgExpr) + castArg us slot_ty arg + -- Cast the argument to the type of the slot if required + | slotPrimRep slot_ty /= typePrimRep1 (stgArgType arg) + = let (u1,us') = takeUniqFromSupply us + out_ty = primRepToType $ slotPrimRep slot_ty + out_name_fs + | (StgVarArg v_arg) <- arg + = getOccFS v_arg `appendFS` fsLit "_cst" + | otherwise = fsLit "cst_lit" + out_id = mkSysLocal out_name_fs u1 Many out_ty :: Id + casts = castArgRename arg out_id :: StgExpr -> StgExpr + in Just (StgVarArg out_id,us',casts) + -- No need for casting + | otherwise = Nothing + + tup_args = tag_arg : slot_args in - tag_arg : mkTupArgs 0 sum_slots arg_idxs + -- pprTrace "mkUbxSum" ( + -- text "ty_args (slots)" <+> ppr ty_args $$ + -- text "args0" <+> ppr args0 $$ + -- text "wrapper" <+> + -- (ppr $ wrapper $ StgLit $ LitChar '_')) + (tup_args, wrapper) -- | Return a rubbish value for the given slot type. @@ -787,7 +1027,7 @@ unariseArgBinder is_con_arg rho x = -- | MultiVal a function argument. Never returns an empty list. unariseFunArg :: UnariseEnv -> StgArg -> [StgArg] unariseFunArg rho (StgVarArg x) = - case lookupVarEnv rho x of + case lookupRho rho x of Just (MultiVal []) -> [voidArg] -- NB: do not remove void args Just (MultiVal as) -> as Just (UnaryVal arg) -> [arg] @@ -809,7 +1049,7 @@ unariseFunArgBinder = unariseArgBinder False -- | MultiVal a DataCon argument. Returns an empty list when argument is void. unariseConArg :: UnariseEnv -> InStgArg -> [OutStgArg] unariseConArg rho (StgVarArg x) = - case lookupVarEnv rho x of + case lookupRho rho x of Just (UnaryVal arg) -> [arg] Just (MultiVal as) -> as -- 'as' can be empty Nothing ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -245,7 +245,8 @@ ubxSumRepType constrs0 in sumRep -layoutUbxSum :: SortedSlotTys -- Layout of sum. Does not include tag. +layoutUbxSum :: HasDebugCallStack + => SortedSlotTys -- Layout of sum. Does not include tag. -- We assume that they are in increasing order -> [SlotTy] -- Slot types of things we want to map to locations in the -- sum layout @@ -268,7 +269,8 @@ layoutUbxSum sum_slots0 arg_slots0 = | otherwise = findSlot arg (slot_idx + 1) slots useds findSlot _ _ [] _ - = pprPanic "findSlot" (text "Can't find slot" $$ ppr sum_slots0 $$ ppr arg_slots0) + = pprPanic "findSlot" (text "Can't find slot" $$ text "sum_slots:" <> ppr sum_slots0 + $$ text "arg_slots:" <> ppr arg_slots0 ) -------------------------------------------------------------------------------- @@ -347,18 +349,17 @@ fitsIn ty1 ty2 = Just ty1 | isWordSlot ty1 && isWordSlot ty2 = Just (max ty1 ty2) - | isFloatSlot ty1 && isFloatSlot ty2 - = Just (max ty1 ty2) | otherwise = Nothing + -- We used to share slots between Float/Double but currently we can't easily + -- covert between float/double in a way that is both work free and safe. + -- So we put them in different slots. + -- See Note [Casting slot arguments] where isWordSlot Word64Slot = True isWordSlot WordSlot = True isWordSlot _ = False - isFloatSlot DoubleSlot = True - isFloatSlot FloatSlot = True - isFloatSlot _ = False {- ********************************************************************** ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -387,6 +387,7 @@ data SDocContext = SDC , sdocSuppressUniques :: !Bool , sdocSuppressModulePrefixes :: !Bool , sdocSuppressStgExts :: !Bool + , sdocSuppressStgReps :: !Bool , sdocErrorSpans :: !Bool , sdocStarIsType :: !Bool , sdocLinearTypes :: !Bool @@ -447,6 +448,7 @@ defaultSDocContext = SDC , sdocSuppressUniques = False , sdocSuppressModulePrefixes = False , sdocSuppressStgExts = False + , sdocSuppressStgReps = True , sdocErrorSpans = False , sdocStarIsType = False , sdocLinearTypes = False ===================================== compiler/ghc.cabal.in ===================================== @@ -168,6 +168,7 @@ Library GHC.Builtin.Names GHC.Builtin.Names.TH GHC.Builtin.PrimOps + GHC.Builtin.PrimOps.Casts GHC.Builtin.PrimOps.Ids GHC.Builtin.Types GHC.Builtin.Types.Literals ===================================== docs/users_guide/debugging.rst ===================================== @@ -946,6 +946,16 @@ parts that you are not interested in. Suppress the printing of core size stats per binding +.. ghc-flag:: -dsuppress-stg-reps + :shortdesc: Suppress rep annotations on STG args. + :type: dynamic + + :since: 9.6.1 + + default: enabled + + Disabling this will annoate certain stg arguments with their prim rep. + .. _checking-consistency: ===================================== testsuite/driver/testlib.py ===================================== @@ -1447,7 +1447,8 @@ def compile_cmp_asm(name: TestName, ext: str, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile only, extra args = ', extra_hc_opts) result = simple_build(name + '.' + ext, way, '-keep-s-files -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): @@ -1474,7 +1475,8 @@ def compile_grep_asm(name: TestName, is_substring: bool, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile and grep asm, extra args = ', extra_hc_opts) result = simple_build(name + '.' + ext, way, '-keep-s-files -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): @@ -1495,7 +1497,8 @@ def compile_grep_core(name: TestName, way: WayName, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile only, extra args = ', extra_hc_opts) result = simple_build(name + '.hs', way, '-ddump-to-file -dsuppress-all -ddump-simpl -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): ===================================== testsuite/tests/unboxedsums/GenManyUbxSums.hs ===================================== @@ -0,0 +1,109 @@ +#!/usr/bin/env runghc +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} + +-- This little piece of code constructs a large set of functions +-- constructing and deconstructing unboxed tuples of various types. +module Main where + +import GHC.Exts +import System.IO +import Data.List (intersperse) +inputs = ["Int", "Word"] +sizes = ["","8","16","32","64"] + +-- ["Addr#","Int#","Int8#","Int16#","Int32#","Int64#","Word#","Word8#","Word16#","Word32#","Word64#"] +types = "Addr#" : do + r <- inputs + s <- sizes + return $ r++s++"#" + +-- We eventually build two sums, one of type (# t1 | t2 #) and one of (# t1 | t3). +-- So we build all possible combinations of three types here. +combos = do + t1 <- types + t2 <- types + t3 <- types + return (t1,t2,t3) + +mkCon ty = case ty of + "Addr#" -> "Addr" + "Int#" -> "I#" + "Int8#" -> "I8#" + "Int16#" -> "I16#" + "Int32#" -> "I32#" + "Int64#" -> "I64#" + "Word#" -> "W#" + "Word8#" -> "W8#" + "Word16#" -> "W16#" + "Word32#" -> "W32#" + "Word64#" -> "W64#" + +-- Construct a function like the one below, varying the types in the sums based on the +-- given type tuples. +-- We need to NOINLINE or the function will be constant folded away. +-- {-# NOINLINE fun0 #-} +-- fun0 :: (# Addr# | I16# #) -> (# Addr# | I# #) +-- fun0 x = case x of +-- (# x1 | #) -> (# x1 | #) :: (# Addr# | I# #) +mkFun n (t1,t2,t3) = + "{-# NOINLINE fun" ++ show n ++ " #-}\n" ++ + "fun" ++ show n ++ " :: (# " ++ t1 ++" | " ++ t2 ++ " #) -> (# " ++ t1 ++" | " ++ t3 ++ " #)\n" ++ + "fun" ++ show n ++ " x = case x of\n" ++ + " (# x1 | #) -> (# x1 | #) :: (# " ++ t1 ++ " | " ++ t3 ++ " #)" + +-- Generate functions for all the tuple combinations. +mkFuns _ [] = "" +mkFuns n (combo:combos) = + mkFun n combo ++ "\n" ++ mkFuns (n+1) combos + +-- generate a test that will put a value into a unboxed sum and then retrieve it later on. +-- It generates code like the one below: +-- test0 = +-- let in_val = maxBound +-- out_val = case in_val of I# x -> case fun0 (# x | #) of (# y | #) -> I# y +-- in in_val == out_val +mkTest n (t1,_,_)= + let test_name = "test" ++ show n + test_code = test_name ++ " =\n" ++ + " let in_val = (maxBound)\n" ++ + " out_val = case in_val of " ++ mkCon t1 ++ " x -> case fun" ++ show n ++ " (# x | #) of (# y | #) -> " ++ mkCon t1 ++ " y\n" ++ + " in in_val == out_val" + in (test_code,test_name) + +-- Test all the tuples +mkTests n combos = + let (defs, names) = unzip $ zipWith mkTest [0..] combos + assert_results = "\nassert_results = and [" ++ (concat $ intersperse "," names) ++ "]\n" :: String + in unlines defs ++ assert_results + +header = + "{-# LANGUAGE MagicHash #-}\n\ + \{-# LANGUAGE UnboxedTuples #-}\n\ + \{-# LANGUAGE UnboxedSums #-}\n\ + \module Main where\n\ + \import GHC.Exts\n\ + \import GHC.Word\n\ + \import GHC.Int\n\ + \import ManyUbxSums_Addr\n" +main = do + out <- openFile "ManyUbxSums.hs" WriteMode + hPutStrLn out header + + let combo:_ = combos + -- putStrLn $ mkFun 1 combo + hPutStrLn out $ mkFuns 0 combos + + hPutStrLn out $ mkTests 0 combos + hPutStrLn out "main = do" + + hPutStrLn out $ " putStrLn . show $ assert_results" + + -- The snippet below would print all individual test results. + -- But for CI really just check if all results match the input + -- let runTest n = + -- hPutStrLn out $ " putStrLn $ \"test" ++ show n ++ " \" ++ (show test" ++ show n ++ ")" + -- mapM runTest [0 .. length combos - 1] + + hClose out ===================================== testsuite/tests/unboxedsums/ManyUbxSums.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs ===================================== @@ -0,0 +1,26 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} + +{-# OPTIONS_GHC -Wno-missing-methods #-} + +module ManyUbxSums_Addr where + +import GHC.Exts +-- import GHC.Word +-- import GHC.Int +--import GHC.Utils.Misc + +data Addr = Addr Addr# + +instance Eq Addr where + (Addr x) == (Addr y) = case (eqAddr# x y) of + 1# -> True + 0# -> False + +instance Num Addr where + fromInteger x = case fromIntegral x of I# x1 -> Addr (int2Addr# x1) + +instance Bounded Addr where + maxBound = fromIntegral (maxBound :: Word) + minBound = 0 \ No newline at end of file ===================================== testsuite/tests/unboxedsums/T22208.hs ===================================== @@ -0,0 +1,41 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +module M where + +import GHC.Base + +-- Reproducer from #22208 +foo :: (# Float# | Double# #) -> (# Float# | Float #) +foo (# x | #) = (# x | #) +bar :: (# Word# | Int64# #) -> (# Double# | Word# #) +bar (# y | #) = let x = y in (# | x #) +baz :: (# Word# | Word64# #) -> (# Word# | (##) #) +baz (# x | #) = (# x | #) + +foo1 :: (# Float# | Double# #) -> (# Float# | Float #) +foo1 (# x | #) = (# x | #) +bar1 :: (# Word# | Int64# #) -> (# Double# | Word# #) +bar1 (# y | #) = let x = y in (# | x #) +baz1 :: (# Word# | Word64# #) -> (# Word# | (##) #) +baz1 (# x | #) = (# x | #) + +-- i8 value from w64 slot +baz2 :: (# Int8# | Word64# #) -> (# Int8# | (##) #) +baz2 (# x | #) = (# x | #) + +-- w8 value from w64 slot +baz3 :: (# Word8# | Word64# #) -> (# Word8# | (##) #) +baz3 (# x | #) = (# x | #) + +-- w8 from w slot +baz4 :: (# Word8# | Word# #) -> (# Word8# | (##) #) +baz4 (# x | #) = (# x | #) + +-- w from w slot +baz5 :: (# Word8# | Word# #) -> (# Word# | (##) #) +baz5 (# | x #) = (# x | #) + +-- addr from w slot +baz6 :: (# Addr# | Word# #) -> (# Addr# | (##) #) +baz6 (# x | #) = (# x | #) \ No newline at end of file ===================================== testsuite/tests/unboxedsums/all.T ===================================== @@ -35,3 +35,12 @@ test('T20858b', [extra_files(['T20858.hs']) ,extra_hc_opts("-fprint-explicit-runtime-reps -fprint-explicit-kinds")] , ghci_script, ['T20858b.script']) test('T20859', normal, compile, ['']) +test('T22208', normal, compile, ['-dstg-lint -dcmm-lint']) +test('ManyUbxSums', + [ pre_cmd('{compiler} --run ./GenManyUbxSums.hs'), + extra_files(['GenManyUbxSums.hs', 'ManyUbxSums_Addr.hs']), + ], + multi_compile_and_run, + ['ManyUbxSums', + [('ManyUbxSums_Addr.hs','')] + , '-v0 -dstg-lint -dcmm-lint']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7eb28b29ce5e3acf492b5020c954542a5873d67 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7eb28b29ce5e3acf492b5020c954542a5873d67 You're receiving 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 Nov 1 07:21:25 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 01 Nov 2022 03:21:25 -0400 Subject: [Git][ghc/ghc][wip/arity-type-9.4] Fix arityType Message-ID: <6360c8f533add_815bc5150420141b@gitlab.mail> Zubin pushed to branch wip/arity-type-9.4 at Glasgow Haskell Compiler / GHC Commits: f5c827fa by Zubin Duggal at 2022-11-01T12:50:42+05:30 Fix arityType - - - - - 1 changed file: - compiler/GHC/Core/Opt/Arity.hs Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1185,15 +1185,6 @@ arityType env (Let (NonRec b r) e) cheap_rhs = myExprIsCheap env r (Just (idType b)) env' = extendSigEnv env b (arityType env r) -arityType env (Let (Rec pairs) body) - | ((j,_):_) <- pairs - , isJoinId j - = -- See Note [arityType for join bindings] - arityType rec_env body - where - rec_env = foldl add_bot env pairs - add_bot env (j,_) = extendSigEnv env j botArityType - arityType env (Let (Rec prs) e) = floatIn (all is_cheap prs) (arityType env' e) where View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5c827fa3958fac73d520f3b1a7dddb97c8a23b9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f5c827fa3958fac73d520f3b1a7dddb97c8a23b9 You're receiving 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 Nov 1 08:15:09 2022 From: gitlab at gitlab.haskell.org (Sven Tennie (@supersven)) Date: Tue, 01 Nov 2022 04:15:09 -0400 Subject: [Git][ghc/ghc][wip/decode_cloned_stack] Save Message-ID: <6360d58d3e197_815bc5150420401f@gitlab.mail> Sven Tennie pushed to branch wip/decode_cloned_stack at Glasgow Haskell Compiler / GHC Commits: 453b2623 by Sven Tennie at 2022-11-01T08:14:55+00:00 Save - - - - - 5 changed files: - libraries/ghc-heap/GHC/Exts/DecodeStack.hs - libraries/ghc-heap/GHC/Exts/StackConstants.hsc - libraries/ghc-heap/cbits/Stack.c - libraries/ghc-heap/cbits/Stack.cmm - utils/deriveConstants/Main.hs Changes: ===================================== libraries/ghc-heap/GHC/Exts/DecodeStack.hs ===================================== @@ -65,8 +65,12 @@ foreign import prim "getInfoTableTypezh" getInfoTableType# :: StackSnapshot# -> foreign import prim "getLargeBitmapzh" getLargeBitmap# :: StackSnapshot# -> Word# -> (# ByteArray#, Word# #) +foreign import prim "getRetFunLargeBitmapzh" getRetFunLargeBitmap# :: StackSnapshot# -> Word# -> (# ByteArray#, Word# #) + foreign import prim "getSmallBitmapzh" getSmallBitmap# :: StackSnapshot# -> Word# -> (# Word#, Word#, Word# #) +foreign import prim "getRetFunSmallBitmapzh" getRetFunSmallBitmap# :: StackSnapshot# -> Word# -> (# Word#, Word# #) + data BitmapEntry = BitmapEntry { closureFrame :: StackFrameIter, isPrimitive :: Bool @@ -132,7 +136,13 @@ unpackStackFrameIter sfi@(StackFrameIter (# s#, i# #)) = payloads = map toBitmapPayload bes in RetBig payloads - RET_FUN -> RetFun + RET_FUN -> let + t = getRetFunType# s# i# + size = W# (getWord# s# i# (intToWord# offsetStgRetFunFrameSize)) + fun = toClosure (unpackClosureReferencedByFrame# (intToWord# offsetStgRetFunFrameFun)) sfi + payload :: [CL.Closure] + in + RetFun t size fun payload -- TODO: Decode update frame type UPDATE_FRAME -> let c = toClosure (unpackClosureReferencedByFrame# (intToWord# offsetStgUpdateFrameUpdatee)) sfi @@ -141,6 +151,7 @@ unpackStackFrameIter sfi@(StackFrameIter (# s#, i# #)) = UpdateFrame t c CATCH_FRAME -> let c = toClosure (unpackClosureReferencedByFrame# (intToWord# offsetStgCatchFrameHandler)) sfi + -- TODO: Replace with getWord# expression exceptionsBlocked = W# (getCatchFrameExceptionsBlocked# s# i#) in CatchFrame exceptionsBlocked c @@ -210,6 +221,8 @@ foreign import prim "getUnderflowFrameNextChunkzh" getUnderflowFrameNextChunk# : foreign import prim "getWordzh" getWord# :: StackSnapshot# -> Word# -> Word# -> Word# +foreign import prim "getRetFunTypezh" getRetFunType# :: StackSnapshot# -> Word# -> Word# + data BitmapPayload = Closure CL.Closure | Primitive Word instance Show BitmapPayload where @@ -257,10 +270,42 @@ data StackFrame = StopFrame | RetSmall { knownRetSmallType :: SpecialRetSmall, payload :: [BitmapPayload]} | RetBig { payload :: [BitmapPayload] } | - RetFun | + RetFun { retFunType :: RetFunType, size :: Word, fun :: CL.Closure, payload :: [CL.Closure]} | RetBCO deriving (Show) +data RetFunType = + ARG_GEN | + ARG_GEN_BIG | + ARG_BCO | + ARG_NONE | + ARG_N | + ARG_P | + ARG_F | + ARG_D | + ARG_L | + ARG_V16 | + ARG_V32 | + ARG_V64 | + ARG_NN | + ARG_NP | + ARG_PN | + ARG_PP | + ARG_NNN | + ARG_NNP | + ARG_NPN | + ARG_NPP | + ARG_PNN | + ARG_PNP | + ARG_PPN | + ARG_PPP | + ARG_PPPP | + ARG_PPPPP | + ARG_PPPPPP | + ARG_PPPPPPP | + ARG_PPPPPPPP + deriving (Show, Eq, Enum) + #if defined(DEBUG) foreign import ccall "belchStack" belchStack# :: StackSnapshot# -> IO () ===================================== libraries/ghc-heap/GHC/Exts/StackConstants.hsc ===================================== @@ -34,3 +34,12 @@ offsetStgCatchRetryFrameRunningFirstCode = (#const OFFSET_StgCatchRetryFrame_fir offsetStgCatchRetryFrameAltCode :: Int offsetStgCatchRetryFrameAltCode = (#const OFFSET_StgCatchRetryFrame_alt_code) + (#size StgHeader) + +offsetStgRetFunFrameSize :: Int +offsetStgRetFunFrameSize = (#const OFFSET_StgRetFun_size) + (#size StgHeader) + +offsetStgRetFunFrameFun :: Int +offsetStgRetFunFrameFun = (#const OFFSET_StgRetFun_fun) + (#size StgHeader) + +offsetStgRetFunFramePayload :: Int +offsetStgRetFunFramePayload = (#const OFFSET_StgRetFun_payload) + (#size StgHeader) ===================================== libraries/ghc-heap/cbits/Stack.c ===================================== @@ -6,19 +6,19 @@ #include "rts/storage/Closures.h" #include "rts/storage/InfoTables.h" -StgWord stackFrameSize(StgStack* stack, StgWord index){ - StgClosure* c = (StgClosure *) stack->sp + index; +StgWord stackFrameSize(StgStack *stack, StgWord index) { + StgClosure *c = (StgClosure *)stack->sp + index; ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); return stack_frame_sizeW(c); } -StgStack* getUnderflowFrameStack(StgStack* stack, StgWord index){ - StgClosure* frame = (StgClosure *) stack->sp + index; +StgStack *getUnderflowFrameStack(StgStack *stack, StgWord index) { + StgClosure *frame = (StgClosure *)stack->sp + index; ASSERT(LOOKS_LIKE_CLOSURE_PTR(frame)); - const StgRetInfoTable *info = get_ret_itbl((StgClosure *)frame); + const StgRetInfoTable *info = get_ret_itbl((StgClosure *)frame); - if(info->i.type == UNDERFLOW_FRAME) { - return ((StgUnderflowFrame*) frame)->next_chunk; + if (info->i.type == UNDERFLOW_FRAME) { + return ((StgUnderflowFrame *)frame)->next_chunk; } else { return NULL; } @@ -33,7 +33,7 @@ const StgInfoTable *getItbl(StgClosure *closure) { StgWord getSpecialRetSmall(StgClosure *closure) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(closure)); - StgWord c = *(StgWord*)closure; + StgWord c = *(StgWord *)closure; if (c == (StgWord)&stg_ap_v_info) { return 1; } else if (c == (StgWord)&stg_ap_f_info) { @@ -79,35 +79,50 @@ StgWord getSpecialRetSmall(StgClosure *closure) { } } -StgWord getUpdateFrameType(StgClosure* c) { +StgWord getUpdateFrameType(StgClosure *c) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); - const StgInfoTable* info = c->header.info; + const StgInfoTable *info = c->header.info; if (info == &stg_upd_frame_info) { - return 0; + return 0; } else if (info == &stg_bh_upd_frame_info) { - return 1; + return 1; } else if (info == &stg_marked_upd_frame_info) { - return 2; + return 2; } else { // Cannot do more than warn and exit. - errorBelch("Cannot decide Update Frame type for info table %p closure %p.", info, c); + errorBelch("Cannot decide Update Frame type for info table %p closure %p.", + info, c); stg_exit(EXIT_INTERNAL_ERROR); } } -StgWord getBitmapSize(StgClosure *c){ +StgWord getBitmapSize(StgClosure *c) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); - const StgInfoTable* info = get_itbl(c); + const StgInfoTable *info = get_itbl(c); StgWord bitmap = info->layout.bitmap; return BITMAP_SIZE(bitmap); } -StgWord getBitmapWord(StgClosure *c){ +StgWord getRetFunBitmapSize(StgRetFun *ret_fun) { + ASSERT(LOOKS_LIKE_CLOSURE_PTR(ret_fun)); + + const StgFunInfoTable *fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + switch (fun_info->f.fun_type) { + case ARG_GEN: + return BITMAP_BITS(fun_info->f.b.bitmap), + case ARG_GEN_BIG: + return GET_FUN_LARGE_BITMAP(fun_info)->size; + default: + return BITMAP_SIZE(stg_arg_bitmaps[fun_info->f.fun_type])); + } + } + +StgWord getBitmapWord(StgClosure *c) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); - const StgInfoTable* info = get_itbl(c); + const StgInfoTable *info = get_itbl(c); StgWord bitmap = info->layout.bitmap; // debugBelch("getBitmapWord - bitmap : %lu \n", bitmap); StgWord bitmapWord = BITMAP_BITS(bitmap); @@ -115,44 +130,86 @@ StgWord getBitmapWord(StgClosure *c){ return bitmapWord; } -StgWord getLargeBitmapSize(StgClosure *c){ +StgWord getRetFunBitmapWord(StgClosure *ret_fun) { + ASSERT(LOOKS_LIKE_CLOSURE_PTR(ret_fun)); + + const StgFunInfoTable *fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + switch (fun_info->f.fun_type) { + case ARG_GEN: + return BITMAP_BITS(fun_info->f.b.bitmap); + case ARG_GEN_BIG: + // Cannot do more than warn and exit. + errorBelch("Unexpected ARG_GEN_BIG StgRetFun closure %p", ret_fun); + stg_exit(EXIT_INTERNAL_ERROR); + default: + return BITMAP_BITS(stg_arg_bitmaps[fun_info->f.fun_type]); + } +} + +StgWord getLargeBitmapSize(StgClosure *c) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); - const StgInfoTable* info = get_itbl(c); - StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); + const StgInfoTable *info = get_itbl(c); + StgLargeBitmap *bitmap = GET_LARGE_BITMAP(info); return bitmap->size; } -#define ROUNDUP_BITS_TO_WDS(n) (((n) + WORD_SIZE_IN_BITS - 1) / WORD_SIZE_IN_BITS ) +#define ROUNDUP_BITS_TO_WDS(n) \ + (((n) + WORD_SIZE_IN_BITS - 1) / WORD_SIZE_IN_BITS) // Copied from Cmm.h -#define SIZEOF_W SIZEOF_VOID_P +#define SIZEOF_W SIZEOF_VOID_P #define WDS(n) ((n)*SIZEOF_W) -StgArrBytes* getLargeBitmaps(Capability *cap, StgClosure *c){ +StgArrBytes *getLargeBitmaps(Capability *cap, StgClosure *c) { ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); - const StgInfoTable* info = get_itbl(c); - StgLargeBitmap* bitmap = GET_LARGE_BITMAP(info); + const StgInfoTable *info = get_itbl(c); + StgLargeBitmap *bitmap = GET_LARGE_BITMAP(info); StgWord neededWords = ROUNDUP_BITS_TO_WDS(bitmap->size); - StgArrBytes* array = (StgArrBytes *) allocate(cap, sizeofW(StgArrBytes) + neededWords); + StgArrBytes *array = + (StgArrBytes *)allocate(cap, sizeofW(StgArrBytes) + neededWords); SET_HDR(array, &stg_ARR_WORDS_info, CCCS); array->bytes = WDS(ROUNDUP_BITS_TO_WDS(bitmap->size)); - for(int i = 0; i < neededWords; i++) { + for (int i = 0; i < neededWords; i++) { array->payload[i] = bitmap->bitmap[i]; } return array; } -#if defined(DEBUG) -extern void printStack (StgStack *stack); -void belchStack(StgStack* stack){ - printStack(stack); +StgArrBytes *getRetFunLargeBitmaps(Capability *cap, StgRetFun *ret_fun) { + ASSERT(LOOKS_LIKE_CLOSURE_PTR(ret_fun)); + + const StgFunInfoTable *fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + StgLargeBitmap *bitmap = GET_FUN_LARGE_BITMAP(fun_info); + StgWord neededWords = ROUNDUP_BITS_TO_WDS(bitmap->size); + StgArrBytes *array = + (StgArrBytes *)allocate(cap, sizeofW(StgArrBytes) + neededWords); + SET_HDR(array, &stg_ARR_WORDS_info, CCCS); + array->bytes = WDS(ROUNDUP_BITS_TO_WDS(bitmap->size)); + + for (int i = 0; i < neededWords; i++) { + array->payload[i] = bitmap->bitmap[i]; + } + + return array; } + +#if defined(DEBUG) +extern void printStack(StgStack *stack); +void belchStack(StgStack *stack) { printStack(stack); } #endif -StgStack* getUnderflowFrameNextChunk(StgUnderflowFrame* frame){ +StgStack *getUnderflowFrameNextChunk(StgUnderflowFrame *frame) { return frame->next_chunk; } + +StgWord getRetFunType(StgRetFun *ret_fun) { + ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); + + StgFunInfoTable *fun_info = get_fun_itbl(UNTAG_CLOSURE(ret_fun->fun)); + return fun_info->f.fun_type; +} ===================================== libraries/ghc-heap/cbits/Stack.cmm ===================================== @@ -99,6 +99,18 @@ getSmallBitmapzh(P_ stack, W_ index) { return (bitmap, size, specialType); } +getRetFunSmallBitmapzh(P_ stack, W_ index) { + P_ c; + c = StgStack_sp(stack) + WDS(index); + ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); + + W_ bitmap, size, specialType; + (bitmap) = ccall getRetFunBitmapWord(c); + (size) = ccall getRetFunBitmapSize(c); + + return (bitmap, size); +} + getLargeBitmapzh(P_ stack, W_ index){ P_ c, stgArrBytes; W_ size; @@ -113,6 +125,18 @@ getLargeBitmapzh(P_ stack, W_ index){ return (stgArrBytes, size); } +getRetFunLargeBitmapzh(P_ stack, W_ index){ + P_ c, stgArrBytes; + W_ size; + c = StgStack_sp(stack) + WDS(index); + ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); + + (stgArrBytes) = ccall getRetFunLargeBitmaps(MyCapability(), c); + (size) = ccall getRetFunSize(c); + + return (stgArrBytes, size); +} + // TODO: Use generalized version unpackClosureReferencedByFramezh with offset=0 unpackClosureFromStackFramezh(P_ stack, W_ index){ P_ closurePtr, closurePtrPrime; @@ -167,3 +191,13 @@ getUnderflowFrameNextChunkzh(P_ stack, W_ index){ ASSERT(LOOKS_LIKE_CLOURE_PTR(next_chunk)); return (next_chunk); } + +getRetFunTypezh(P_ stack, W_ index){ + P_ c; + c = StgStack_sp(stack) + WDS(index); + ASSERT(LOOKS_LIKE_CLOSURE_PTR(c)); + + W_ type; + (type) = ccall getRetFunType(c); + return (type); +} ===================================== utils/deriveConstants/Main.hs ===================================== @@ -464,6 +464,10 @@ wanteds os = concat ,closureField C "StgCatchFrame" "handler" ,closureField C "StgCatchFrame" "exceptions_blocked" + ,closureField C "StgRetFun" "size" + ,closureField C "StgRetFun" "fun" + ,closureField C "StgRetFun" "payload" + ,closureSize C "StgPAP" ,closureField C "StgPAP" "n_args" ,closureFieldGcptr C "StgPAP" "fun" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/453b2623e13aefe4193c03fc55793ac30de33e16 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/453b2623e13aefe4193c03fc55793ac30de33e16 You're receiving 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 Nov 1 08:25:01 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 01 Nov 2022 04:25:01 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 496 commits: CI: Don't run lint-submods on nightly Message-ID: <6360d7dd784a3_815bc5156820427c@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - 7f613755 by Josh Meredith at 2022-11-01T09:28:16+01:00 Add ghcjs changes to deriveConstants: - change String targetOS option in deriveConstants to an enum - separate out getWantedGHSJS, removing generated c file in this path - - - - - 94058dc9 by doyougnu at 2022-11-01T09:28:16+01:00 Add JavaScript code generator Adapt code generator of GHCJS to GHC head. Currently it is only enabled with the hidden -fjavascript flag. It produces .o files that can't be used yet except by GHCJS's linker. Codegen: doc Codegen: correctly return linkable object Now we can build a static library (-staticlib) Codegen: doc genLit Codegen: use assignAll Codegen: introduce TypedExpr Refactor assignAll et al, add documentation Codegen: minor changes Doc - - - - - f80be809 by doyougnu at 2022-11-01T09:28:16+01:00 Add JS.Rts JS.Rts: compiles reword: progress on RtsTypes StgToJS.Config: add SDoc Context JSRts: move ppr, workaround def type JSRts.Types: compiles JS.Rts: closer to compiling JS.Rts: move jsIdIdent' to StgToJS.Monad JS.Rts: remove unused predicates JS: cleanup, comment sections, math funcs to Make JS.Rts.Types: compiles StgToJS.Expr: fix compilation errors StgToJS.DataCon: move initClosure JS.Rts: remove Alloc module JS.Rts: initalize Rts module, remove redundant fs JS: init Rts.Alloc move initClosure JS.Apply: unwinding combinators in progress JS: add helpers and fixmes JS.Rts.Apply: no more e's, add closure, reg helper StgToJS: add ToStat instance ClosureInfo JS.Rts.Apply: closer to compiling JS.Rts.Apply: more removal of # JS.Rts.Apply: (#) removed JS.Rts.Apply: compiles JS.Rts.Rts: just pretty printing left JS.Rts: Add Notes JS.Rts: add file headers and notes JS.Rts.Rts: fixing stringy issues JS.Rts.Rts: compiles JS.Rts.Rts: fix non-exhaustive patterns warnings - - - - - 6842ce3f by Sylvain Henry at 2022-11-01T09:28:16+01:00 Doc has been moved into GHC.StgToJs top-level module - - - - - 9dd06a22 by Sylvain Henry at 2022-11-01T09:28:16+01:00 JS.Rts; refactoring and move to StgToJS * add closure manipulation helpers and use them in Apply * add cache (Array) for pre-generated PAP names * reduce line length: * use BlockArguments instead of parens * remove implicit mconcat in jVar's body Rts: more refactorings Rts: move into StgToJS hierarchy - - - - - 41084c20 by Sylvain Henry at 2022-11-01T09:28:16+01:00 JS: cleanup, renaming, better module layout Various degrees of cleanup adapting GHCJS to GHC. We move several functions to CoreUtils, remove duplication between the JS.Rts.Apply and Apply module and factor out closure related code into a Closure module for cohesion. Deduplicate code between Rts.Apply and Apply Move might_be_a_function into CoreUtils Factorize closure stuff into Closure module Rename closureExtra into closureField Minor renamings, comments... - - - - - 1ff824fc by Sylvain Henry at 2022-11-01T09:28:16+01:00 JS.Backend: add FFI code but don't implement yet FFI: don't crash on JavaScript foreign imports Note that they are still not desugared properly!! But the following cmd doesn't crash anymore: ghc -fjavascript Test.hs -fforce-recomp -ddump-tc -fno-code -ddump-ds FFI: adapt GHCJS desugarer FFI: support direct application The following example: foo :: Int# -> Int# foo = add 50000# foreign import javascript "(function(x,y) { return (x + y) })" add :: Int# -> Int# -> Int# is compiled into an application like this: var h$mainZCMzifoozur2_e; h$mainZCMzifoozur2_e = (function() { var h$mainZCMziaddzur1; h$mainZCMziaddzur1 = h$r1.d1; var h$$mainZCMzietazuB0_8KXnScrCjF5; h$$mainZCMzietazuB0_8KXnScrCjF5 = h$r2; h$r3 = h$$mainZCMzietazuB0_8KXnScrCjF5; h$r2 = 50000; h$r1 = h$mainZCMziaddzur1; return h$ap_2_2_fast(); return h$rs(); }); var h$mainZCMziaddzur1_e; h$mainZCMziaddzur1_e = (function() { var h$$mainZCMzidszusAk_236l8r0P8S9; h$$mainZCMzidszusAk_236l8r0P8S9 = h$r2; var h$$mainZCMzids1zusAl_336l8r0P8S9; h$$mainZCMzids1zusAl_336l8r0P8S9 = h$r3; var h$$mainZCM_2; var h$$mainZCMziwildzusAn_536l8r0P8S9; try { h$$mainZCMziwildzusAn_536l8r0P8S9 = (function(x,y) { return (x + y) })(h$$mainZCMzidszusAk_236l8r0P8S9, h$$mainZCMzids1zusAl_336l8r0P8S9) } catch(except) { return h$throwJSException(except) }; var h$$mainZCMzids3zusAp_736l8r0P8S9; h$$mainZCMzids3zusAp_736l8r0P8S9 = h$$mainZCMziwildzusAn_536l8r0P8S9; h$r1 = h$$mainZCMzids3zusAp_736l8r0P8S9; return h$rs(); }); FFI: correctly dispatch for foreign exports too FFI: move C FFI desugaring into its own module FFI: avoid DynFlags in toJsName (copy of toCName) - - - - - 0b09bc78 by Sylvain Henry at 2022-11-01T09:28:16+01:00 Configure: preliminary support for triple js-unknown-ghcjs - - - - - 7e43de12 by Sylvain Henry at 2022-11-01T09:28:16+01:00 Driver: enable JS backend by default for JS arch - - - - - 6c2636fb by doyougnu at 2022-11-01T09:28:16+01:00 JS.Backend: Add JS specific Linker JS: initialize Linker, DynamicLinking JS.Printer: adapted to GHC Head JS.Printer: some cleanup and init Printer StgToJS.Printer: Compiles JS.Linker: Add types, expose JS keywords JS.Syntax: add Binary instance on Ident's JS.Linker: Migrate more Types to Data.Binary JS.Linker.Types: compiles and adapted to GHC Head JS.Linker.Types: compiles JS.Linker.Types: add UseBase type JS.Linker: Comments and Cleanup JS.Linker.Types: add TH types, Env type, DepsLoc JS.Linker: more FIXMEs numerous Linker fixes JS.Linker: removed Text references JS.UnitUtils: add package related helper functions JS.Linker: more DynFlags removal JS.Linker: Time for semantic errors JS.Linker: DynFlags finally removed JS.Linker: 107 compile errors to go JS.Linker.Utils: initialized, adapted to GHC Head JS.Linker.Utils: initialize Utils module JS.Linker.Utils: more utils JS.Rts: move rtsText to Rts JS.Linker: linkerStats implemented JS.Compactor: compiles, adapted to GHC Head JS.Compactor: have to retrofit compact for linker JS.Linker.Compactor: unwinding lenses JS.Linker.Compactor: comments over addItem JS.Linker.Compactor: Lenses removed JS.Linker.Compactor: SHA256 removed JS.Linker.Compactor: only missing instances left JS.Linker.Compactor: compiles JS.Linker: compiles, adapted to ghc Head JS.Linker: More progress JS.Linker: link in memory compiles JS.Linker: just shims left JS.Linker.DynamicLinking compiles: adapted to head JS.Linker.DynamicLinking: initialization JS.Linker.DynamicLinking: compiles up to Variants JS.Variants: initialize JS.Linker: numerous and various fixes JS.Linker.DynamicLinking: only small errors left JS.Linker.Archive: compiles, adapted to GHC Head JS.Linker: initialize Archive compat module JS.Linker.Archive: minor fixes JS.Linker.DynamicLinking: compiles JS.Linker: cleanup, remove Variants, add comments fixup: more cleanup JS.Linker: more cleanup and comments - - - - - d750a80b by Sylvain Henry at 2022-11-01T09:28:16+01:00 Minor panic fix - - - - - 8dc11e2a by Sylvain Henry at 2022-11-01T09:28:16+01:00 Linker: fix stage2 build - - - - - 7be5e174 by Sylvain Henry at 2022-11-01T09:28:16+01:00 Configure: Add support fo JS as unregistered ABI Configure: detect emscripten tools e.g. on ArchLinux: EMSDK=/usr/lib/emscripten EMSDK_LLVM=/opt/emscripten-llvm ./configure --target=js-unknown-ghcjs Configure: detect nm tool too, required by Hadrian Configure: make StgToJS use non-unregisterised ABI It should probably be a third kind of ABI... - - - - - 99860e97 by doyougnu at 2022-11-01T09:28:16+01:00 JS.Linker: Hook up to GHC.Driver.Pipeline JS.Linker.Types: Add newGhcjsEnv function JS.UnitUtils: fix encodeModule api JS.Linker: more removal of HscEnv JS.Linker: hooked into GHC.Driver.Pipeline - - - - - b96ffdcc by Sylvain Henry at 2022-11-01T09:28:16+01:00 VERY WIP Hadrian/rts fixes export EMSDK_LLVM=/opt/emscripten-llvm export EMSDK=/usr/lib/emscripten export PATH=./inplace/ghcjs_toolchain/bin:$PATH ./configure --target=js-unknown-ghcjs ./hadrian/build --flavour=quick-js -j --bignum=native --docs=none -V - - - - - 1cdaf0d2 by Sylvain Henry at 2022-11-01T09:28:16+01:00 Force creation of rts library with dummy file - - - - - 8b7850d2 by Sylvain Henry at 2022-11-01T09:28:16+01:00 ghc-prim: avoid building C files - - - - - 411e6a09 by Sylvain Henry at 2022-11-01T09:28:16+01:00 Hadrian: disable -fllvm - - - - - c23615d2 by Sylvain Henry at 2022-11-01T09:28:16+01:00 JS: fix caches Note that the fact that we need index 0 may hide another issue... - - - - - c5779ebd by Sylvain Henry at 2022-11-01T09:28:16+01:00 codegen: enhance genCon debug message - - - - - e83669ad by Sylvain Henry at 2022-11-01T09:28:16+01:00 RTS: fix stupid comment - - - - - b1e75caa by Sylvain Henry at 2022-11-01T09:28:16+01:00 RTS: embed headers - - - - - 329e88a0 by Sylvain Henry at 2022-11-01T09:28:16+01:00 JS.StgToJS: add documentation header for JS Types - - - - - 52d9647f by Sylvain Henry at 2022-11-01T09:28:16+01:00 CodeGen: refactor ExprCtx code - - - - - e4105a3c by Sylvain Henry at 2022-11-01T09:28:16+01:00 CodeGen: cache LNE frame size - - - - - f9df64e9 by doyougnu at 2022-11-01T09:28:16+01:00 JS.Types: Add Outputable for TypedExpr - - - - - 3f3e09e0 by doyougnu at 2022-11-01T09:28:16+01:00 JS.CoreUtils: handle IOPort case - - - - - 4159901b by doyougnu at 2022-11-01T09:28:16+01:00 JS.Expr: Fix unhandled datacon for RuntimeRep - - - - - b808520c by doyougnu at 2022-11-01T09:28:16+01:00 JS.Literals: Adapt genLit to new Literal domain - - - - - 380dee1f by Sylvain Henry at 2022-11-01T09:28:16+01:00 RTS: expose more headers (required to build base) - - - - - 87950e1e by Sylvain Henry at 2022-11-01T09:28:16+01:00 Base: don't build C and Cmm sources with ghcjs - - - - - 93d711f6 by Sylvain Henry at 2022-11-01T09:28:16+01:00 Tentatively set NO_REGS for JS platforms - - - - - 0bea1ff2 by Sylvain Henry at 2022-11-01T09:28:16+01:00 CodeGen: output LitRubbish as null JS values - - - - - 002f3486 by Sylvain Henry at 2022-11-01T09:28:16+01:00 base: disable forkOS and bound thread machinery - - - - - b5315add by Sylvain Henry at 2022-11-01T09:28:16+01:00 CodeGen: support StackSnapshot# in primTypeVt - - - - - 0795b72e by Sylvain Henry at 2022-11-01T09:28:16+01:00 CodeGen: better debug message for assignCoerce1 - - - - - 3de503ee by Sylvain Henry at 2022-11-01T09:28:16+01:00 Misc: enable HasDebugCallStack for zipWithEqual* - - - - - 4338231e by Sylvain Henry at 2022-11-01T09:28:17+01:00 CodeGen: remove useless imports - - - - - a9675027 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Stg: expose pprStgAlt - - - - - 9eeb8114 by Sylvain Henry at 2022-11-01T09:28:17+01:00 CodeGen: restore assignAll (instead of assignAllEqual) - - - - - 225cd755 by Sylvain Henry at 2022-11-01T09:28:17+01:00 CodeGen: handle proxy# - - - - - 4bbb9b5d by doyougnu at 2022-11-01T09:28:17+01:00 ghc-heap: Don't compile Cmm file for JS-Backend - - - - - 44ef79b5 by doyougnu at 2022-11-01T09:28:17+01:00 Driver.Main: minor refactor do_code_gen To clearly separate the JS-Backend from any other backend - - - - - 46011cbc by Sylvain Henry at 2022-11-01T09:28:17+01:00 Configure: fix echo on Mac, add ghcjs target OS - - - - - b3ddb708 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Configure: fix previous commit - - - - - 92cc4acf by Luite Stegeman at 2022-11-01T09:28:17+01:00 fix package name in module name field of system dependencies - - - - - 47d77601 by Luite Stegeman at 2022-11-01T09:28:17+01:00 fix duplicate module name in symbols - - - - - 10e39a66 by doyougnu at 2022-11-01T09:28:17+01:00 GHCi.FFI: ignore ffi.h and friends for js-backend - - - - - de33e625 by Sylvain Henry at 2022-11-01T09:28:17+01:00 RTS: fix build of native rts - - - - - 0bb3dd9b by Sylvain Henry at 2022-11-01T09:28:17+01:00 Remove temporary -fjavascript flag - - - - - 8afa7d9d by Sylvain Henry at 2022-11-01T09:28:17+01:00 Codegen: fix symbol names ppr - - - - - a5e2931a by Sylvain Henry at 2022-11-01T09:28:17+01:00 Outputable: add ShortText instance - - - - - e61f6315 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Linker: enhance debugging message - - - - - e9d7802e by Sylvain Henry at 2022-11-01T09:28:17+01:00 Remove unused ghcjs unit related code - - - - - 43720677 by Sylvain Henry at 2022-11-01T09:28:17+01:00 ghci: Avoid unused-xyz warnings - - - - - e5424368 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Linker: remove wiring of ghcjs-prim and ghcjs-th They will be replaced by ghc-prim, base, template-haskell, etc. - - - - - 9370b34b by Sylvain Henry at 2022-11-01T09:28:17+01:00 Add outputable instance for Deps - - - - - 91eb3e9c by doyougnu at 2022-11-01T09:28:17+01:00 Docs: JS.Syntax, JS.Make docs done JS-backend: Add documentation headers Docs: JS.Syntax done Docs: JS.Make done Docs: JS.Make JS.Syntax refined a bit - - - - - 2a9c1d86 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Rename u_env into unit_env (more common) - - - - - b3cf255e by Sylvain Henry at 2022-11-01T09:28:17+01:00 Linker: deduplication + fixes - deduplicate code that was copied from old GHC - explicitly add preloadUnits to the link - avoid calling getShims - - - - - ee072345 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Linker: reenable packStrings (not yet implemented though) - - - - - df2b0913 by Sylvain Henry at 2022-11-01T09:28:17+01:00 ShortText: add singleton - - - - - 5f84d72d by Sylvain Henry at 2022-11-01T09:28:17+01:00 Linker: force less efficient (but working) static encoding - - - - - 60d7ff83 by Luite Stegeman at 2022-11-01T09:28:17+01:00 add GHCJS modules to base package - - - - - 38bc27e7 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Linker: remove JS Shims,tiny GHC.Linker refactor - - - - - 1f5e230f by doyougnu at 2022-11-01T09:28:17+01:00 Hadrian: QuickJS ways [] --> Set - - - - - 251776dc by doyougnu at 2022-11-01T09:28:17+01:00 JS-Backend: rebased to master 468f919b First rebase of the JS-Backend. This rebase includes the JS backend combined with !7442 (new backend design). Unfortunately we have to short circuit the new backend design because the JS backend takes over after STG and not after StgToCmm. What's working: - hadrian builds JS backend - JS backend outputs .js files and "links" them What still has to be done: - JS backend is missing core js libraries as we add these we discover bugs in the linker and js rts. - - - - - 797f2800 by doyougnu at 2022-11-01T09:28:17+01:00 JS: silence haddock warnings JS Backend: remove misc. warnings - - - - - 0942489b by doyougnu at 2022-11-01T09:28:17+01:00 JS Backend: ghcjs_HOST_OS --> js_HOST_ARCH - - - - - 905c12a2 by Sylvain Henry at 2022-11-01T09:28:17+01:00 JS.Linker: add shims GHCJS uses JS files for primitive things like the GC and RTS. We call these JS files "shims". This sequence of commits adds shims from JS and includes them for linking. In addition the shim directory is controlled via an evironment variable JS_RTS_PATH...at least for now. Linker: implement tryReadShimFile Linker: link with shims provided via an env variable Use JS_RTS_PATH to provide a directory into which .js and .js.pp files will be linked into rts.js JS.Linker: add js dir at root, fix js cpp includes JS.gc.pp: remove variadic macro JS.RTS: add rts JS shims files, remove shim CPP RTS: remove the need for rts.h and add rts JS files rts.h only contained a few constants duplicated in the codegen. Let's use the Haskell version as the single source of truth and pass defined values explicitly to cpp command line ("-DXYZ=abc" arguments). Also switch from "raw" (use_cpp_and_not_cc_dash_E = True) to the opposite: in both case we call "cc -E" (meh), but with False the preprocessor doesn't choke one varargs in macros. RTS: remove integer.js.pp We use the native ghc-bignum backend, so we don't need the GMP compatible JS code. In addition, this code was failing to run as it requires the JSBN (https://www.npmjs.com/package/jsbn) "Javascript big number" library, which we don't necessarily have installed. RTS: fix typo in field name RTS: generate CPP macros in Haskell RTS: share common CPP def into CAFs - - - - - c8a512e1 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Linker: add more types Some cleanup Enhance and fix LinkerStats Document and refactor renderLinker Split collectDeps Fix collectDeps Fix linker stats rendering Remove unused seqListSpine It isn't used in ghcjs either - - - - - aa1dfa2c by Sylvain Henry at 2022-11-01T09:28:17+01:00 Add some missing primops (Word32,Int32) Also fix the rendering of missing primops (they must be z-encoded to avoid having a "#" in their JS name) - - - - - b014b79b by Sylvain Henry at 2022-11-01T09:28:17+01:00 FFI: desugar every foreign import/export in JS with JS backend It means we also desugar CApi calls into JS. It's probably wrong but instead of generating invalid JS we will only get the failure at runtime when we will use the function. fixup - - - - - 9bfa5350 by doyougnu at 2022-11-01T09:28:17+01:00 JS.Linker: remove dflags includePath workaround. We implemented a workaround for shims that modified the dynflags includePaths so that the JS backend would find the rts.h file during CPP of shims. Since aebcca98 this is no longer required because we've removed the need for rts.h completely. Thus, this commit reverts that modification. - - - - - c1f2fee1 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Temporarily wire-in base's shim Use JS_BASE_PATH env var to set base's shim directory (js_base for now) Also minor other changes base: fix encoding for JS arch - - - - - c22ed97f by Sylvain Henry at 2022-11-01T09:28:17+01:00 Add primops Add primop - - - - - e8653ffd by doyougnu at 2022-11-01T09:28:17+01:00 Make Shims type, refactor JS Linker This commit: - Adds a proper Shim type and associated utilities. These utitlies are purposefully limited to ensure the ShimLbl tag is preserved thus guarenteeing shim ordering at link time. - Refactors the JS backend linker to use this ordering and Shim API. The ordering is not correct (yet!) but with this API its much easier to triage, experiment and diagnose link time issues. Refactor linker to compile time shim ordering - - - - - 1512269d by doyougnu at 2022-11-01T09:28:17+01:00 Base: Adapt primitives to JS backend, add base.js - - - - - 4a68f980 by doyougnu at 2022-11-01T09:28:17+01:00 Base: Remove binding forms in JS ffi - - - - - d6b65306 by Josh Meredith at 2022-11-01T09:28:17+01:00 Replace GHCJS Objectable with GHC Binary - - - - - 45a51350 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Binary: remove unused Map instance - - - - - 039e0f21 by Sylvain Henry at 2022-11-01T09:28:17+01:00 CodeGen: Add export list - - - - - 6397cf6f by Sylvain Henry at 2022-11-01T09:28:17+01:00 Primops: add some Int64/Word64 primops - - - - - 48cc267c by Sylvain Henry at 2022-11-01T09:28:17+01:00 base: fix one ffi import - - - - - b4f5acb5 by doyougnu at 2022-11-01T09:28:17+01:00 base: CPP for JS-backend, adapt write in base shim This commit ports over each CPP directive from GHCJS to base. In addition, it adds struct.js.pp to Base shim directory and modifies h$base_write to always take 6 arguments. Thereby avoiding errors such as "c(bytesWritten) is not a function". The missing parameter was the file descriptor object, fdo, which was looked up in the function itself and is now passed through to comport with the FFI expectations. - - - - - a1e0db69 by doyougnu at 2022-11-01T09:28:17+01:00 fixup: remove redundant struct.js.pp in js_base - - - - - 6ff6085a by doyougnu at 2022-11-01T09:28:17+01:00 JS.Linker: enable linker RTS symbols - - - - - 5d4bcb15 by doyougnu at 2022-11-01T09:28:17+01:00 base.GHCJS: adapt Prim to direct call FFI format - - - - - 851b2192 by doyougnu at 2022-11-01T09:28:17+01:00 Linker: Load JSVal from base not ghc-prim - - - - - 1bdf3cc2 by doyougnu at 2022-11-01T09:28:17+01:00 fixup: caught one more reference to JSVal in prim - - - - - cd336990 by Sylvain Henry at 2022-11-01T09:28:17+01:00 base: match on js arch , not ghcjs os - - - - - ce5513d3 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Fix MK_JSVAL - - - - - 14604a13 by doyougnu at 2022-11-01T09:28:17+01:00 Prim: cleanup comments - - - - - e0f08c68 by doyougnu at 2022-11-01T09:28:17+01:00 JS.Prim: add Int64 PrimOps - - - - - 9debf57d by Sylvain Henry at 2022-11-01T09:28:17+01:00 Vendor MD5 lib - - - - - cc6f808a by Sylvain Henry at 2022-11-01T09:28:17+01:00 More 64-bit primops - - - - - ab6b9786 by Sylvain Henry at 2022-11-01T09:28:17+01:00 CodeGen: use if10 helper - - - - - aff475ba by Sylvain Henry at 2022-11-01T09:28:17+01:00 Ppr: fix selector to avoid adding a newline - - - - - e0eec69e by doyougnu at 2022-11-01T09:28:17+01:00 base: GHCJS.Prim make ffi imports use anon funcs - - - - - a2257b62 by Sylvain Henry at 2022-11-01T09:28:17+01:00 Linker: disable invalid constructors again - - - - - e9c6ee18 by Sylvain Henry at 2022-11-01T09:28:18+01:00 More 64-bits primops - - - - - a0151b25 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Fix base_write function - - - - - eba4ac82 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Fix base_write for 32-bit size_t - - - - - 76d120ff by Sylvain Henry at 2022-11-01T09:28:18+01:00 Configure: fix detection of the target toolchain - - - - - b4630b2a by Sylvain Henry at 2022-11-01T09:28:18+01:00 Remove js_base directory - - - - - 1d67f17d by Sylvain Henry at 2022-11-01T09:28:18+01:00 Kill Node when the main loop reports an unhandled exception - - - - - 58499e44 by Sylvain Henry at 2022-11-01T09:28:18+01:00 CodeGen: preparation to make match on primops complete - - - - - b2a7e9ce by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primops: fix Compact primops - - - - - 839bfa9b by Sylvain Henry at 2022-11-01T09:28:18+01:00 Ignore result arity for some exception primops - - - - - 62a5e525 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Fix more primops. Bump array submodule! - - - - - 7cbb74c3 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Compact: fix return of 3 values - - - - - e47ddb89 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Configure: switch to absolute path - - - - - 2ad10f1e by Sylvain Henry at 2022-11-01T09:28:18+01:00 Add a few primops - - - - - 156a1d9c by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: implement WordAdd2 - - - - - 8e8df87d by Luite Stegeman at 2022-11-01T09:28:18+01:00 quick fix for uTypeVt and typePrimRep panics this may cause other panics, a full fix will require a bit more rework and probably removal of VarType - - - - - 63d313c0 by Josh Meredith at 2022-11-01T09:28:18+01:00 Replace ShortText with (Lexical)FastString in GHCJS backend - - - - - 7f3d8267 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primops: add arithmetic ops Primops: add decodeDoubleInt64 back Primop: added timesInt2# Primop: add mulWord32 and mul2Word32 - - - - - d4a40234 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Reduce dependency on goog - - - - - 2a758c76 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: implement quotWord32, remWord32, and quotRemWord32 - - - - - 00b57675 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: Implement quotRem2Word32, misc fixes Primop: implement quotRem2Word32 Primop: fix timesInt2# Primop: fix some shifting primops - - - - - 3fea1dcf by Sylvain Henry at 2022-11-01T09:28:18+01:00 Fix bug in upd_frame I've introduced this bug when I've refactored the code to use helpers to assign closures. - - - - - 9a7e13c3 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: throw an exception for unimplemented primops - - - - - 544603b3 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: fix remWord32 - - - - - 8599b57a by Josh Meredith at 2022-11-01T09:28:18+01:00 Configure: add EMSDK_BIN, match emsdk expectations Change EMSDK vars to match emscripten/emsdk_env.sh definitions Add EMSDK_BIN environment variable to configure - - - - - 5a6f9146 by Sylvain Henry at 2022-11-01T09:28:18+01:00 resultSize: correctly handle Void# - - - - - 96475620 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: fix Sized test, more shifting fixes Primop: ensure that we return u32 values for word primops Also a refactoring from i3 to i32 for clarity. Primop: add/fix more shifting primops Primops: fix Sized test! - - - - - 4b00505b by Sylvain Henry at 2022-11-01T09:28:18+01:00 StgToJS.Apply: Docs Doc Doc - - - - - 35109092 by Josh Meredith at 2022-11-01T09:28:18+01:00 Fix EMSDK configure condition - - - - - d17c75a1 by doyougnu at 2022-11-01T09:28:18+01:00 StgToJS.Arg: Unboxable Literal Optimization note - - - - - 0db9b9c4 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Fix Outputable instances for JExpr/JVal - Put orphan instances in JS.Ppr - Also fix some redundant imports - - - - - 2ec1d0e7 by doyougnu at 2022-11-01T09:28:18+01:00 configure: avoid CXX stdlib check for js backend and some cleanup for a previously mis-applied commit during rebasing - - - - - 837c1e04 by doyougnu at 2022-11-01T09:28:18+01:00 fixup: misc. fixes post rebase - - - - - 3eaac985 by Sylvain Henry at 2022-11-01T09:28:18+01:00 PrimOps: add more 64-bit primops PrimOp: implement more 64-bit primops + PM fix Ensure that we cover every primop explicitly - - - - - 46e0295a by Sylvain Henry at 2022-11-01T09:28:18+01:00 PrimOp: correclty (un)handle new thread related primops - - - - - ec3f86b3 by Sylvain Henry at 2022-11-01T09:28:18+01:00 PrimOp: disable LabelThreadOp for now - - - - - 507f2fb2 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Minor doc/cleanup Fix more redundant imports - - - - - ace7d730 by doyougnu at 2022-11-01T09:28:18+01:00 base: GHCJS.Prim directory --> GHC.JS.Prim - - - - - 330a8a04 by Luite Stegeman at 2022-11-01T09:28:18+01:00 implement KeepAlive primop - - - - - edc5b65f by Sylvain Henry at 2022-11-01T09:28:18+01:00 Remove orphan instance for StaticArg - - - - - db70468a by Sylvain Henry at 2022-11-01T09:28:18+01:00 Remove redundant jsIdIdent' function - - - - - d7ec93ee by Sylvain Henry at 2022-11-01T09:28:18+01:00 Split StgToJS.Monad into StgToJS.{Monad,Ids,Stack} - - - - - 7e4c112b by Sylvain Henry at 2022-11-01T09:28:18+01:00 Apply: remove commented case (wasn't optimized either in latest ghcjs) - - - - - 269bead7 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Doc: Apply Apply: doc and refactoring - use new types instead of Bool/Int - factorize some code - - - - - aa7c85a5 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: arith fixes Primop: fix 64-bit shifting primops + add some traces Primop: fix quotRem2Word32 Primop: fix timesInt2. Progress towards passing arith003 PrimOp: fix timesInt32 PrimOp: use mulWord32 when appropriate - - - - - 2aaca866 by doyougnu at 2022-11-01T09:28:18+01:00 Configure: remove EMSDK hacks and wrapper scripts configure JS: remove wrapper scripts Configure: remove EMSDK hacks. Use emconfigure instead emconfigure ./configure --target=js-unknown-ghcjs - - - - - 9870c338 by Sylvain Henry at 2022-11-01T09:28:18+01:00 GHCJS.Prim leftovers - - - - - 2ac65c80 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Linker: fix linking issue for tuples - - - - - 20510109 by Sylvain Henry at 2022-11-01T09:28:18+01:00 FFI: remove narrowing Fix tests such as cgrun015 (Core lint error) - - - - - 92b6f7da by Sylvain Henry at 2022-11-01T09:28:18+01:00 Linker: disable logs with default verbosity - - - - - ab2caf9e by Sylvain Henry at 2022-11-01T09:28:18+01:00 Append program name in top-level exception handler - - - - - 30ed9aa6 by doyougnu at 2022-11-01T09:28:18+01:00 GHC.JS: Remove FIXMEs JS.Syntax: Remove FIXMEs JS.Make: remove FIXMEs JS.Ppr/Transform: Remove FIXMEs - - - - - 766d8393 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: fix timesInt2# Pass arith003 test - - - - - 6e2055d6 by doyougnu at 2022-11-01T09:28:18+01:00 JS.Linker.Linker: remove FIXMEs, clean dead code - - - - - 6dd07866 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Linker: link platform shim before the others - - - - - f1058a83 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primops: rework 64-bit and Word32 primops - Use BigInt instead of complex and buggy bit twiddling. We'll assess performance later. Let's use a correct and simple implementation for now. - Implement previously missing 64-bit quot and rem - Refactor logical operators and Prim module more generally - - - - - 12cd4e27 by Sylvain Henry at 2022-11-01T09:28:18+01:00 PrimOp: fixup previous commit... - - - - - 091be68d by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: fixup previous commit - - - - - 88717142 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Doc: minor changes - - - - - 1119fe40 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Add debug option to watch for insertion of undefined/null in the stack - - - - - 042c32bb by Sylvain Henry at 2022-11-01T09:28:18+01:00 Apply: fix tag generation - - - - - 3f17a157 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Remove redundant import - - - - - 0d11bb5d by Sylvain Henry at 2022-11-01T09:28:18+01:00 Testsuite: disable Cmm tests with the JS backend - - - - - 9542788b by Sylvain Henry at 2022-11-01T09:28:18+01:00 Base: fix c_interruptible_open - - - - - a9c8d0d1 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Base: fix typo in long_from_number - - - - - c3d5ed52 by Sylvain Henry at 2022-11-01T09:28:18+01:00 Env: only add program name to errors, not to traces - - - - - 951ee7bf by Sylvain Henry at 2022-11-01T09:28:18+01:00 Testsuite: disable more Cmm tests - - - - - b89fead4 by doyougnu at 2022-11-01T09:28:18+01:00 JS.Linker: removes FIXMEs JS.Linker.Linker: remove FIXMEs, clean dead code StgToJS.Linker.Utils: remove FIXMEs Compactor: Remove FIXMEs StgToJS.Linker.Types: Remove FIXMEs JS.Linker.Archive/Dynamic: remove FIXMEs StgToJS.Linker.Shims: remove FIXMEs - - - - - cc72fb1a by doyougnu at 2022-11-01T09:28:18+01:00 JS RTS: remove FIXMEs StgToJS.Rts.Types: Remove FIXMEs - - - - - 5a710e3a by Sylvain Henry at 2022-11-01T09:28:18+01:00 Primop: fix bswap32/64 (cf cgrun072) - - - - - 49d29bdf by Sylvain Henry at 2022-11-01T09:28:18+01:00 Testsuite: normalise ghc program name - - - - - 49bfc800 by doyougnu at 2022-11-01T09:28:18+01:00 JS Backend: Remove FIXMEs StgToJS.Apply: Remove FIXMEs StgToJS.FFI: remove FIXMEs StgToJS.Expr: remove FIXMEs StgToJS: Remove FIXMEs - - - - - 02dca6bc by Sylvain Henry at 2022-11-01T09:28:18+01:00 Enable RTS args filtering (cf cgrun025) - - - - - 9ebdde4f by Sylvain Henry at 2022-11-01T09:28:18+01:00 Remove trailing whitespaces (whitespace test) - - - - - a25f5873 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Testsuite: remove platform prefix for unlit tool - - - - - 5b327189 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Primop: fix Int64 conversion/negate (integerConversions test) - - - - - 0f850ac8 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Linker: remove message with default verbosity - - - - - 5b7f8f80 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Testsuite: normalise .jsexe suffix - - - - - ffb3c708 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Remove warning about orphan instance - - - - - 8c12d8b5 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Compactor: disable dead code - - - - - 7f42f9b9 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Exception: implement raiseUnderflow etc. as primops - - - - - 5117ead2 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Primop: fix Int8/18 quot/rem - - - - - 2c737d75 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Linker: refactor wired-in deps - - - - - 4cce6072 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Ppr: remove useless left padding for functions in JS dumps - - - - - d5e3ecaa by Josh Meredith at 2022-11-01T09:28:19+01:00 Disable llvm ways and ghci for JS backend testsuite - - - - - 6a73363e by Sylvain Henry at 2022-11-01T09:28:19+01:00 StaticPtr: don't generate CStubs for the JS backend - - - - - 8b97e5c1 by Sylvain Henry at 2022-11-01T09:28:19+01:00 StaticPtr: fix hs_spt_lookup after upstream change - - - - - 17205732 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Testsuite: fix normalisation for unlit T8430 shows: `js-unknown-ghcjs-unlit' failed in phase `Literate pre-processor'. (Exit code: 1) Notice the quote around the program name. So I've made the regex match more cases (i.e. not only lines starting with the program name). - - - - - 660ba6ed by Sylvain Henry at 2022-11-01T09:28:19+01:00 Codegen: fix codegen of string literals Due to FastString change: Before: Text.pack . BSC.unpack After: mkFastString . BSC.unpack It seems that Text handles buggy multi-byte codepoints split into several String Chars. - - - - - a9ca0115 by Sylvain Henry at 2022-11-01T09:28:19+01:00 CPP: fix LINE markers. Only disable them for JS - - - - - 7fc3dada by Luite Stegeman at 2022-11-01T09:28:19+01:00 add JavaScript files listed in js-sources to package archives - - - - - c443e9c0 by Luite Stegeman at 2022-11-01T09:28:19+01:00 update rts js files to include recent fixes - - - - - 47db92a7 by Luite Stegeman at 2022-11-01T09:28:19+01:00 fix definitions in js/rts.h - - - - - ec9c1ce0 by Josh Meredith at 2022-11-01T09:28:19+01:00 stopgap fix for missing ghc-pkg in cross-compiler tests - - - - - b6b5de8d by Sylvain Henry at 2022-11-01T09:28:19+01:00 Testsuite: better fix for finding prefixed tools - - - - - 0cfa4ef2 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Ppr: add hangBrace helper - - - - - d943b233 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Only declare ccs var in profiling mode - - - - - bc935d9e by Sylvain Henry at 2022-11-01T09:28:19+01:00 Don't consider recursive bindings as inline nor as evaluated Fix mdo001 - - - - - aee7b63b by Sylvain Henry at 2022-11-01T09:28:19+01:00 Hadrian: disable shared libs for JS target - - - - - 8139e93d by Sylvain Henry at 2022-11-01T09:28:19+01:00 Support -ddump-stg-final with the JS backend - - - - - 359a2f03 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Add ticky_ghc0 flavour transformer to ticky stage1 - - - - - 43a3491c by Sylvain Henry at 2022-11-01T09:28:19+01:00 Don't read object file when -ddump-js isn't passed - - - - - b1956dba by Sylvain Henry at 2022-11-01T09:28:19+01:00 Object: remove dead code + renaming - - - - - e3054c1d by Sylvain Henry at 2022-11-01T09:28:19+01:00 Object: replace SymbolTableR with Dictionary - - - - - 8910adb1 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Object: refactoring - - - - - 62051b6d by Sylvain Henry at 2022-11-01T09:28:19+01:00 RTS: link platform.js before the others! - - - - - fbbe54e0 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Hadrian: treat JS objects similarly to other objects - - - - - 6abb5436 by Luite Stegeman at 2022-11-01T09:28:19+01:00 fix javascript FFI calls for read and write - - - - - adfd785e by doyougnu at 2022-11-01T09:28:19+01:00 propagate ppr code changes to JS backend - - - - - 2d02ef30 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Switch from Data.Binary and ByteString to BinHandle - - - - - 5500f86f by Sylvain Henry at 2022-11-01T09:28:19+01:00 Perf: use Ppr's LeftMode to output JS - - - - - 28d07267 by doyougnu at 2022-11-01T09:28:19+01:00 Primops: Add {Index,Write,Read}ByteArrayAs ops Still need to check for correctness based on T4442. minor doc fixes fixup: add some Index..As primops fixup missed type signature Primops: Add WriteByteArrayOp_Word8AsFoo ops Primops: {Index,Read,Write}FooAsBar done except Addr's Primops: add {Index,Read,Write}ByteArrayAsAddr ops These will need to be tested for correctness with T4442.hs - - - - - 710329f3 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Move platform.js to base (it must be linked first) - - - - - e1cfbfa1 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Remove old shim directory - - - - - 235b01f7 by doyougnu at 2022-11-01T09:28:19+01:00 JS.Prim: more PrimOps {IndexByteArrayAs, CAS} Primop: WriteByteArrayOp_Word8AsChar use setInt8 Primops: remove dv_s_u8 This function is non-sensical. Due to the infelicities of JS as a platform we must use Int8 and friends to write, then coerce to a word, thus dv_s_iN are the only legal calls for a write, and dv_s_uN legal for Index and Reads. Primops: set dv_u8 to correct method call should be getUint8, not getUInt8, of course the naming convention changes ever so slightly for Words. Primops: T4442 finishes ByteArrayAs still fails JS.Prim: More IndexByteAAs primops JS.Prim: Prefetch PrimOps are noOps JS.Primops: Doc explaining lack of vector support JS.Prim: add CAS and Fetch Ops - - - - - d0ac611b by doyougnu at 2022-11-01T09:28:19+01:00 GHC.Utils.Binary: BinDictionary -> FSTable Rename to avoid naming conflict with haddock. - - - - - fc83ddfa by Josh Meredith at 2022-11-01T09:28:19+01:00 Adjust derefnull test exit code for ghcjs - - - - - 28beb8f0 by doyougnu at 2022-11-01T09:28:19+01:00 Fix Driver missing type signature warnings - - - - - 51702dbc by doyougnu at 2022-11-01T09:28:19+01:00 PipeLine.Execute: silence warnings on JS backend - - - - - 1e32acc3 by doyougnu at 2022-11-01T09:28:19+01:00 JS.Primops: Add Bit reverse ops - - - - - 1f2d7d7a by doyougnu at 2022-11-01T09:28:19+01:00 SysTools.Tasks: quiet non-totality warnings - - - - - b000df6f by doyougnu at 2022-11-01T09:28:19+01:00 JS.Primops: Add InterlockedExchange Addr Word - - - - - 2deda1f0 by Sylvain Henry at 2022-11-01T09:28:19+01:00 base: conditional js-sources - - - - - 902dc242 by Sylvain Henry at 2022-11-01T09:28:19+01:00 TH: add support for JS files - - - - - 0746db88 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Linker: fix creation of directories in output paths - - - - - 3ecf993e by Sylvain Henry at 2022-11-01T09:28:19+01:00 Backpack: fix empty stubs - - - - - 93c64c87 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Add encodeDouble/Float RTS functions - - - - - 89944169 by Sylvain Henry at 2022-11-01T09:28:19+01:00 encodeDouble: correctly handle 0 base - - - - - 6e438b76 by doyougnu at 2022-11-01T09:28:19+01:00 JS.Primops: Add listThreads op - - - - - 70519622 by doyougnu at 2022-11-01T09:28:19+01:00 JS.Primops: Add Read/WriteAddrOp ops - - - - - 30c1583b by doyougnu at 2022-11-01T09:28:19+01:00 JS: Linker and Compactor: cleanup and docs Compactor: Cleanup: Remove dead comments JS.Linker.Types: cleanup and document module - - - - - 8d9562bd by doyougnu at 2022-11-01T09:28:19+01:00 StgToJS.Linker: Add docs to utility modules StgToJS.Linker.Utils: more docs StgToJS.Linker.Archive: more docs - - - - - 74bb7959 by doyougnu at 2022-11-01T09:28:19+01:00 StgToJS.Object: Add documentation - - - - - f9a9da6b by Sylvain Henry at 2022-11-01T09:28:19+01:00 Refactor Expr - - - - - f8e61577 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Object: reduce pinned allocation. And don't forget to hClose invalid objects - - - - - d789c629 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Fix pdep (cgrun075) - - - - - b8aec0d5 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Fix error message (don't mention emscripten) - - - - - 09821db5 by Sylvain Henry at 2022-11-01T09:28:19+01:00 Add Float/Word casts - - - - - 76f829aa by Sylvain Henry at 2022-11-01T09:28:19+01:00 Disable HPC tests with JS backend - - - - - bbecd081 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Fix encodeDouble/Float - - - - - e799d864 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Implement putchar (fix cgrun015) - - - - - 17c8c141 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Fix decoding of denormalized floats - - - - - 7f5389a8 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Fix isFloatDenormalized function - - - - - 66d09993 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Reuse convert buffer - - - - - 4e08413e by Sylvain Henry at 2022-11-01T09:28:20+01:00 Reuse convert buffer bis - - - - - 1125a5f7 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Skip some tests that require the dynamic linker - - - - - 5699c280 by Josh Meredith at 2022-11-01T09:28:20+01:00 JavaScript ShrinkSmallMutableArrayOp_Char & GetSizeofSmallMutableArrayOp - - - - - acd28465 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable more linker tests - - - - - c2a89bef by Sylvain Henry at 2022-11-01T09:28:20+01:00 Testsuite: better normalisation for ghc and ghc-pkg Allow normalisation for ghc and ghc-pkg anywhere in the output, not just at the beginning of the line. Fix T1750 and ghcpkg05 for example - - - - - 166e7cf5 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Skip T14373 because it requires Cmm - - - - - 6ab8f0e3 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable cg010 with JS backend - - - - - a9c1bcb0 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Testsuite: better normalisation of .jsexe extension - - - - - d8e5cb24 by doyougnu at 2022-11-01T09:28:20+01:00 JS: Linker,Rts docs and cleanup JS.Linker: Cleanup: remove unused functions/types JS.Rts.Types: remove dead code, docs StgToJS.RTS: cleanup and more docs - - - - - f5f8e5df by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable recomp015 - - - - - 8444d963 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Minor refactoring - - - - - 3916138c by Sylvain Henry at 2022-11-01T09:28:20+01:00 Temporary fix the testsuite bug - - - - - 5299be22 by doyougnu at 2022-11-01T09:28:20+01:00 JS.StgToJS.Types: Docs and cleanup - - - - - a6dcb043 by Josh Meredith at 2022-11-01T09:28:20+01:00 change JS.Transform.Idents* to use UniqDSet from Set - - - - - 0dc4d34a by Sylvain Henry at 2022-11-01T09:28:20+01:00 Minor Linker cleanup Minor cleanup - - - - - cdadb904 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Linker: load all the dependent units transitively - - - - - 768a8f4b by doyougnu at 2022-11-01T09:28:20+01:00 JS: Add Docs and cleanup StgToJS.{Arg,Ids} JS.Arg: docs and cleanup StgToJS.Arg: add minimal docs StgToJS.Ids: Add header - - - - - 42609682 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Implement h$sleep (T5611) - - - - - 428e6a1a by Sylvain Henry at 2022-11-01T09:28:20+01:00 Linker: don't link the same unit twice - - - - - 92650f4e by doyougnu at 2022-11-01T09:28:20+01:00 JS: docs, cleanup, StgToJS.{Expr,DataCon,Stack} StgToJS.Deps/Expr: add docs StgToJS.DataCon: add minor docs StgToJS.Stack: Docs and cleanup In particular: -- Removing some single use functions -- Some minor refactors related to these removals StgToJS: comments on static args and optimizeFree - - - - - 6a2d1fb7 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable compact tests - - - - - 0d27e6d3 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Add support for JS files passed on the command line - - - - - e4c07387 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Minor cleanup in compactor - - - - - c48d885a by Sylvain Henry at 2022-11-01T09:28:20+01:00 Fix encoding of unboxed strings (don't pass through FastString/h$str) - - - - - 7b4633db by doyougnu at 2022-11-01T09:28:20+01:00 JS: Misc fixes post Del-Cont rebase - - - - - 4d8ebdda by Sylvain Henry at 2022-11-01T09:28:20+01:00 Minor cleanup - - - - - f39d4d86 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Add log1p and expm1 (fix cgrun078) - - - - - d63ba818 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Assume existence of Math.fround and use it in Float's primops - - - - - 952d772d by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable "debug" test - - - - - a41b7e84 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Implement copyMutableArray with overlap support - - - - - b8de79f4 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Skip CmmSwitchTests - - - - - 19a01519 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Fix WordToDouble/WordToFloat (Word2Float32 test) - - - - - c6adc6d0 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Skip one more test - - - - - 889b7dcd by Sylvain Henry at 2022-11-01T09:28:20+01:00 Fix after GHC.Tuple to GHC.Tuple.Prim - - - - - 4a7894fb by Sylvain Henry at 2022-11-01T09:28:20+01:00 Fix InterlockedExchange primops (cgrun080) - - - - - 4bec82fc by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable T12059 - - - - - 21aa43d5 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Implement sqrt/sqrtf (fix T14619) - - - - - 441c1a10 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Skip more tests - - - - - 1d4cfb34 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable conc012 - - - - - 5cefab5e by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable more Cmm tests - - - - - 3184f196 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Fix AtomicPrimops test. Some refactoring in Prim too - - - - - 766b8f6b by Sylvain Henry at 2022-11-01T09:28:20+01:00 Use GHCJS's signExtend/narrow - - - - - f47f40a5 by Josh Meredith at 2022-11-01T09:28:20+01:00 Implement get/set thread label prims - - - - - 484554dc by doyougnu at 2022-11-01T09:28:20+01:00 JS: remove Linker.Archive module - - - - - 2e16f61e by Sylvain Henry at 2022-11-01T09:28:20+01:00 Start disabling tests that use TH/interpreter - - - - - 13d3629a by Josh Meredith at 2022-11-01T09:28:20+01:00 Add flagged bounds checking to JS primops - - - - - 7618a745 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable more tests - - - - - 74f43554 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable T1791 - - - - - c97891f7 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Raise NonTermination as an async exception - - - - - 2f22bdb7 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Expect IOPort test to be broken - - - - - b41e5701 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Implement rts_isThreaded (fix jules_xref2) - - - - - 1afc18b8 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable outofmem2 test - - - - - 7549ef26 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable delimited continuation tests - - - - - eff390f4 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable native RTS flag tests - - - - - ec5fd113 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable more tests - - - - - b00e65d8 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable more tests - - - - - 74d86d08 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Skip more tests - - - - - 524bf175 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable try_putmvar tests that use C files - - - - - f8ee8e75 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Disable even more tests - - - - - f7caed95 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Linker: remove dead code (base, compactor) - - - - - 3a045551 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Better shims linking - - - - - bb3b1bc4 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Make isJsFile a bit faster by only reading the header - - - - - b99aec42 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Linker: write directly into output file - - - - - 04d87180 by Sylvain Henry at 2022-11-01T09:28:20+01:00 Linker: more refactoring - - - - - c33f4971 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Lazy loading of JStat in object code - - - - - 1e1841a7 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Use Ppr hack to render directly into a file - - - - - 24deacc5 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Fix backpack dependencies - - - - - 2955d32a by doyougnu at 2022-11-01T09:28:21+01:00 testsuite: add js_skip_csources function Used to indicate a test that fails in the JS backend because the JS Backend does not yet support c-sources in cabal files. - - - - - 5038385e by doyougnu at 2022-11-01T09:28:21+01:00 testsuite: JS: skip tests which use c-sources Skip because these tests use c-sources and the JS backend does not yet support including c-sources testsuite: JS backend: skip backpack tests testsuite: JS: skip c-sources ffi tests testsuite: JS: skip multipleHomeUnits_odir testsuite: JS: disable more backpack tests testsuite: JS: disable c-sources rts tests testsuite: JS: skip c-sources codeGen tests testsuite: JS: skip c-sources generics test - - - - - 7774b4e7 by Josh Meredith at 2022-11-01T09:28:21+01:00 use exit code 134 for JS prim bounds checks - - - - - fcb7be1d by Sylvain Henry at 2022-11-01T09:28:21+01:00 Remove panic in getObject - - - - - 5d2ea946 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Add debug and Outputable instances - - - - - b31784db by Sylvain Henry at 2022-11-01T09:28:21+01:00 Remove backup file - - - - - 45414f79 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Skip overflow tests - - - - - 598c3fb7 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Fix RTS includes for native build - - - - - 57021955 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Doc - - - - - fadd1b8b by Sylvain Henry at 2022-11-01T09:28:21+01:00 Add perf-js Hadrian flavour - - - - - 46506483 by doyougnu at 2022-11-01T09:28:21+01:00 JS.Syntax: fix doc wording - - - - - f1bf31b4 by doyougnu at 2022-11-01T09:28:21+01:00 Driver: JS: tweak error message - - - - - f92ddef1 by Josh Meredith at 2022-11-01T09:28:21+01:00 Factor JS platform constants and h$programArgs/h$rtsArgs into functions with init - - - - - 780bcbfa by Josh Meredith at 2022-11-01T09:28:21+01:00 Fix function name from h$shrinkMutableArray to h$shrinkMutableCharArray - - - - - 5f91ffe5 by Luite Stegeman at 2022-11-01T09:28:21+01:00 allow async exceptions to be thrown from outside a haskell thread - - - - - 53468ca2 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Remove shims and refactor Cpp I've removed the use of js/rts.h and js/constants.h again. We generate their contents at cpp time. Instead of wiring z-encoded strings into these macros, we should derive them from wired-in Names so that they stay correct in the future. Using wired-in Names as single source of truth. - - - - - cc1f8cc6 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Support RTS globals (used by GHC) and EISDIR Did this while trying to fix CallArity1 (still failing) - - - - - 9c004bbf by Sylvain Henry at 2022-11-01T09:28:21+01:00 Remove JS keywords 1. The list is incomplete 2. We prefix locals with "h$$" so there is no risk of conflict with JS keywords - - - - - ddab551f by Sylvain Henry at 2022-11-01T09:28:21+01:00 Remove dead code - - - - - 12f91c58 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Make ident supply strict (no need to make it lazy, list already is) - - - - - 2fdc991c by Sylvain Henry at 2022-11-01T09:28:21+01:00 Add optional assign to DeclStat and remove dead code - - - - - 85306fc1 by doyougnu at 2022-11-01T09:28:21+01:00 JS: Note on JS .o file order, fix .o files To be specific: 1. add Note [JS Backend .o file procedure] 2. ensure that .o files are touch'd in JS backend postHsc phase. This fixes "missing object file" errors produced by 'GHC.Driver.Main.checkObjects'. - - - - - 7e2af61d by Luite Stegeman at 2022-11-01T09:28:21+01:00 start a subtransaction in a catchStm block - - - - - aec731ec by Sylvain Henry at 2022-11-01T09:28:21+01:00 Use FastMutInt in G for uniques - - - - - 24d0a8bf by Sylvain Henry at 2022-11-01T09:28:21+01:00 Compactor: remove dead code - - - - - bea17167 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Compactor: remove more dead code - - - - - 3ec76a14 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Compactor: remove unused debug code - - - - - d7589056 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Compactor: remove unimplemented packStrings - - - - - 405c4fef by Sylvain Henry at 2022-11-01T09:28:21+01:00 RTS: fix query/replace error - - - - - 0ae7fa77 by Luite Stegeman at 2022-11-01T09:28:21+01:00 remove unused STM check invariants - - - - - 61154def by Josh Meredith at 2022-11-01T09:28:21+01:00 Refactor renaming functions from Compactor module into the Linker - - - - - 80fa13f9 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Linker: refactor and cleanup after compactor removal - - - - - bfafaa9f by Sylvain Henry at 2022-11-01T09:28:21+01:00 Filter empty exports to avoid printing a lot of useless newlines - - - - - 42db2e67 by Sylvain Henry at 2022-11-01T09:28:21+01:00 RTS: remove dangling semicolons - - - - - dbfaadec by Sylvain Henry at 2022-11-01T09:28:21+01:00 RTS: remove more dangling semicolons - - - - - 9569b2e2 by Sylvain Henry at 2022-11-01T09:28:21+01:00 RTS: less semicolons - - - - - 11602431 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Only initialize statics once! - - - - - 5b912c4e by Sylvain Henry at 2022-11-01T09:28:21+01:00 Minor refactoring: avoid unpacking ShortText too soon - - - - - 9d228e6f by Sylvain Henry at 2022-11-01T09:28:21+01:00 Remove unused derived instances - - - - - 717c0107 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Use Ident in ClosureInfo instead of FastString - - - - - e1cfce1c by Sylvain Henry at 2022-11-01T09:28:21+01:00 Add identFS helper - - - - - 77a66710 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Fix liftToGlobal identsS wasn't correctly ported: it has to return all the Ident occurences, not only one. Fixed this and simplified liftToGlobal implementation. Used UniqFM instead of Map forn the global ident cache. - - - - - f2d4d196 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Refactor symbol generation. Avoid concatenating Strings or FastStrings. Concatenate ByteString instead. - - - - - bc102651 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Enhance Label symbol generation - - - - - 8e609063 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Rename fresh idents with their FastString unique Reduce by 2x the size of the generated file (on Cabal's Setup). - - - - - 1099be39 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Disable more tests - - - - - cbb93221 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Disable more tests - - - - - 40f6f444 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Disable ghc-heap tests - - - - - a0c8acab by Sylvain Henry at 2022-11-01T09:28:21+01:00 Mark flaky test as fragile - - - - - c022953d by Sylvain Henry at 2022-11-01T09:28:21+01:00 Fix bound checking - - - - - d459500a by Sylvain Henry at 2022-11-01T09:28:21+01:00 Fix note - - - - - d186f2bb by Sylvain Henry at 2022-11-01T09:28:21+01:00 Disable more tests - - - - - 1339e328 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Disable more tests - - - - - dc27c9b6 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Disable more tests - - - - - 50a5ef80 by doyougnu at 2022-11-01T09:28:21+01:00 testsuite: force ghc-pkg to use stage1 - - - - - 3b616e34 by doyougnu at 2022-11-01T09:28:21+01:00 fix linker errors post rebase Re-add InitFini.c to the rts, it was introduced in 78ab7afe244a7617d600a6180d81d9dec657114d but was somehow removed after a rebase. - - - - - e5513926 by doyougnu at 2022-11-01T09:28:21+01:00 testsuite: rts disable rtsflags001 for JS backend - - - - - 8e0cd904 by Josh Meredith at 2022-11-01T09:28:21+01:00 Disable runInteractiveProcess tests for ghcjs - - - - - 4f117717 by Josh Meredith at 2022-11-01T09:28:21+01:00 Disable fed001 test for javascript backend - - - - - 8f76fff2 by Josh Meredith at 2022-11-01T09:28:21+01:00 Disable driver tests for JS backend that use foreign exports - - - - - 23cc6d30 by Josh Meredith at 2022-11-01T09:28:21+01:00 Disable ImpSafeOnly01..10 for JavaScript backend - - - - - 798ecf39 by Sylvain Henry at 2022-11-01T09:28:21+01:00 Add missing GHC globals - - - - - cf716b88 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable ffi for JS backend More Specically disable: ffi006 ffi008 ffi011 ffi013 ffi018 ffi019 ffi020 ffi021 ffi023 - - - - - e4204886 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable ghci linking tests for JS Specifically: ghcilink001 ghcilink003 ghcilink005 ghcilink006 - - - - - c8e21083 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix comment - - - - - e524d733 by Sylvain Henry at 2022-11-01T09:28:22+01:00 More bound checking - - - - - 01a48b0c by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix some Word reading in Prim - - - - - 53470d03 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Implement openDir Seems to work (with tracing) but tests still fail with getInt16 index error :'( - - - - - a03aa040 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable cabal tests for JS backend - - - - - 4ab0708f by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable bkpcabal[01-07] for JS backend - - - - - 9bf25e28 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable tests that cause OOM on JS These tests require the JS Backend to implement GHCJS's compactor, until that happens nodejs throws an exception that variable names are too long, hence we disable them. - - - - - 1a2d8fd1 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Disable HPC tests Bump hpc submodule - - - - - 2be9b3c5 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Avoid useless space change - - - - - a177cf46 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Remove duplicated comment - - - - - aae4a5b1 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Readd useless space - - - - - 2d40950c by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix some rts.cabal.in rebase glitches - - - - - a8635170 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable T12233 tests for JS backend - - - - - d0c51ee6 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix rts.cabal.in again - - - - - fdc3620f by Luite Stegeman at 2022-11-01T09:28:22+01:00 fix typo in dumpStackTop function - - - - - 4d949aee by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: remove js_skip_csources, use c_src - - - - - a361fc75 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip recomp4,8 on JS backend - - - - - 77550bdf by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip alloccounter1 and T19156 for JS These tests fail due to missing primops - - - - - 5865390b by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T7773 and topHandler01 for JS - - - - - 73e35828 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip rdynamic and T2615 for JS Backend - - - - - 48186ff3 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T4012 for JS backend - - - - - 003ad502 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T15427 for JS backend - - - - - bef8b598 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T19481, T19381, T3474 for JS - - - - - e64d3559 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip stack004 for JS backend - - - - - ef248290 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: JS skip ThreadDelay001 and encoding004 - - - - - 72889fcd by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip openFile003 for JS backend - - - - - e61f8977 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable T1959 and capi tests for JS - - - - - b9d405af by Sylvain Henry at 2022-11-01T09:28:22+01:00 Replace c_src with req_c - - - - - 142942ce by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix testsuite - - - - - d89c4201 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable CallArity, LintEtaExpand etc These cause a illegal op on directory error. Disable for now: CallArity1 LintEtaExpand T9595 T10942 T18522-dbg-ppr - - - - - 7089ce3b by Luite Stegeman at 2022-11-01T09:28:22+01:00 fix isJsCore predicates for base package - - - - - c1b0d550 by Sylvain Henry at 2022-11-01T09:28:22+01:00 CI: add CI script for the JS backend - - - - - 08cf4a66 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix rts.cabal again - - - - - 5b318bff by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix invalid use of predStage - - - - - 96ecfc70 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix hlint errors on CI - - - - - 719b13d4 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: disable that throw out of bounds on JS Specifically: T12733 T1372 T15594 T16219 T18567 T20509 T3007 different-db mhu-closure package-imports-20779 t19518 - - - - - b92834f4 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip EventlogOutput{1,2} for JS backend - - - - - fe1f3a99 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T1679, T2469, T4038 for JS and also skip UnliftedTVar2 - - - - - 648e5d10 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T4891 for JS backend This one throws illegal op on directory similar to T10942 and CallArity1 - - - - - e1cd80e9 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T8308 for JS JS backend does not have any ticky capability yet, so skip for now - - - - - dbd3a57f by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T9405 for JS JS backend does not yet support ticky - - - - - f17d64d6 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T14624, T20199 for JS backend - - - - - c02284cd by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T5594 and T5402 for JS - - - - - b650d375 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip openFile00{5,7} readFile001 for JS - - - - - c8f8ec02 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T11004 and T12504 for JS - - - - - a5fc2314 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip hGetBuf001, hReady00{1,2} for JS - - - - - 16955c95 by doyougnu at 2022-11-01T09:28:22+01:00 fixup: missed readwrite002 - - - - - fa732b26 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T18642 for JS - - - - - 24dd6e4a by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip TargetContents for JS - - - - - c3557faf by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T18481a T10678 and friends - - - - - 07a15e4c by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip RepPolyUnliftedDatatype2 for JS - - - - - cb436cf3 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip ghci some tests these throw not built for interactive use errors - - - - - 2745d3d3 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip DocsInHiFileTH for JS - - - - - 105ac546 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T7037, T7702, safePkg01 for JS - - - - - 65efdf96 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip tests that throw gmake error Specifically: T15261a T15261b T16318 T17648 T20214 T21336c rtsopts002 withRtsOpts - - - - - db820cbf by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T3837, hsc2hs003 typecheck.testeq1 - - - - - c6fd2897 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip fat005 for JS - - - - - 4d1f5691 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip topHandler02,03 for JS - - - - - 3095f574 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip tests that unexpected pass/fail - - - - - 07401b96 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Try to fix Hadrian for native - - - - - 244a3453 by Luite Stegeman at 2022-11-01T09:28:22+01:00 fix index.html template newlines and use all.js for now (at least it works) - - - - - f690d516 by Sylvain Henry at 2022-11-01T09:28:22+01:00 Fix testsuite typo - - - - - 19166565 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip golden failure tests Specifically: GcStaticPointers T13167 T14452 T16707 T17481 T7160 bkp32 fptr01 - - - - - 1b4dbfe3 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T13525 for JS Fails for missing h$base_mkfifo - - - - - ac7ff0c7 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip tests which timeout on JS Specifically: Timeout001 listThreads mask002 - - - - - e0d1ac34 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip failing IO tests for JS Specifically: hClose002 hFileSize002 hSetBuffering003 sum_mod - - - - - 8778d3ff by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip countReaders001 for JS - - - - - 58e57454 by doyougnu at 2022-11-01T09:28:22+01:00 testsuite: skip T10414 for JS backend - - - - - 4630ce02 by Luite Stegeman at 2022-11-01T09:28:23+01:00 correct stack offset when restarting an STM transaction - - - - - a3e4c984 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: skip T11155 T21336a T21869 for JS - - - - - d1fc7755 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: skip failing linker and hp2ps tests - - - - - b83e0a85 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: skip out of memory tests for JS - - - - - 49bc8589 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: skip remaining failing tests for JS - - - - - ead844ef by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: fix typo - - - - - 9eb7cba8 by doyougnu at 2022-11-01T09:28:23+01:00 hadrian: fix js and native testing - - - - - 4ef34221 by Sylvain Henry at 2022-11-01T09:28:23+01:00 Skip one test - - - - - eac64fac by Sylvain Henry at 2022-11-01T09:28:23+01:00 Skip one more test - - - - - bc6b233b by Sylvain Henry at 2022-11-01T09:28:23+01:00 Add missing comma - - - - - c1378620 by Sylvain Henry at 2022-11-01T09:28:23+01:00 Only change the test environment for cross - - - - - b7b79316 by Sylvain Henry at 2022-11-01T09:28:23+01:00 Force creation of hpc/haddock/runghc programs for cross - - - - - fbc47abc by doyougnu at 2022-11-01T09:28:23+01:00 process: skip process tests for JS backend - - - - - 5ec173d9 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: skip remaining failing tests for JS - - - - - 4d7a7359 by doyougnu at 2022-11-01T09:28:23+01:00 process: skip T1780, T8343, T4889 for JS - - - - - 641ab48b by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: skip T12852 for JS backend - - - - - f1e4d17f by doyougnu at 2022-11-01T09:28:23+01:00 stm: skip failing tests for JS backend - - - - - a94e462d by Sylvain Henry at 2022-11-01T09:28:23+01:00 Some changes to Binary after reviews - - - - - 25d8a82a by Sylvain Henry at 2022-11-01T09:28:23+01:00 Rename back defaultUserData into noUserData - - - - - bc711011 by Sylvain Henry at 2022-11-01T09:28:23+01:00 Revert backpack change - - - - - 751cb7c5 by Sylvain Henry at 2022-11-01T09:28:23+01:00 Don't create directory in copyWithHeader - - - - - 60fd198a by Sylvain Henry at 2022-11-01T09:28:23+01:00 Remove now useless changes to Ppr - - - - - b7287b1d by Josh Meredith at 2022-11-01T09:28:23+01:00 Change js_skip to js_broken(22350) for ImpSafeOnly01..10 tests - - - - - 0b2d6837 by Josh Meredith at 2022-11-01T09:28:23+01:00 Change js_broken(22350) to js_skip for safePkg01 test - - - - - 73f423c6 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: Cabal js_skip -> js_broken(22351) Issue: https://gitlab.haskell.org/ghc/ghc/-/issues/22351 - - - - - f6728f13 by doyougnu at 2022-11-01T09:28:23+01:00 add req_js_compactor, update impacted tests Issue: https://gitlab.haskell.org/ghc/ghc/-/issues/22352 - - - - - 8310b2a6 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: mark more tests with req_js_compactor - - - - - e2e31931 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: js_skip -> js_broken(22355) more tests Specifically: T11004 T12504 T3837 hsc2hs003 T15758 exec_signals hsc2hs001 hsc2hs002 typecheck.testeq1 See tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/22355 - - - - - 4dc69fca by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: mark #22356 tests as js_broken Specifically: T12733 T1372 T15594 T16219 T18567 T20509 T3007 different-db mhu-closure package-imports-20779 t19518 - - - - - 651cc160 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use js_broken(22349) for releavant base tests - - - - - 35b48f47 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use js_broken(22359) for relevant tests - - - - - 95e34165 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use js_broken(22360) for releavant tests - - - - - 9fc8bd57 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use req_ffi_exports for JS-skipped driver* tests - - - - - 1428e913 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use req_c for some JS-skipped tests - - - - - 3bd9f504 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use js_broken(22362) for package.conf.d errored tests - - - - - 2c844d27 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use req_interp for JS-skipped ghcilink001/3/5/6 - - - - - 4db1ec58 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use js_broken(22363) for affected ffi000 tests - - - - - db06c9b1 by Josh Meredith at 2022-11-01T09:28:23+01:00 Use js_broken(22364) for affected tests - - - - - db749e23 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: mark tests as js_broken(22370) Specifically: rtsopts002 T15261a T15261b T16318 T17648 T20214 T21336c withRtsOpts Tracking ticket: #22370 - - - - - 5167b8be by Josh Meredith at 2022-11-01T09:28:23+01:00 Use js_broken(22351) for T10955dyn - - - - - 7d628a04 by Sylvain Henry at 2022-11-01T09:28:23+01:00 Remove trailing semicolons - - - - - 27dfbeac by Sylvain Henry at 2022-11-01T09:28:23+01:00 Minor fixes after rebase - - - - - e01532d0 by doyougnu at 2022-11-01T09:28:23+01:00 test: T23674{w} recomp004 load_short_name -> req_c - - - - - 184cab5b by Josh Meredith at 2022-11-01T09:28:23+01:00 Upgrade miscellaneous tests from js_skip to js_broken(22261) - - - - - 90b55de0 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite mark compactor tests as js_broken(22352) - - - - - 56d68875 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: mark tests js_skip -> js_broken(22374) Specifically: hGetBuf001 T12852 T12903 rdynamic T2615 T4012 T15427 T18642 T19381 T19481 T3474 stack004 encoding004 ThreadDelay001 TargetContents openFile003 T13525 Tracking Ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/22374 - - - - - d93edb99 by doyougnu at 2022-11-01T09:28:23+01:00 stm: mark tests for JS backend as broken - - - - - a9fcaf9a by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: mark js_skip -> js_broken(22261) Specifically: DocsInHiFileTH alloccounter1 T19156 rtsflags002 T7773 topHandler01 T1959 T1679 T2469 T4038 UnliftedTVar2 T15136 T8308 T9405 openFile005 openFile007 readFile001 countReaders001 RepPolyUnliftedDatatype2 fat005 topHandler02 topHandler03 T10414 T11760 T12035j T13191 T14075 T16473 T17499 T17720a T17720b T17720c T20030_test1j T3924 T8766 T9839_01 T9848 fptr01 GcStaticPointers T13167 T14452 T17481 T7160 listThreads mask002 Timeout001 hClose002 hFileSize002 hSetBuffering003 sum_mod T11155 T21336a T21869 T15904 MergeObjsMode recomp011 T13914 executablePath rn.prog006 T16916 recomp008 - - - - - 6f43b7d2 by Sylvain Henry at 2022-11-01T09:28:23+01:00 Remove added configure comment - - - - - 47b2a07d by Sylvain Henry at 2022-11-01T09:28:23+01:00 Fix res_js_compactor leftover - - - - - 101b9fc5 by doyougnu at 2022-11-01T09:28:23+01:00 testsuite: mark more tests as broken for JS Specifically tests which throw reference errors: hReady001 hReady002 readwrite002 fed001 Capi_Ctype_001 Capi_Ctype_002 T7037 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/22374 - - - - - 49cc3ea5 by doyougnu at 2022-11-01T09:28:23+01:00 genToplevelConEntry: Fix for InferTags at Stg - - - - - 25 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backend/Internal.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/StgToCmm.hs - + compiler/GHC/Driver/Config/StgToJS.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Phases.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Pipeline/Phases.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - + compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - + compiler/GHC/JS/Make.hs - + compiler/GHC/JS/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8aa1266ea65512b11a3a2a922ca75764c99b2639...49cc3ea5a3eb8518e826e4e666b590096c651965 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8aa1266ea65512b11a3a2a922ca75764c99b2639...49cc3ea5a3eb8518e826e4e666b590096c651965 You're receiving 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 Nov 1 08:28:25 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 01 Nov 2022 04:28:25 -0400 Subject: [Git][ghc/ghc][wip/javascript-backend] 70 commits: rts: ensure we are below maxHeapSize after returning megablocks Message-ID: <6360d8a92d755_815bc515cc20449e@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - 7f613755 by Josh Meredith at 2022-11-01T09:28:16+01:00 Add ghcjs changes to deriveConstants: - change String targetOS option in deriveConstants to an enum - separate out getWantedGHSJS, removing generated c file in this path - - - - - 8b8e9d02 by doyougnu at 2022-11-01T09:31:49+01:00 Add JavaScript backend Bump submodules - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/956f0749c08862f12073df167717363b028e6bc1...8b8e9d02cbb3f51cbc16a73f98236b8069fd1b37 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/956f0749c08862f12073df167717363b028e6bc1...8b8e9d02cbb3f51cbc16a73f98236b8069fd1b37 You're receiving 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 Nov 1 09:21:03 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 01 Nov 2022 05:21:03 -0400 Subject: [Git][ghc/ghc][wip/arity-type-9.4] Attemp fix for core lint failures Message-ID: <6360e4ff64ae1_815bc51428212785@gitlab.mail> Zubin pushed to branch wip/arity-type-9.4 at Glasgow Haskell Compiler / GHC Commits: 53235edd by Zubin Duggal at 2022-11-01T14:50:52+05:30 Attemp fix for core lint failures For an expression: joinrec foo = ... in expr we compute the arityType as `foldr andArityType (arityType expr) [arityType foo]` which is the same as `andArityType (arityType expr) (arityType foo)`. However, this is incorrect: joinrec go x = ... in go 0 then the arity of go is 1 (\?. T), but the arity of the overall expression is 0 (_|_). `andArityType` however returns (\?. T) for these, which is wrong. - - - - - 4 changed files: - compiler/GHC/Core/Opt/Arity.hs - + testsuite/tests/arityanal/should_compile/Arity17.hs - testsuite/tests/arityanal/should_compile/all.T - testsuite/tests/linters/notes.stdout Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1185,22 +1185,6 @@ arityType env (Let (NonRec b r) e) cheap_rhs = myExprIsCheap env r (Just (idType b)) env' = extendSigEnv env b (arityType env r) -arityType env (Let (Rec pairs) body) - | ((j,_):_) <- pairs - , isJoinId j - = -- See Note [arityType for join bindings] - foldr (andArityType env . do_one) (arityType rec_env body) pairs - where - rec_env = foldl add_bot env pairs - add_bot env (j,_) = extendSigEnv env j botArityType - - do_one :: (JoinId, CoreExpr) -> ArityType - do_one (j,rhs) - | Just arity <- isJoinId_maybe j - = arityType rec_env $ snd $ collectNBinders arity rhs - | otherwise - = pprPanic "arityType:joinrec" (ppr pairs) - arityType env (Let (Rec prs) e) = floatIn (all is_cheap prs) (arityType env' e) where ===================================== testsuite/tests/arityanal/should_compile/Arity17.hs ===================================== @@ -0,0 +1,27 @@ +module Bug (downsweep) where + +import GHC.Utils.Misc ( filterOut ) +import qualified Data.Map.Strict as M ( Map, elems ) +import qualified Data.Map as Map ( fromListWith ) + +type DownsweepCache = M.Map Int Int + +downsweep :: [Int] -> IO DownsweepCache +downsweep rootSummariesOk = do + let root_map = mkRootMap rootSummariesOk + checkDuplicates root_map + return root_map + where + checkDuplicates :: DownsweepCache -> IO () + checkDuplicates root_map = multiRootsErr dup_roots + where + dup_roots = filterOut (>2) (M.elems root_map) + +mkRootMap + :: [Int] + -> DownsweepCache +mkRootMap summaries = Map.fromListWith const + [ (s, s) | s <- summaries ] + +multiRootsErr :: [a] -> IO () +multiRootsErr [] = pure () ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -16,6 +16,7 @@ test('Arity13', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn test('Arity14', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity15', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('Arity17', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-package ghc -dcore-lint -O2']) # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -1,4 +1,6 @@ ref compiler/GHC/Core/Coercion/Axiom.hs:458:2: Note [RoughMap and rm_empty] +ref compiler/GHC/Core/Opt/Arity.hs:: Note [Combining case branches] +ref compiler/GHC/Core/Opt/Arity.hs:: Note [ArityType for let-bindings] ref compiler/GHC/Core/Opt/OccurAnal.hs:851:15: Note [Loop breaking] ref compiler/GHC/Core/Opt/SetLevels.hs:1598:30: Note [Top level scope] ref compiler/GHC/Core/Opt/Simplify.hs:2618:13: Note [Case binder next] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53235edd478bd4c5e29e4f254ce02559af259dd5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/53235edd478bd4c5e29e4f254ce02559af259dd5 You're receiving 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 Nov 1 10:43:34 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 01 Nov 2022 06:43:34 -0400 Subject: [Git][ghc/ghc][wip/T22379] 4 commits: CI: Don't run lint-submods on nightly Message-ID: <6360f85634e8b_815bc515042637e3@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22379 at Glasgow Haskell Compiler / GHC Commits: c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - 6f05ce62 by Simon Peyton Jones at 2022-10-31T15:36:55+00:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - e4eecc8d by Simon Peyton Jones at 2022-11-01T10:44:43+00:00 Improve skolem info - - - - - 11 changed files: - .gitlab-ci.yml - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - libraries/base/GHC/Pack.hs - testsuite/tests/deriving/should_fail/T21871.stderr - testsuite/tests/indexed-types/should_fail/T15870.stderr - + testsuite/tests/polykinds/T22379a.hs - + testsuite/tests/polykinds/T22379b.hs - testsuite/tests/polykinds/all.T Changes: ===================================== .gitlab-ci.yml ===================================== @@ -287,6 +287,9 @@ lint-submods: rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' allow_failure: false + # Don't run on nightly because the program needs a base commit to check. + - if: $NIGHTLY + when: never - allow_failure: true lint-submods-branch: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -3489,6 +3489,8 @@ bindTyClTyVars tycon_name thing_inside bindTyClTyVarsAndZonk :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a -- Like bindTyClTyVars, but in addition -- zonk the skolem TcTyVars of a PolyTcTyCon to TyVars +-- We always do this same zonking after a call to bindTyClTyVars, but +-- here we do it right away because there are no more unifications to come bindTyClTyVarsAndZonk tycon_name thing_inside = bindTyClTyVars tycon_name $ \ tc_bndrs tc_kind -> do { ze <- mkEmptyZonkEnv NoFlexi ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -411,21 +411,27 @@ TcTyCons are used for two distinct purposes 2. When checking a type/class declaration (in module GHC.Tc.TyCl), we come upon knowledge of the eventual tycon in bits and pieces, and we use a TcTyCon to record what we know before we are ready to build the - final TyCon. + final TyCon. Here is the plan: - We first build a MonoTcTyCon, then generalise to a PolyTcTyCon - See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType - Specifically: + Step 1 (inferInitialKinds, inference only, skipped for checking): + Make a MonoTcTyCon whose binders are TcTyVars, + which may contain free unification variables - S1) In kcTyClGroup, we use checkInitialKinds to get the - utterly-final Kind of all TyCons in the group that - (a) have a kind signature or - (b) have a CUSK. - This produces a PolyTcTyCon, that is, a TcTyCon in which the binders - and result kind are full of TyVars (not TcTyVars). No unification - variables here; everything is in its final form. + Step 2 (generaliseTcTyCon) + Generalise that MonoTcTyCon to make a PolyTcTyCon + Its binders are skolem TcTyVars, with accurate SkolemInfo + + Step 3 (tcTyClDecl) + Typecheck the type and class decls to produce a final TyCon + Its binders are final TyVars, not TcTyVars + + Note that a MonoTcTyCon can contain unification variables, + but a PolyTcTyCon does not: only skolem TcTyVars. See + Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType + + More details about /kind inference/: - S2) In kcTyClGroup, we use inferInitialKinds to look over the + S1) In kcTyClGroup, we use inferInitialKinds to look over the declaration of any TyCon that lacks a kind signature or CUSK, to determine its "shape"; for example, the number of parameters, and any kind signatures. @@ -434,27 +440,30 @@ TcTyCons are used for two distinct purposes "mono" because it has not been been generalised, and its binders and result kind may have free unification variables. - S3) Still in kcTyClGroup, we use kcLTyClDecl to kind-check the + S2) Still in kcTyClGroup, we use kcLTyClDecl to kind-check the body (class methods, data constructors, etc.) of each of these MonoTcTyCons, which has the effect of filling in the metavariables in the tycon's initial kind. - S4) Still in kcTyClGroup, we use generaliseTyClDecl to generalize - each MonoTcTyCon to get a PolyTcTyCon, with final TyVars in it, + S3) Still in kcTyClGroup, we use generaliseTyClDecl to generalize + each MonoTcTyCon to get a PolyTcTyCon, with skolem TcTyVars in it, and a final, fixed kind. - S5) Finally, back in TcTyClDecls, we extend the environment with + S4) Finally, back in TcTyClDecls, we extend the environment with the PolyTcTyCons, and typecheck each declaration (regardless of kind signatures etc) to get final TyCon. - These TcTyCons are stored in the local environment in GHC.Tc.TyCl, - until the real full TyCons can be created during desugaring. A - desugared program should never have a TcTyCon. + More details about /kind checking/ -3. A MonoTcTyCon can contain unification variables, but a PolyTcTyCon - does not: only skolem TcTyVars. + S5) In kcTyClGroup, we use checkInitialKinds to get the + utterly-final Kind of all TyCons in the group that + (a) have a separate kind signature or + (b) have a CUSK. + This produces a PolyTcTyCon, that is, a TcTyCon in which the binders + and result kind are full of TyVars (not TcTyVars). No unification + variables here; everything is in its final form. -4. tyConScopedTyVars. A challenging piece in all of this is that we +3. tyConScopedTyVars. A challenging piece in all of this is that we end up taking three separate passes over every declaration: - one in inferInitialKind (this pass look only at the head, not the body) - one in kcTyClDecls (to kind-check the body) @@ -2425,15 +2434,15 @@ tcClassDecl1 :: RolesInfo -> Name -> Maybe (LHsContext GhcRn) -> TcM Class tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs = fixM $ \ clas -> -- We need the knot because 'clas' is passed into tcClassATs - bindTyClTyVars class_name $ \ binders res_kind -> + bindTyClTyVars class_name $ \ tc_bndrs res_kind -> do { checkClassKindSig res_kind - ; traceTc "tcClassDecl 1" (ppr class_name $$ ppr binders) + ; traceTc "tcClassDecl 1" (ppr class_name $$ ppr tc_bndrs) ; let tycon_name = class_name -- We use the same name roles = roles_info tycon_name -- for TyCon and Class ; (ctxt, fds, sig_stuff, at_stuff) - <- pushLevelAndSolveEqualities skol_info binders $ - -- The (binderVars binders) is needed bring into scope the + <- pushLevelAndSolveEqualities skol_info tc_bndrs $ + -- The (binderVars tc_bndrs) is needed bring into scope the -- skolems bound by the class decl header (#17841) do { ctxt <- tcHsContext hs_ctxt ; fds <- mapM (addLocMA tc_fundep) fundeps @@ -2458,9 +2467,10 @@ tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs -- any unfilled coercion variables unless there is such an error -- The zonk also squeeze out the TcTyCons, and converts -- Skolems to tyvars. - ; ze <- mkEmptyZonkEnv NoFlexi - ; ctxt <- zonkTcTypesToTypesX ze ctxt - ; sig_stuff <- mapM (zonkTcMethInfoToMethInfoX ze) sig_stuff + ; ze <- mkEmptyZonkEnv NoFlexi + ; (ze, bndrs) <- zonkTyVarBindersX ze tc_bndrs -- From TcTyVars to TyVars + ; ctxt <- zonkTcTypesToTypesX ze ctxt + ; sig_stuff <- mapM (zonkTcMethInfoToMethInfoX ze) sig_stuff -- ToDo: do we need to zonk at_stuff? -- TODO: Allow us to distinguish between abstract class, @@ -2482,8 +2492,8 @@ tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs | otherwise = Just (ctxt, at_stuff, sig_stuff, mindef) - ; clas <- buildClass class_name binders roles fds body - ; traceTc "tcClassDecl" (ppr fundeps $$ ppr binders $$ + ; clas <- buildClass class_name bndrs roles fds body + ; traceTc "tcClassDecl" (ppr fundeps $$ ppr bndrs $$ ppr fds) ; return clas } where @@ -2712,7 +2722,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info , fdResultSig = L _ sig , fdInjectivityAnn = inj }) | DataFamily <- fam_info - = bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> do + = bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> do { traceTc "tcFamDecl1 data family:" (ppr tc_name) ; checkFamFlag tc_name @@ -2729,8 +2739,8 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info -- See also Note [Datatype return kinds] ; checkDataKindSig DataFamilySort res_kind ; tc_rep_name <- newTyConRepName tc_name - ; let inj = Injective $ replicate (length binders) True - tycon = mkFamilyTyCon tc_name binders + ; let inj = Injective $ replicate (length tc_bndrs) True + tycon = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) (DataFamilyTyCon tc_rep_name) @@ -2738,12 +2748,12 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info ; return tycon } | OpenTypeFamily <- fam_info - = bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> do + = bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> do { traceTc "tcFamDecl1 open type family:" (ppr tc_name) ; checkFamFlag tc_name - ; inj' <- tcInjectivity binders inj + ; inj' <- tcInjectivity tc_bndrs inj ; checkResultSigFlag tc_name sig -- check after injectivity for better errors - ; let tycon = mkFamilyTyCon tc_name binders res_kind + ; let tycon = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) OpenSynFamilyTyCon parent inj' ; return tycon } @@ -2754,10 +2764,10 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info do { traceTc "tcFamDecl1 Closed type family:" (ppr tc_name) -- the variables in the header scope only over the injectivity -- declaration but this is not involved here - ; (inj', binders, res_kind) - <- bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> - do { inj' <- tcInjectivity binders inj - ; return (inj', binders, res_kind) } + ; (inj', tc_bndrs, res_kind) + <- bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> + do { inj' <- tcInjectivity tc_bndrs inj + ; return (inj', tc_bndrs, res_kind) } ; checkFamFlag tc_name -- make sure we have -XTypeFamilies ; checkResultSigFlag tc_name sig @@ -2766,14 +2776,14 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info -- but eqns might be empty in the Just case as well ; case mb_eqns of Nothing -> - return $ mkFamilyTyCon tc_name binders res_kind + return $ mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) AbstractClosedSynFamilyTyCon parent inj' Just eqns -> do { -- Process the equations, creating CoAxBranches - ; let tc_fam_tc = mkTcTyCon tc_name binders res_kind + ; let tc_fam_tc = mkTcTyCon tc_name tc_bndrs res_kind noTcTyConScopedTyVars False {- this doesn't matter here -} ClosedTypeFamilyFlavour @@ -2792,7 +2802,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info | null eqns = Nothing -- mkBranchedCoAxiom fails on empty list | otherwise = Just (mkBranchedCoAxiom co_ax_name fam_tc branches) - fam_tc = mkFamilyTyCon tc_name binders res_kind (resultVariableName sig) + fam_tc = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) (ClosedSynFamilyTyCon mb_co_ax) parent inj' -- We check for instance validity later, when doing validity @@ -2853,10 +2863,10 @@ tcInjectivity tcbs (Just (L loc (InjectivityAnn _ _ lInjNames))) tcTySynRhs :: RolesInfo -> Name -> LHsType GhcRn -> TcM TyCon tcTySynRhs roles_info tc_name hs_ty - = bindTyClTyVars tc_name $ \ binders res_kind -> + = bindTyClTyVars tc_name $ \ tc_bndrs res_kind -> do { env <- getLclEnv ; traceTc "tc-syn" (ppr tc_name $$ ppr (tcl_env env)) - ; rhs_ty <- pushLevelAndSolveEqualities skol_info binders $ + ; rhs_ty <- pushLevelAndSolveEqualities skol_info tc_bndrs $ tcCheckLHsType hs_ty (TheKind res_kind) -- See Note [Error on unconstrained meta-variables] in GHC.Tc.Utils.TcMType @@ -2870,11 +2880,11 @@ tcTySynRhs roles_info tc_name hs_ty , ppr rhs_ty ] ) } ; doNotQuantifyTyVars dvs mk_doc - ; ze <- mkEmptyZonkEnv NoFlexi - ; (ze, binders) <- zonkTyVarBindersX ze binders - ; rhs_ty <- zonkTcTypeToTypeX ze rhs_ty + ; ze <- mkEmptyZonkEnv NoFlexi + ; (ze, bndrs) <- zonkTyVarBindersX ze tc_bndrs + ; rhs_ty <- zonkTcTypeToTypeX ze rhs_ty ; let roles = roles_info tc_name - ; return (buildSynTyCon tc_name binders res_kind roles rhs_ty) } + ; return (buildSynTyCon tc_name bndrs res_kind roles rhs_ty) } where skol_info = TyConSkol TypeSynonymFlavour tc_name ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -1735,12 +1735,6 @@ quantifyTyVars skol_info ns_strat dvs = return Nothing -- this can happen for a covar that's associated with -- a coercion hole. Test case: typecheck/should_compile/T2494 --- Omit: no TyVars now --- | not (isTcTyVar tkv) --- = return (Just tkv) -- For associated types in a class with a standalone --- -- kind signature, we have the class variables in --- -- scope, and they are TyVars not TcTyVars - | otherwise = Just <$> skolemiseQuantifiedTyVar skol_info tkv @@ -1785,13 +1779,19 @@ skolemiseQuantifiedTyVar :: SkolemInfo -> TcTyVar -> TcM TcTyVar skolemiseQuantifiedTyVar skol_info tv = case tcTyVarDetails tv of - SkolemTv {} -> do { kind <- zonkTcType (tyVarKind tv) - ; return (setTyVarKind tv kind) } - -- It might be a skolem type variable, - -- for example from a user type signature - MetaTv {} -> skolemiseUnboundMetaTyVar skol_info tv + SkolemTv _ lvl _ -- It might be a skolem type variable, + -- for example from a user type signature + -- But it might also be a shared meta-variable across several + -- type declarations, each with its own skol_info. The first + -- will skolemise it, but the other uses must update its + -- skolem info (#22379) + -> do { kind <- zonkTcType (tyVarKind tv) + ; let details = SkolemTv skol_info lvl False + name = tyVarName tv + ; return (mkTcTyVar name kind details) } + _other -> pprPanic "skolemiseQuantifiedTyVar" (ppr tv) -- RuntimeUnk -- | Default a type variable using the given defaulting strategy. ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -428,7 +428,7 @@ Invariants: - Flag tcTyConIsPoly = True; this is used only to short-cut zonking - tyConBinders are still TcTyConBinders, but they are /skolem/ TcTyVars, - with fixed kinds: no unification variables here + with fixed kinds, and acurate skoem info: no unification variables here tyConBinders includes the Inferred binders if any ===================================== libraries/base/GHC/Pack.hs ===================================== @@ -12,6 +12,11 @@ -- Stability : internal -- Portability : non-portable (GHC Extensions) -- +-- ⚠ Warning: Starting @base-4.18@, this module is being deprecated. +-- See https://gitlab.haskell.org/ghc/ghc/-/issues/21461 for more information. +-- +-- +-- -- This module provides a small set of low-level functions for packing -- and unpacking a chunk of bytes. Used by code emitted by the compiler -- plus the prelude libraries. ===================================== testsuite/tests/deriving/should_fail/T21871.stderr ===================================== @@ -3,7 +3,7 @@ T21871.hs:13:36: error: [GHC-25897] • Couldn't match kind ‘k’ with ‘*’ Expected kind ‘* -> *’, but ‘m’ has kind ‘k -> *’ ‘k’ is a rigid type variable bound by - the newtype declaration for ‘FooT’ + a `deriving' clause at T21871.hs:(10,1)-(13,36) • In the second argument of ‘ReaderT’, namely ‘m’ In the newtype declaration for ‘FooT’ ===================================== testsuite/tests/indexed-types/should_fail/T15870.stderr ===================================== @@ -3,7 +3,7 @@ T15870.hs:32:34: error: [GHC-25897] • Couldn't match kind ‘k’ with ‘*’ Expected kind ‘Optic @{k} a’, but ‘g2’ has kind ‘Optic @{*} b’ ‘k’ is a rigid type variable bound by - the instance declaration + a family instance declaration at T15870.hs:(27,1)-(32,35) • In the second argument of ‘Get’, namely ‘g2’ In the type ‘Get a g2’ ===================================== testsuite/tests/polykinds/T22379a.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind +import Data.Proxy (Proxy) + +data Delayed (env :: Type) (c :: Type) +data Handler (a :: Type) +data Router (a :: Type) + +-- class decl, then type decl + +class HasServer api where + type ServerT api (m :: Type -> Type) :: Type + + route :: + Proxy api + -> Delayed env (Server api) + -> Router env + + hoistServerWithContext + :: Proxy api + -> (forall x. m x -> n x) + -> ServerT api m + -> ServerT api n + +type Server aqi = ServerT aqi Handler + ===================================== testsuite/tests/polykinds/T22379b.hs ===================================== @@ -0,0 +1,30 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind +import Data.Proxy (Proxy) + +data Delayed (env :: Type) (c :: Type) +data Handler (a :: Type) +data Router (a :: Type) + +-- type decl, then class decl + +type Server aqi = ServerT aqi Handler + +class HasServer api where + type ServerT api (m :: Type -> Type) :: Type + + route :: + Proxy api + -> Delayed env (Server api) + -> Router env + + hoistServerWithContext + :: Proxy api + -> (forall x. m x -> n x) + -> ServerT api m + -> ServerT api n ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -239,3 +239,5 @@ test('T19739a', normal, compile, ['']) test('T19739b', normal, compile, ['']) test('T19739c', normal, compile, ['']) test('T19739d', normal, compile, ['']) +test('T22379a', normal, compile, ['']) +test('T22379b', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/436d935c565655d0930ca2a92bf8824d805bc7e4...e4eecc8d9eb70767988edcfe92c4a2d31878c029 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/436d935c565655d0930ca2a92bf8824d805bc7e4...e4eecc8d9eb70767988edcfe92c4a2d31878c029 You're receiving 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 Nov 1 10:45:19 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 01 Nov 2022 06:45:19 -0400 Subject: [Git][ghc/ghc][wip/T22379] Add accurate skolem info when quantifying Message-ID: <6360f8bf987eb_815bc514c826418@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22379 at Glasgow Haskell Compiler / GHC Commits: 1944cf80 by Simon Peyton Jones at 2022-11-01T10:46:57+00:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 9 changed files: - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - testsuite/tests/deriving/should_fail/T21871.stderr - testsuite/tests/indexed-types/should_fail/T15870.stderr - + testsuite/tests/polykinds/T22379a.hs - + testsuite/tests/polykinds/T22379b.hs - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -3489,6 +3489,8 @@ bindTyClTyVars tycon_name thing_inside bindTyClTyVarsAndZonk :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a -- Like bindTyClTyVars, but in addition -- zonk the skolem TcTyVars of a PolyTcTyCon to TyVars +-- We always do this same zonking after a call to bindTyClTyVars, but +-- here we do it right away because there are no more unifications to come bindTyClTyVarsAndZonk tycon_name thing_inside = bindTyClTyVars tycon_name $ \ tc_bndrs tc_kind -> do { ze <- mkEmptyZonkEnv NoFlexi ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -411,21 +411,27 @@ TcTyCons are used for two distinct purposes 2. When checking a type/class declaration (in module GHC.Tc.TyCl), we come upon knowledge of the eventual tycon in bits and pieces, and we use a TcTyCon to record what we know before we are ready to build the - final TyCon. + final TyCon. Here is the plan: - We first build a MonoTcTyCon, then generalise to a PolyTcTyCon - See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType - Specifically: + Step 1 (inferInitialKinds, inference only, skipped for checking): + Make a MonoTcTyCon whose binders are TcTyVars, + which may contain free unification variables - S1) In kcTyClGroup, we use checkInitialKinds to get the - utterly-final Kind of all TyCons in the group that - (a) have a kind signature or - (b) have a CUSK. - This produces a PolyTcTyCon, that is, a TcTyCon in which the binders - and result kind are full of TyVars (not TcTyVars). No unification - variables here; everything is in its final form. + Step 2 (generaliseTcTyCon) + Generalise that MonoTcTyCon to make a PolyTcTyCon + Its binders are skolem TcTyVars, with accurate SkolemInfo + + Step 3 (tcTyClDecl) + Typecheck the type and class decls to produce a final TyCon + Its binders are final TyVars, not TcTyVars + + Note that a MonoTcTyCon can contain unification variables, + but a PolyTcTyCon does not: only skolem TcTyVars. See + Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType + + More details about /kind inference/: - S2) In kcTyClGroup, we use inferInitialKinds to look over the + S1) In kcTyClGroup, we use inferInitialKinds to look over the declaration of any TyCon that lacks a kind signature or CUSK, to determine its "shape"; for example, the number of parameters, and any kind signatures. @@ -434,27 +440,30 @@ TcTyCons are used for two distinct purposes "mono" because it has not been been generalised, and its binders and result kind may have free unification variables. - S3) Still in kcTyClGroup, we use kcLTyClDecl to kind-check the + S2) Still in kcTyClGroup, we use kcLTyClDecl to kind-check the body (class methods, data constructors, etc.) of each of these MonoTcTyCons, which has the effect of filling in the metavariables in the tycon's initial kind. - S4) Still in kcTyClGroup, we use generaliseTyClDecl to generalize - each MonoTcTyCon to get a PolyTcTyCon, with final TyVars in it, + S3) Still in kcTyClGroup, we use generaliseTyClDecl to generalize + each MonoTcTyCon to get a PolyTcTyCon, with skolem TcTyVars in it, and a final, fixed kind. - S5) Finally, back in TcTyClDecls, we extend the environment with + S4) Finally, back in TcTyClDecls, we extend the environment with the PolyTcTyCons, and typecheck each declaration (regardless of kind signatures etc) to get final TyCon. - These TcTyCons are stored in the local environment in GHC.Tc.TyCl, - until the real full TyCons can be created during desugaring. A - desugared program should never have a TcTyCon. + More details about /kind checking/ -3. A MonoTcTyCon can contain unification variables, but a PolyTcTyCon - does not: only skolem TcTyVars. + S5) In kcTyClGroup, we use checkInitialKinds to get the + utterly-final Kind of all TyCons in the group that + (a) have a separate kind signature or + (b) have a CUSK. + This produces a PolyTcTyCon, that is, a TcTyCon in which the binders + and result kind are full of TyVars (not TcTyVars). No unification + variables here; everything is in its final form. -4. tyConScopedTyVars. A challenging piece in all of this is that we +3. tyConScopedTyVars. A challenging piece in all of this is that we end up taking three separate passes over every declaration: - one in inferInitialKind (this pass look only at the head, not the body) - one in kcTyClDecls (to kind-check the body) @@ -2425,15 +2434,15 @@ tcClassDecl1 :: RolesInfo -> Name -> Maybe (LHsContext GhcRn) -> TcM Class tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs = fixM $ \ clas -> -- We need the knot because 'clas' is passed into tcClassATs - bindTyClTyVars class_name $ \ binders res_kind -> + bindTyClTyVars class_name $ \ tc_bndrs res_kind -> do { checkClassKindSig res_kind - ; traceTc "tcClassDecl 1" (ppr class_name $$ ppr binders) + ; traceTc "tcClassDecl 1" (ppr class_name $$ ppr tc_bndrs) ; let tycon_name = class_name -- We use the same name roles = roles_info tycon_name -- for TyCon and Class ; (ctxt, fds, sig_stuff, at_stuff) - <- pushLevelAndSolveEqualities skol_info binders $ - -- The (binderVars binders) is needed bring into scope the + <- pushLevelAndSolveEqualities skol_info tc_bndrs $ + -- The (binderVars tc_bndrs) is needed bring into scope the -- skolems bound by the class decl header (#17841) do { ctxt <- tcHsContext hs_ctxt ; fds <- mapM (addLocMA tc_fundep) fundeps @@ -2458,9 +2467,10 @@ tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs -- any unfilled coercion variables unless there is such an error -- The zonk also squeeze out the TcTyCons, and converts -- Skolems to tyvars. - ; ze <- mkEmptyZonkEnv NoFlexi - ; ctxt <- zonkTcTypesToTypesX ze ctxt - ; sig_stuff <- mapM (zonkTcMethInfoToMethInfoX ze) sig_stuff + ; ze <- mkEmptyZonkEnv NoFlexi + ; (ze, bndrs) <- zonkTyVarBindersX ze tc_bndrs -- From TcTyVars to TyVars + ; ctxt <- zonkTcTypesToTypesX ze ctxt + ; sig_stuff <- mapM (zonkTcMethInfoToMethInfoX ze) sig_stuff -- ToDo: do we need to zonk at_stuff? -- TODO: Allow us to distinguish between abstract class, @@ -2482,8 +2492,8 @@ tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs | otherwise = Just (ctxt, at_stuff, sig_stuff, mindef) - ; clas <- buildClass class_name binders roles fds body - ; traceTc "tcClassDecl" (ppr fundeps $$ ppr binders $$ + ; clas <- buildClass class_name bndrs roles fds body + ; traceTc "tcClassDecl" (ppr fundeps $$ ppr bndrs $$ ppr fds) ; return clas } where @@ -2712,7 +2722,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info , fdResultSig = L _ sig , fdInjectivityAnn = inj }) | DataFamily <- fam_info - = bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> do + = bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> do { traceTc "tcFamDecl1 data family:" (ppr tc_name) ; checkFamFlag tc_name @@ -2729,8 +2739,8 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info -- See also Note [Datatype return kinds] ; checkDataKindSig DataFamilySort res_kind ; tc_rep_name <- newTyConRepName tc_name - ; let inj = Injective $ replicate (length binders) True - tycon = mkFamilyTyCon tc_name binders + ; let inj = Injective $ replicate (length tc_bndrs) True + tycon = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) (DataFamilyTyCon tc_rep_name) @@ -2738,12 +2748,12 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info ; return tycon } | OpenTypeFamily <- fam_info - = bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> do + = bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> do { traceTc "tcFamDecl1 open type family:" (ppr tc_name) ; checkFamFlag tc_name - ; inj' <- tcInjectivity binders inj + ; inj' <- tcInjectivity tc_bndrs inj ; checkResultSigFlag tc_name sig -- check after injectivity for better errors - ; let tycon = mkFamilyTyCon tc_name binders res_kind + ; let tycon = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) OpenSynFamilyTyCon parent inj' ; return tycon } @@ -2754,10 +2764,10 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info do { traceTc "tcFamDecl1 Closed type family:" (ppr tc_name) -- the variables in the header scope only over the injectivity -- declaration but this is not involved here - ; (inj', binders, res_kind) - <- bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> - do { inj' <- tcInjectivity binders inj - ; return (inj', binders, res_kind) } + ; (inj', tc_bndrs, res_kind) + <- bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> + do { inj' <- tcInjectivity tc_bndrs inj + ; return (inj', tc_bndrs, res_kind) } ; checkFamFlag tc_name -- make sure we have -XTypeFamilies ; checkResultSigFlag tc_name sig @@ -2766,14 +2776,14 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info -- but eqns might be empty in the Just case as well ; case mb_eqns of Nothing -> - return $ mkFamilyTyCon tc_name binders res_kind + return $ mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) AbstractClosedSynFamilyTyCon parent inj' Just eqns -> do { -- Process the equations, creating CoAxBranches - ; let tc_fam_tc = mkTcTyCon tc_name binders res_kind + ; let tc_fam_tc = mkTcTyCon tc_name tc_bndrs res_kind noTcTyConScopedTyVars False {- this doesn't matter here -} ClosedTypeFamilyFlavour @@ -2792,7 +2802,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info | null eqns = Nothing -- mkBranchedCoAxiom fails on empty list | otherwise = Just (mkBranchedCoAxiom co_ax_name fam_tc branches) - fam_tc = mkFamilyTyCon tc_name binders res_kind (resultVariableName sig) + fam_tc = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) (ClosedSynFamilyTyCon mb_co_ax) parent inj' -- We check for instance validity later, when doing validity @@ -2853,10 +2863,10 @@ tcInjectivity tcbs (Just (L loc (InjectivityAnn _ _ lInjNames))) tcTySynRhs :: RolesInfo -> Name -> LHsType GhcRn -> TcM TyCon tcTySynRhs roles_info tc_name hs_ty - = bindTyClTyVars tc_name $ \ binders res_kind -> + = bindTyClTyVars tc_name $ \ tc_bndrs res_kind -> do { env <- getLclEnv ; traceTc "tc-syn" (ppr tc_name $$ ppr (tcl_env env)) - ; rhs_ty <- pushLevelAndSolveEqualities skol_info binders $ + ; rhs_ty <- pushLevelAndSolveEqualities skol_info tc_bndrs $ tcCheckLHsType hs_ty (TheKind res_kind) -- See Note [Error on unconstrained meta-variables] in GHC.Tc.Utils.TcMType @@ -2870,11 +2880,11 @@ tcTySynRhs roles_info tc_name hs_ty , ppr rhs_ty ] ) } ; doNotQuantifyTyVars dvs mk_doc - ; ze <- mkEmptyZonkEnv NoFlexi - ; (ze, binders) <- zonkTyVarBindersX ze binders - ; rhs_ty <- zonkTcTypeToTypeX ze rhs_ty + ; ze <- mkEmptyZonkEnv NoFlexi + ; (ze, bndrs) <- zonkTyVarBindersX ze tc_bndrs + ; rhs_ty <- zonkTcTypeToTypeX ze rhs_ty ; let roles = roles_info tc_name - ; return (buildSynTyCon tc_name binders res_kind roles rhs_ty) } + ; return (buildSynTyCon tc_name bndrs res_kind roles rhs_ty) } where skol_info = TyConSkol TypeSynonymFlavour tc_name ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -1735,12 +1735,6 @@ quantifyTyVars skol_info ns_strat dvs = return Nothing -- this can happen for a covar that's associated with -- a coercion hole. Test case: typecheck/should_compile/T2494 --- Omit: no TyVars now --- | not (isTcTyVar tkv) --- = return (Just tkv) -- For associated types in a class with a standalone --- -- kind signature, we have the class variables in --- -- scope, and they are TyVars not TcTyVars - | otherwise = Just <$> skolemiseQuantifiedTyVar skol_info tkv @@ -1785,13 +1779,19 @@ skolemiseQuantifiedTyVar :: SkolemInfo -> TcTyVar -> TcM TcTyVar skolemiseQuantifiedTyVar skol_info tv = case tcTyVarDetails tv of - SkolemTv {} -> do { kind <- zonkTcType (tyVarKind tv) - ; return (setTyVarKind tv kind) } - -- It might be a skolem type variable, - -- for example from a user type signature - MetaTv {} -> skolemiseUnboundMetaTyVar skol_info tv + SkolemTv _ lvl _ -- It might be a skolem type variable, + -- for example from a user type signature + -- But it might also be a shared meta-variable across several + -- type declarations, each with its own skol_info. The first + -- will skolemise it, but the other uses must update its + -- skolem info (#22379) + -> do { kind <- zonkTcType (tyVarKind tv) + ; let details = SkolemTv skol_info lvl False + name = tyVarName tv + ; return (mkTcTyVar name kind details) } + _other -> pprPanic "skolemiseQuantifiedTyVar" (ppr tv) -- RuntimeUnk -- | Default a type variable using the given defaulting strategy. ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -428,7 +428,7 @@ Invariants: - Flag tcTyConIsPoly = True; this is used only to short-cut zonking - tyConBinders are still TcTyConBinders, but they are /skolem/ TcTyVars, - with fixed kinds: no unification variables here + with fixed kinds, and accurate skolem info: no unification variables here tyConBinders includes the Inferred binders if any ===================================== testsuite/tests/deriving/should_fail/T21871.stderr ===================================== @@ -3,7 +3,7 @@ T21871.hs:13:36: error: [GHC-25897] • Couldn't match kind ‘k’ with ‘*’ Expected kind ‘* -> *’, but ‘m’ has kind ‘k -> *’ ‘k’ is a rigid type variable bound by - the newtype declaration for ‘FooT’ + a `deriving' clause at T21871.hs:(10,1)-(13,36) • In the second argument of ‘ReaderT’, namely ‘m’ In the newtype declaration for ‘FooT’ ===================================== testsuite/tests/indexed-types/should_fail/T15870.stderr ===================================== @@ -3,7 +3,7 @@ T15870.hs:32:34: error: [GHC-25897] • Couldn't match kind ‘k’ with ‘*’ Expected kind ‘Optic @{k} a’, but ‘g2’ has kind ‘Optic @{*} b’ ‘k’ is a rigid type variable bound by - the instance declaration + a family instance declaration at T15870.hs:(27,1)-(32,35) • In the second argument of ‘Get’, namely ‘g2’ In the type ‘Get a g2’ ===================================== testsuite/tests/polykinds/T22379a.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind +import Data.Proxy (Proxy) + +data Delayed (env :: Type) (c :: Type) +data Handler (a :: Type) +data Router (a :: Type) + +-- class decl, then type decl + +class HasServer api where + type ServerT api (m :: Type -> Type) :: Type + + route :: + Proxy api + -> Delayed env (Server api) + -> Router env + + hoistServerWithContext + :: Proxy api + -> (forall x. m x -> n x) + -> ServerT api m + -> ServerT api n + +type Server aqi = ServerT aqi Handler + ===================================== testsuite/tests/polykinds/T22379b.hs ===================================== @@ -0,0 +1,30 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind +import Data.Proxy (Proxy) + +data Delayed (env :: Type) (c :: Type) +data Handler (a :: Type) +data Router (a :: Type) + +-- type decl, then class decl + +type Server aqi = ServerT aqi Handler + +class HasServer api where + type ServerT api (m :: Type -> Type) :: Type + + route :: + Proxy api + -> Delayed env (Server api) + -> Router env + + hoistServerWithContext + :: Proxy api + -> (forall x. m x -> n x) + -> ServerT api m + -> ServerT api n ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -239,3 +239,5 @@ test('T19739a', normal, compile, ['']) test('T19739b', normal, compile, ['']) test('T19739c', normal, compile, ['']) test('T19739d', normal, compile, ['']) +test('T22379a', normal, compile, ['']) +test('T22379b', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1944cf8015a28a16bb683be9a2327b8eaad77297 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1944cf8015a28a16bb683be9a2327b8eaad77297 You're receiving 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 Nov 1 12:31:31 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 01 Nov 2022 08:31:31 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Disable SplcieTypes test Message-ID: <636111a39b4d7_815bc51554281426@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 74f184eb by Sylvain Henry at 2022-11-01T13:35:03+01:00 Disable SplcieTypes test - - - - - 1 changed file: - testsuite/tests/hiefile/should_run/all.T Changes: ===================================== testsuite/tests/hiefile/should_run/all.T ===================================== @@ -2,4 +2,4 @@ test('PatTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestU test('HieQueries', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('T20341', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) test('RecordDotTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) -test('SpliceTypes', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) +test('SpliceTypes', [req_th, extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74f184ebc16c2bace9baeb5e3d8a4f90150ffec3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74f184ebc16c2bace9baeb5e3d8a4f90150ffec3 You're receiving 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 Nov 1 12:31:49 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 01 Nov 2022 08:31:49 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/driver-fix-defer Message-ID: <636111b5d694c_815bc515902816d2@gitlab.mail> Matthew Pickering pushed new branch wip/driver-fix-defer at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/driver-fix-defer You're receiving 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 Nov 1 13:52:34 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 01 Nov 2022 09:52:34 -0400 Subject: [Git][ghc/ghc][wip/driver-fix-defer] driver: Fix -fdefer-diagnostics flag Message-ID: <636124a2902d8_815bc514c8289957@gitlab.mail> Matthew Pickering pushed to branch wip/driver-fix-defer at Glasgow Haskell Compiler / GHC Commits: 9de1dc50 by Matthew Pickering at 2022-11-01T13:52:24+00:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - 9 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/t22391/Makefile - + testsuite/tests/driver/t22391/all.T - + testsuite/tests/driver/t22391/src/Lib.hs - + testsuite/tests/driver/t22391/src/Lib/A.hs - + testsuite/tests/driver/t22391/src/Lib/B.hs - + testsuite/tests/driver/t22391/t22391.stderr - + testsuite/tests/driver/t22391/t22391j.stderr - testsuite/tests/ghci/prog018/prog018.stdout Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -741,8 +741,8 @@ load' mhmi_cache how_much mHscMessage mod_graph = do Just n -> return n setSession $ hscUpdateHUG (unitEnv_map pruneHomeUnitEnv) hsc_env - hsc_env <- getSession - (upsweep_ok, hsc_env1) <- withDeferredDiagnostics $ + (upsweep_ok, hsc_env1) <- withDeferredDiagnostics $ do + hsc_env <- getSession liftIO $ upsweep n_jobs hsc_env mhmi_cache mHscMessage (toCache pruned_cache) build_plan setSession hsc_env1 case upsweep_ok of ===================================== testsuite/tests/driver/t22391/Makefile ===================================== @@ -0,0 +1,19 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +warnings-ghc-deferred: clean + "$GHC" --make -Wall -fdefer-diagnostics src/Lib.hs src/Lib/A.hs src/Lib/B.hs" + ghc --version + +warnings-ghc-regular: clean + bash -c "ghc --make -Wall src/Lib.hs src/Lib/A.hs src/Lib/B.hs" + ghc --version + +.PHONY: warnings-ghc + +clean: + rm -rf src/**/*.{hi,o} + rm -rf **/*.{hi,o} + +.PHONY: clean ===================================== testsuite/tests/driver/t22391/all.T ===================================== @@ -0,0 +1,5 @@ +test('t22391', [extra_files(['src'])], + multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics']) + +test('t22391j', [extra_files(['src'])], + multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics -j2']) ===================================== testsuite/tests/driver/t22391/src/Lib.hs ===================================== @@ -0,0 +1,11 @@ +module Lib + ( someFunc + ) where + +import Lib.A +import Lib.B + +blah = 3 + +someFunc :: IO () +someFunc = putStrLn "someFunc" ===================================== testsuite/tests/driver/t22391/src/Lib/A.hs ===================================== @@ -0,0 +1,3 @@ +module Lib.A where + +blast = 1 ===================================== testsuite/tests/driver/t22391/src/Lib/B.hs ===================================== @@ -0,0 +1,3 @@ +module Lib.B where + +warnmeup = 4 ===================================== testsuite/tests/driver/t22391/t22391.stderr ===================================== @@ -0,0 +1,43 @@ +[1 of 3] Compiling Lib.A +[2 of 3] Compiling Lib.B +[3 of 3] Compiling Lib + +src/Lib/A.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blast :: Integer + +src/Lib/A.hs:3:9: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘1’ + • In the expression: 1 + In an equation for ‘blast’: blast = 1 + +src/Lib/B.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: warnmeup :: Integer + +src/Lib/B.hs:3:12: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘4’ + • In the expression: 4 + In an equation for ‘warnmeup’: warnmeup = 4 + +src/Lib.hs:5:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.A’ is redundant + except perhaps to import instances from ‘Lib.A’ + To import instances alone, use: import Lib.A() + +src/Lib.hs:6:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.B’ is redundant + except perhaps to import instances from ‘Lib.B’ + To import instances alone, use: import Lib.B() + +src/Lib.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blah :: Integer + +src/Lib.hs:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: ‘blah’ + +src/Lib.hs:8:8: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘3’ + • In the expression: 3 + In an equation for ‘blah’: blah = 3 ===================================== testsuite/tests/driver/t22391/t22391j.stderr ===================================== @@ -0,0 +1,43 @@ +[1 of 3] Compiling Lib.A +[2 of 3] Compiling Lib.B +[3 of 3] Compiling Lib + +src/Lib/A.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blast :: Integer + +src/Lib/A.hs:3:9: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘1’ + • In the expression: 1 + In an equation for ‘blast’: blast = 1 + +src/Lib/B.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: warnmeup :: Integer + +src/Lib/B.hs:3:12: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘4’ + • In the expression: 4 + In an equation for ‘warnmeup’: warnmeup = 4 + +src/Lib.hs:5:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.A’ is redundant + except perhaps to import instances from ‘Lib.A’ + To import instances alone, use: import Lib.A() + +src/Lib.hs:6:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.B’ is redundant + except perhaps to import instances from ‘Lib.B’ + To import instances alone, use: import Lib.B() + +src/Lib.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blah :: Integer + +src/Lib.hs:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: ‘blah’ + +src/Lib.hs:8:8: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘3’ + • In the expression: 3 + In an equation for ‘blah’: blah = 3 ===================================== testsuite/tests/ghci/prog018/prog018.stdout ===================================== @@ -1,4 +1,6 @@ [1 of 3] Compiling A ( A.hs, interpreted ) +[2 of 3] Compiling B ( B.hs, interpreted ) +[3 of 3] Compiling C ( C.hs, interpreted ) A.hs:5:1: warning: [GHC-62161] [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive @@ -7,19 +9,14 @@ A.hs:5:1: warning: [GHC-62161] [-Wincomplete-patterns (in -Wextra)] A.hs:8:15: warning: [-Wunused-matches (in -Wextra)] Defined but not used: ‘x’ -[2 of 3] Compiling B ( B.hs, interpreted ) B.hs:7:1: warning: [-Wunused-imports (in -Wextra)] The import of ‘Data.Tuple’ is redundant except perhaps to import instances from ‘Data.Tuple’ To import instances alone, use: import Data.Tuple() -[3 of 3] Compiling C ( C.hs, interpreted ) C.hs:6:7: error: [GHC-88464] Variable not in scope: variableNotInScope :: () Failed, two modules loaded. [3 of 3] Compiling C ( C.hs, interpreted ) - -C.hs:6:7: error: [GHC-88464] - Variable not in scope: variableNotInScope :: () Failed, two modules loaded. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9de1dc501777374236f9e47d6a879dfd988ab7dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9de1dc501777374236f9e47d6a879dfd988ab7dc You're receiving 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 Nov 1 14:37:22 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 01 Nov 2022 10:37:22 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 11 commits: Start the deprecation process for GHC.Pack Message-ID: <63612f221d262_815bc515a4304093@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - 9cec68d1 by M Farkas-Dyck at 2022-11-01T10:37:01-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 5235def9 by Nicolas Trangez at 2022-11-01T10:37:02-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 2589e69e by Nicolas Trangez at 2022-11-01T10:37:02-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - 2220718e by Nicolas Trangez at 2022-11-01T10:37:02-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b5d17d3c by Krzysztof Gogolewski at 2022-11-01T10:37:03-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - c5f96f15 by Vladislav Zavialov at 2022-11-01T10:37:03-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - bd4031b2 by Simon Peyton Jones at 2022-11-01T10:37:04-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 8a675f48 by Fendor at 2022-11-01T10:37:08-04:00 Expose UnitEnvGraphKey for user-code - - - - - 1070bf07 by Simon Peyton Jones at 2022-11-01T10:37:08-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 963c17b7 by Simon Peyton Jones at 2022-11-01T10:37:08-04:00 Add two tests for #17366 - - - - - 30 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Env.hs - compiler/GHC/Unit/Module/WholeCoreBindings.hs - docs/users_guide/phases.rst - libraries/base/GHC/Pack.hs - rts/include/rts/OSThreads.h - rts/posix/OSThreads.c - rts/posix/ticker/Pthread.c - rts/win32/OSThreads.c - testsuite/tests/deriving/should_fail/T21871.stderr - testsuite/tests/driver/fat-iface/Makefile - testsuite/tests/indexed-types/should_fail/T15870.stderr - + testsuite/tests/polykinds/T22379a.hs - + testsuite/tests/polykinds/T22379b.hs - testsuite/tests/polykinds/all.T - + testsuite/tests/simplCore/should_compile/T17366.hs - + testsuite/tests/simplCore/should_compile/T17366.stderr - + testsuite/tests/simplCore/should_compile/T17366_AR.hs - + testsuite/tests/simplCore/should_compile/T17366_AR.stderr - + testsuite/tests/simplCore/should_compile/T17366_ARa.hs - + testsuite/tests/simplCore/should_compile/T17366a.hs - testsuite/tests/simplCore/should_compile/T22357.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/454b824409fefc8ccaeb05d52d2bc97d52ae94ca...963c17b77bd89c026e937405582e6b669f2ec414 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/454b824409fefc8ccaeb05d52d2bc97d52ae94ca...963c17b77bd89c026e937405582e6b669f2ec414 You're receiving 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 Nov 1 14:44:01 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 01 Nov 2022 10:44:01 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <636130b15ad1d_815bc514dc318359@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: f44242de by Andreas Klebinger at 2022-11-01T15:41:30+01:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 17 changed files: - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - testsuite/driver/testlib.py - + testsuite/tests/unboxedsums/GenManyUbxSums.hs - + testsuite/tests/unboxedsums/ManyUbxSums.stdout - + testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs - + testsuite/tests/unboxedsums/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,213 @@ +{- +This module contains helpers to cast variables +between different Int/WordReps in StgLand. + +-} + +module GHC.Builtin.PrimOps.Casts + ( getCasts ) +where + +import GHC.Prelude + +import GHC.Core.TyCon +import GHC.Utils.Outputable +import GHC.Utils.Panic +import GHC.Utils.Panic.Plain +import GHC.Types.RepType +import GHC.Core.Type +import GHC.Builtin.Types.Prim +import GHC.Builtin.Types + +import GHC.Builtin.PrimOps +import GHC.Plugins (HasDebugCallStack) + +{- Note [PrimRep based casting] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This module contains a number of utility functions useful when +converting between variables of differing PrimReps. + +The general pattern is: +* We have two primReps `from_rep` and `to_rep`. +* We want a list of PrimOps we can apply to a variable of rep `from_rep`. +Applying the list of primOps in order takes us to `to_rep` from `from_rep` giving +us a variable of the returned type at each step. + +E.g. we call `getCasts from_rep to_rep` and get back [(op1#,ty1),(op2#,ty2)]. +We can use this list of primOps to construct a function of type +`StgExpr -> StgExpr` by construction an expression + + case op1# of (x' :: ty1) -> case op2# x' of x' -> + +Ideally backends will compile the sequence of PrimOps to a no-op. E.g. by reusing +the same register but just relabeling it as another width. +However this is might not always be possible or the required optimizations +simply not implemented in the backend. This means currently many of these casts +will be cheap but not all of them will be completely zero-cost. + +-} + +-- | `getCasts from_rep to_rep` gives us a list of primops which when applied in order convert from_rep to to_rep. +-- See Note [PrimRep based casting] +getCasts :: PrimRep -> PrimRep -> [(PrimOp,Type)] +getCasts from_rep to_rep + -- No-op + | -- pprTrace "getCasts" (ppr (from_rep,to_rep)) $ + to_rep == from_rep + = [] + + -- Float <-> Double + | to_rep == FloatRep = + assertPpr (from_rep == DoubleRep) (ppr from_rep <+> ppr to_rep) $ + [(DoubleToFloatOp,floatPrimTy)] + | to_rep == DoubleRep = + assertPpr (from_rep == FloatRep) (ppr from_rep <+> ppr to_rep) $ + [(FloatToDoubleOp,doublePrimTy)] + + -- Addr <-> Word/Int + | to_rep == AddrRep = wordOrIntToAddrRep from_rep + | from_rep == AddrRep = addrToWordOrIntRep to_rep + + -- Int* -> Int* + | primRepIsInt from_rep + , primRepIsInt to_rep + = sizedIntToSizedInt from_rep to_rep + + -- Word* -> Word* + | primRepIsWord from_rep + , primRepIsWord to_rep + = sizedWordToSizedWord from_rep to_rep + + -- Word* -> Int* + | primRepIsWord from_rep + , primRepIsInt to_rep + = let (op1,r1) = wordToIntRep from_rep + in (op1,primRepToType r1):sizedIntToSizedInt r1 to_rep + + -- Int* -> Word* + | primRepIsInt from_rep + , primRepIsWord to_rep + = let (op1,r1) = intToWordRep from_rep + in (op1,primRepToType r1):sizedWordToSizedWord r1 to_rep + + | otherwise = pprPanic "getCasts:Unexpect rep combination" + (ppr (from_rep,to_rep)) + +wordOrIntToAddrRep :: HasDebugCallStack => PrimRep -> [(PrimOp,Type)] +wordOrIntToAddrRep AddrRep = [] -- No-op argument is already AddrRep +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r1) = wordToIntRep r + in (op1, primRepToType r1):[(intToMachineInt r1,intPrimTy), (IntToAddrOp,addrPrimTy)] + | otherwise = pprPanic "Rep not word or int rep" (ppr r) + +addrToWordOrIntRep :: HasDebugCallStack => PrimRep -> [(PrimOp,Type)] +-- Machine sizes +addrToWordOrIntRep IntRep = [(AddrToIntOp, intPrimTy)] +addrToWordOrIntRep WordRep = [(AddrToIntOp,intPrimTy), (IntToWordOp,wordPrimTy)] +-- Explicitly sized reps +addrToWordOrIntRep r + | primRepIsWord r = (AddrToIntOp,intPrimTy) : (IntToWordOp,wordPrimTy) : sizedWordToSizedWord WordRep r + | primRepIsInt r = (AddrToIntOp,intPrimTy) : sizedIntToSizedInt IntRep r + | otherwise = pprPanic "Target rep not word or int rep" (ppr r) + + +-- WordX# -> IntX# (same size), argument is source rep +wordToIntRep :: HasDebugCallStack => PrimRep -> (PrimOp,PrimRep) +wordToIntRep rep + = case rep of + (WordRep) -> (WordToIntOp, IntRep) + (Word8Rep) -> (Word8ToInt8Op, Int8Rep) + (Word16Rep) -> (Word16ToInt16Op, Int16Rep) + (Word32Rep) -> (Word32ToInt32Op, Int32Rep) + (Word64Rep) -> (Word64ToInt64Op, Int64Rep) + _ -> pprPanic "Rep not a wordRep" (ppr rep) + +-- IntX# -> WordX#, argument is source rep +intToWordRep :: HasDebugCallStack => PrimRep -> (PrimOp,PrimRep) +intToWordRep rep + = case rep of + (IntRep) -> (IntToWordOp, WordRep) + (Int8Rep) -> (Int8ToWord8Op, Word8Rep) + (Int16Rep) -> (Int16ToWord16Op, Word16Rep) + (Int32Rep) -> (Int32ToWord32Op, Word32Rep) + (Int64Rep) -> (Int64ToWord64Op, Word64Rep) + _ -> pprPanic "Rep not a wordRep" (ppr rep) + +-- Casts between any size int to any other size of int +sizedIntToSizedInt :: HasDebugCallStack => PrimRep -> PrimRep -> [(PrimOp,Type)] +sizedIntToSizedInt r1 r2 + | r1 == r2 = [] +-- Cast to Int# +sizedIntToSizedInt r IntRep = [(intToMachineInt r,intTy)] +-- Cast from Int# +sizedIntToSizedInt IntRep r = [(intFromMachineInt r,primRepToType r)] +-- Sized to differently sized must go over machine word. +sizedIntToSizedInt r1 r2 = (intToMachineInt r1,intTy) : [(intFromMachineInt r2,primRepToType r2)] + +-- Casts between any size Word to any other size of Word +sizedWordToSizedWord :: HasDebugCallStack => PrimRep -> PrimRep -> [(PrimOp,Type)] +sizedWordToSizedWord r1 r2 + | r1 == r2 = [] +-- Cast to Word# +sizedWordToSizedWord r WordRep = [(wordToMachineWord r,wordPrimTy)] +-- Cast from Word# +sizedWordToSizedWord WordRep r = [(wordFromMachineWord r, primRepToType r)] +-- Conversion between different non-machine sizes must go via machine word. +sizedWordToSizedWord r1 r2 = (wordToMachineWord r1,wordPrimTy) : [(wordFromMachineWord r2, primRepToType r2)] + + +-- Prefer the definitions above this line if possible +---------------------- + + +-- Int*# to Int# +{-# INLINE intToMachineInt #-} +intToMachineInt :: HasDebugCallStack => PrimRep -> PrimOp +intToMachineInt r = + assertPpr (primRepIsInt r) (ppr r) $ + case r of + (Int8Rep) -> Int8ToIntOp + (Int16Rep) -> Int16ToIntOp + (Int32Rep) -> Int32ToIntOp + (Int64Rep) -> Int64ToIntOp + _ -> pprPanic "Source rep not int" $ ppr r + +-- Int# to Int*# +{-# INLINE intFromMachineInt #-} +intFromMachineInt :: HasDebugCallStack => PrimRep -> PrimOp +intFromMachineInt r = + assertPpr (primRepIsInt r) (ppr r) $ + case r of + Int8Rep -> IntToInt8Op + Int16Rep -> IntToInt16Op + Int32Rep -> IntToInt32Op + Int64Rep -> IntToInt64Op + _ -> pprPanic "Dest rep not sized int" $ ppr r + +-- Word# to Word*# +{-# INLINE wordFromMachineWord #-} +wordFromMachineWord :: HasDebugCallStack => PrimRep -> PrimOp +wordFromMachineWord r = + assert (primRepIsWord r) $ + case r of + Word8Rep -> WordToWord8Op + Word16Rep -> WordToWord16Op + Word32Rep -> WordToWord32Op + Word64Rep -> WordToWord64Op + _ -> pprPanic "Dest rep not sized word" $ ppr r + +-- Word*# to Word# +{-# INLINE wordToMachineWord #-} +wordToMachineWord :: HasDebugCallStack => PrimRep -> PrimOp +wordToMachineWord r = + assertPpr (primRepIsWord r) (text "Not a word rep:" <> ppr r) $ + case r of + Word8Rep -> Word8ToWordOp + Word16Rep -> Word16ToWordOp + Word32Rep -> Word32ToWordOp + Word64Rep -> Word64ToWordOp + _ -> pprPanic "Dest rep not sized word" $ ppr r \ No newline at end of file ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -1399,7 +1399,10 @@ instance OutputableP Platform CLabel where pdoc !platform lbl = getPprStyle $ \pp_sty -> case pp_sty of PprDump{} -> pprCLabel platform CStyle lbl - _ -> pprPanic "Labels in code should be printed with pprCLabel" (pprCLabel platform CStyle lbl) + -- Workaround for #22218 + _ -> (pprCLabel platform CStyle lbl) + -- _ -> pprPanic "Labels in code should be printed with pprCLabel" (pprCLabel platform CStyle lbl) + pprCLabel :: Platform -> LabelStyle -> CLabel -> SDoc pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel] ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -129,6 +129,7 @@ module GHC.Core.TyCon( primRepIsFloat, primRepsCompatible, primRepCompatible, + primRepIsWord, primRepIsInt, ) where @@ -1785,6 +1786,24 @@ primRepIsFloat DoubleRep = Just True primRepIsFloat (VecRep _ _) = Nothing primRepIsFloat _ = Just False +-- Rep is one of the word reps. +primRepIsWord :: PrimRep -> Bool +primRepIsWord WordRep = True +primRepIsWord (Word8Rep) = True +primRepIsWord (Word16Rep) = True +primRepIsWord (Word32Rep) = True +primRepIsWord (Word64Rep) = True +primRepIsWord _ = False + +-- Rep is one of the int reps. +primRepIsInt :: PrimRep -> Bool +primRepIsInt (IntRep) = True +primRepIsInt (Int8Rep) = True +primRepIsInt (Int16Rep) = True +primRepIsInt (Int32Rep) = True +primRepIsInt (Int64Rep) = True +primRepIsInt _ = False + {- ************************************************************************ * * ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -422,6 +422,7 @@ data GeneralFlag -- variables that have otherwise identical names. | Opt_SuppressUniques | Opt_SuppressStgExts + | Opt_SuppressStgReps | Opt_SuppressTicks -- Replaces Opt_PprShowTicks | Opt_SuppressTimestamps -- ^ Suppress timestamps in dumps | Opt_SuppressCoreSizes -- ^ Suppress per binding Core size stats in dumps ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2393,6 +2393,7 @@ dynamic_flags_deps = [ setGeneralFlag Opt_SuppressIdInfo setGeneralFlag Opt_SuppressTicks setGeneralFlag Opt_SuppressStgExts + setGeneralFlag Opt_SuppressStgReps setGeneralFlag Opt_SuppressTypeSignatures setGeneralFlag Opt_SuppressCoreSizes setGeneralFlag Opt_SuppressTimestamps) @@ -3344,6 +3345,7 @@ dFlagsDeps = [ depFlagSpec' "suppress-stg-free-vars" Opt_SuppressStgExts (useInstead "-d" "suppress-stg-exts"), flagSpec "suppress-stg-exts" Opt_SuppressStgExts, + flagSpec "suppress-stg-reps" Opt_SuppressStgReps, flagSpec "suppress-coercions" Opt_SuppressCoercions, flagSpec "suppress-coercion-types" Opt_SuppressCoercionTypes, flagSpec "suppress-idinfo" Opt_SuppressIdInfo, @@ -3796,7 +3798,8 @@ defaultFlags settings Opt_VersionMacros, Opt_RPath, Opt_DumpWithWays, - Opt_CompactUnwind + Opt_CompactUnwind, + Opt_SuppressStgReps ] ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns] @@ -5020,6 +5023,7 @@ initSDocContext dflags style = SDC , sdocSuppressUniques = gopt Opt_SuppressUniques dflags , sdocSuppressModulePrefixes = gopt Opt_SuppressModulePrefixes dflags , sdocSuppressStgExts = gopt Opt_SuppressStgExts dflags + , sdocSuppressStgReps = gopt Opt_SuppressStgReps dflags , sdocErrorSpans = gopt Opt_ErrorSpans dflags , sdocStarIsType = xopt LangExt.StarIsType dflags , sdocLinearTypes = xopt LangExt.LinearTypes dflags ===================================== compiler/GHC/Stg/Syntax.hs ===================================== @@ -87,7 +87,7 @@ import GHC.Core.Ppr( {- instances -} ) import GHC.Builtin.PrimOps ( PrimOp, PrimCall ) import GHC.Core.TyCon ( PrimRep(..), TyCon ) import GHC.Core.Type ( Type ) -import GHC.Types.RepType ( typePrimRep1 ) +import GHC.Types.RepType ( typePrimRep1, typePrimRep ) import GHC.Utils.Panic.Plain {- @@ -740,12 +740,23 @@ pprStgTopBinding = pprGenStgTopBinding pprStgTopBindings :: OutputablePass pass => StgPprOpts -> [GenStgTopBinding pass] -> SDoc pprStgTopBindings = pprGenStgTopBindings +pprIdWithRep :: Id -> SDoc +pprIdWithRep v = ppr v <> pprTypeRep (idType v) + +pprTypeRep :: Type -> SDoc +pprTypeRep ty = + ppUnlessOption sdocSuppressStgReps $ + char ':' <> case typePrimRep ty of + [r] -> ppr r + r -> ppr r + + instance Outputable StgArg where ppr = pprStgArg pprStgArg :: StgArg -> SDoc -pprStgArg (StgVarArg var) = ppr var -pprStgArg (StgLitArg con) = ppr con +pprStgArg (StgVarArg var) = pprIdWithRep var +pprStgArg (StgLitArg con) = ppr con <> pprTypeRep (literalType con) instance OutputablePass pass => Outputable (GenStgExpr pass) where ppr = pprStgExpr panicStgPprOpts ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -186,6 +186,132 @@ So we pass type arguments of the DataCon's TyCon in StgConApp to decide what layout to use. Note that unlifted values can't be let-bound, so we don't need types in StgRhsCon. +Note [Casting slot arguments] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this function which selects between Float# and Double# from a unboxed sum. + + foo :: (# Float# | Double# #) -> FD + foo x = case x of + (# x1 | #) -> F x1 + (# | x2 #) -> D x2 + +Naturally we would expect x1 to have a PrimRep of FloatRep and x2 of DoubleRep. +However we used to generate this (bogus) code after Unarise giving rise to #22208: + + M.foo :: (# GHC.Prim.Float# | GHC.Prim.Double# #) -> M.FD + [GblId, Arity=1, Unf=OtherCon []] = + {} \r [sum_tag sum_field] + case sum_tag of tag_gsc { + __DEFAULT -> M.F [sum_field]; + 2# -> M.D [sum_field]; + }; + +Where sum_field is used both as Float# and Double# depending on the branch +because they share the same SlotTy. +This usually works out since we put floats/doubles in the same sort of register. +However this caused issues down the road where we would assign between variables +of different reps causing lint errors or in the case of #22208 even compiler panics. +For now our solution is to construct proper casts between the PrimRep of the slot and +the variables we want to store in, or read out of these slots. + +This means when we have a sum (# Float# | Double# #) if we want to store a float +we convert it to a double on construction of the tuple value, and convert it back +to a float once when want to use the field. +Conversion for values coming out of a strict field happen in mapSumIdBinders. While +conversion during the construction of sums happen inside mkUbxSum. + +------------- A full example of casting during sum construction ---------------- + +To give a full example if we *construct* a unboxed sum of +type (# Int32# | Int64# ) in an expression like `let sum = (# | #) x` +Then we will call mkUbxSum to determine which arguments we have to pass in which +order to the unboxed tuple that represents the unboxed sum. + +Int32# and Int# in this case will share the same slot in the unboxed sum. This +means we want to upcast the argument in order to match up the reps of the +variables. To do this mkUbxSum will produce a casting expression with a hole for +the original rhs to go into. That is the call to mkUbxSum and it's result will +look something like: + + >>> mkUbxSum (#|#) [Int32#, Int#] (x::Int32#) us(x') + ([x'::Double#], case int32ToInt# x of x' -> <_hole_> ) + +We will use the returned arguments to construct an application to an unboxed tuple: + + (# #) 1# x' + +Which we will then use to construct an expression that casts `x` to the right type +and places it into x': + + >>> (\_hole_ -> case int32ToInt# x of x' -> _hole_) ((# #) 1# x') + case int32ToInt# x of x' -> (# #) 1# x' + +Which results in the this definition for `sum` after all is said and done: + + let sum = case int32ToInt# x of { x' -> (# #) 1# x' } + +You might wonder why we bother renaming `x` to `x'`. It's quite subtle. Consider +a definition like this: + + let sum_shadow :: (# (# Int32#, Int32# ) | Int64# #) + let sum_shadow = (# |#) (# x, x #) + +We compute the required slots for the tuple and come up with +`[WordSlot, Word64Slot]`. For the first sum constructor we will place `x` both +in a Word and a Word64Slot. If we would not rename the constructor what we would +get would be: + + let sum_shadow = case int32ToInt# x of + { x -> + (# #) 1# x x -- With the unboxed tuple having type (# #) :: (# Int#, Int#, Int64 #) + } + +Clearly this is somewhat bogus, we would end up using the same `x` as a +Int# and a Int64# value! + +------------- A full example of casting during sum matching -------------------- + +When matching on the same unboxed sum constructor as above we start out with +something like this the pre-unarise: + + f sum = case sum of + (# x |#) -> ... x ... -- (# x |#) :: (# Int32, Int#) + ... + +We start desugaring and get: + + f sum_tag sum_slot_arg_1 = case sum_tag of + 1# -> ??? + +Now we need to match the slot arguments to binders in the original case +alternative. This is done by mapSumIdBinders which we we call for our +example alternative like this: + + >>> mapSumIdBinders [x] [sum_slot_arg_1] alt_rhs env + (env', alt_rhs') + +mapSumIdBinders first matches up the list of binders with the slots passed to +the function which is trivial in this case. Then we check if the slot and the +variable residing inside it agree on their Rep. If all binders and slot reps +agree we just extend the environment with a mapping from `x` to `sum_slot_arg_1` +and we return the rhs as is. +If the reps do not agree then we wrap the whole RHS in a case which casts the +bound variable to a type of the correct representation. Here `x` is of Int32Rep +while `sum_slot_arg_1` will be of IntRep. This means instead of retuning the +original alt_rhs we will return: + + case intToInt32# (x :: Int#) of + (x :: Int32#) -> original_alt_rhs + +We then run unarise on this expression, which will replace the first occurence +of `x` with sum_slot_arg_1 giving us post-unarise: + + f sum_tag sum_slot_arg_1 = + case sum_tag of + 1# -> case intToInt32# sum_slot_arg_1 of + x -> ... x ... + ... + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +384,8 @@ import GHC.Prelude import GHC.Types.Basic import GHC.Core import GHC.Core.DataCon -import GHC.Core.TyCon ( isVoidRep ) -import GHC.Data.FastString (FastString, mkFastString) +import GHC.Core.TyCon +import GHC.Data.FastString (FastString, mkFastString, fsLit, appendFS) import GHC.Types.Id import GHC.Types.Literal import GHC.Core.Make (aBSENT_SUM_FIELD_ERROR_ID) @@ -281,7 +407,12 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name +import GHC.Utils.Trace -------------------------------------------------------------------------------- -- | A mapping from binders to the Ids they were expanded/renamed to. @@ -306,8 +437,10 @@ import qualified Data.IntMap as IM -- INVARIANT: OutStgArgs in the range only have NvUnaryTypes -- (i.e. no unboxed tuples, sums or voids) -- -type UnariseEnv = VarEnv UnariseVal +newtype UnariseEnv = UnariseEnv { ue_rho :: (VarEnv UnariseVal) } +initUnariseEnv :: VarEnv UnariseVal -> UnariseEnv +initUnariseEnv = UnariseEnv data UnariseVal = MultiVal [OutStgArg] -- MultiVal to tuple. Can be empty list (void). | UnaryVal OutStgArg -- See Note [Renaming during unarisation]. @@ -320,25 +453,27 @@ instance Outputable UnariseVal where -- The id is mapped to one or more things. -- See Note [UnariseEnv] extendRho :: UnariseEnv -> Id -> UnariseVal -> UnariseEnv -extendRho rho x (MultiVal args) +extendRho env x (MultiVal args) = assert (all (isNvUnaryType . stgArgType) args) - extendVarEnv rho x (MultiVal args) -extendRho rho x (UnaryVal val) + env { ue_rho = extendVarEnv (ue_rho env) x (MultiVal args) } +extendRho env x (UnaryVal val) = assert (isNvUnaryType (stgArgType val)) - extendVarEnv rho x (UnaryVal val) + env { ue_rho = extendVarEnv (ue_rho env) x (UnaryVal val) } -- Properly shadow things from an outer scope. -- See Note [UnariseEnv] -- The id stands for itself so we don't record a mapping. -- See Note [UnariseEnv] extendRhoWithoutValue :: UnariseEnv -> Id -> UnariseEnv -extendRhoWithoutValue rho x = delVarEnv rho x +extendRhoWithoutValue env x = env { ue_rho = delVarEnv (ue_rho env) x } +lookupRho :: UnariseEnv -> Id -> Maybe UnariseVal +lookupRho env v = lookupVarEnv (ue_rho env) v -------------------------------------------------------------------------------- unarise :: UniqSupply -> [StgTopBinding] -> [StgTopBinding] -unarise us binds = initUs_ us (mapM (unariseTopBinding emptyVarEnv) binds) +unarise us binds = initUs_ us (mapM (unariseTopBinding (initUnariseEnv emptyVarEnv)) binds) unariseTopBinding :: UnariseEnv -> StgTopBinding -> UniqSM StgTopBinding unariseTopBinding rho (StgTopLifted bind) @@ -366,7 +501,7 @@ unariseRhs rho (StgRhsCon ccs con mu ts args) unariseExpr :: UnariseEnv -> StgExpr -> UniqSM StgExpr unariseExpr rho e@(StgApp f []) - = case lookupVarEnv rho f of + = case lookupRho rho f of Just (MultiVal args) -- Including empty tuples -> return (mkTuple args) Just (UnaryVal (StgVarArg f')) @@ -379,7 +514,7 @@ unariseExpr rho e@(StgApp f []) unariseExpr rho e@(StgApp f args) = return (StgApp f' (unariseFunArgs rho args)) where - f' = case lookupVarEnv rho f of + f' = case lookupRho rho f of Just (UnaryVal (StgVarArg f')) -> f' Nothing -> f err -> pprPanic "unariseExpr - app2" (pprStgExpr panicStgPprOpts e $$ ppr err) @@ -390,12 +525,17 @@ unariseExpr _ (StgLit l) = return (StgLit l) unariseExpr rho (StgConApp dc n args ty_args) - | Just args' <- unariseMulti_maybe rho dc args ty_args - = return (mkTuple args') - - | otherwise - , let args' = unariseConArgs rho args - = return (StgConApp dc n args' (map stgArgType args')) + | isUnboxedSumDataCon dc || isUnboxedTupleDataCon dc + = do + us <- getUniqueSupplyM + case unariseUbxSumOrTupleArgs rho us dc args ty_args of + (args', Just cast_wrapper) + -> return $ cast_wrapper (mkTuple args') + (args', Nothing) + -> return $ (mkTuple args') + | otherwise = + let args' = unariseConArgs rho args in + return $ (StgConApp dc n args' (map stgArgType args')) unariseExpr rho (StgOpApp op args ty) = return (StgOpApp op (unariseFunArgs rho args) ty) @@ -403,15 +543,19 @@ unariseExpr rho (StgOpApp op args ty) unariseExpr rho (StgCase scrut bndr alt_ty alts) -- tuple/sum binders in the scrutinee can always be eliminated | StgApp v [] <- scrut - , Just (MultiVal xs) <- lookupVarEnv rho v + , Just (MultiVal xs) <- lookupRho rho v = elimCase rho xs bndr alt_ty alts -- Handle strict lets for tuples and sums: -- case (# a,b #) of r -> rhs -- and analogously for sums | StgConApp dc _n args ty_args <- scrut - , Just args' <- unariseMulti_maybe rho dc args ty_args - = elimCase rho args' bndr alt_ty alts + , isUnboxedSumDataCon dc || isUnboxedTupleDataCon dc + = do + us <- getUniqueSupplyM + case unariseUbxSumOrTupleArgs rho us dc args ty_args of + (args',Just wrapper) -> wrapper <$> elimCase rho args' bndr alt_ty alts + (args',Nothing) -> elimCase rho args' bndr alt_ty alts -- See (3) of Note [Rubbish literals] in GHC.Types.Literal | StgLit lit <- scrut @@ -436,17 +580,21 @@ unariseExpr rho (StgTick tick e) = StgTick tick <$> unariseExpr rho e -- Doesn't return void args. -unariseMulti_maybe :: UnariseEnv -> DataCon -> [InStgArg] -> [Type] -> Maybe [OutStgArg] -unariseMulti_maybe rho dc args ty_args +unariseUbxSumOrTupleArgs :: UnariseEnv -> UniqSupply -> DataCon -> [InStgArg] -> [Type] + -> ( [OutStgArg] -- Arguments representing the unboxed sum + , Maybe (StgExpr -> StgExpr)) -- Transformation to apply to the arguments, to bring them + -- into the right Rep +unariseUbxSumOrTupleArgs rho us dc args ty_args | isUnboxedTupleDataCon dc - = Just (unariseConArgs rho args) + = (unariseConArgs rho args, Nothing) | isUnboxedSumDataCon dc , let args1 = assert (isSingleton args) (unariseConArgs rho args) - = Just (mkUbxSum dc ty_args args1) + = let (args2, cast_wrapper) = mkUbxSum dc ty_args args1 us + in (args2, Just cast_wrapper) | otherwise - = Nothing + = panic "unariseUbxSumOrTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +621,15 @@ elimCase rho args bndr (MultiValAlt _) [GenStgAlt{ alt_con = _ , alt_bndrs = bndrs , alt_rhs = rhs}] = do let rho1 = extendRho rho bndr (MultiVal args) - rho2 + (rho2, rhs') | isUnboxedTupleBndr bndr - = mapTupleIdBinders bndrs args rho1 + = (mapTupleIdBinders bndrs args rho1, rhs) | otherwise = assert (isUnboxedSumBndr bndr) $ - if null bndrs then rho1 - else mapSumIdBinders bndrs args rho1 + if null bndrs then (rho1, rhs) + else mapSumIdBinders bndrs args rhs rho1 - unariseExpr rho2 rhs + unariseExpr rho2 rhs' elimCase rho args bndr (MultiValAlt _) alts | isUnboxedSumBndr bndr @@ -576,12 +724,12 @@ unariseSumAlt rho args GenStgAlt{ alt_con = DataAlt sumCon , alt_bndrs = bs , alt_rhs = e } - = do let rho' = mapSumIdBinders bs args rho - lit_case = LitAlt (LitNumber LitNumInt (fromIntegral (dataConTag sumCon))) - GenStgAlt lit_case mempty <$> unariseExpr rho' e + = do let (rho',e') = mapSumIdBinders bs args e rho + lit_case = LitAlt (LitNumber LitNumInt (fromIntegral (dataConTag sumCon))) + GenStgAlt lit_case mempty <$> unariseExpr rho' e' unariseSumAlt _ scrt alt - = pprPanic "unariseSumAlt" (ppr scrt $$ pprPanicAlt alt) + = pprPanic "unariseSumAlt3" (ppr scrt $$ pprPanicAlt alt) -------------------------------------------------------------------------------- @@ -623,24 +771,79 @@ mapSumIdBinders -- only have one binder, so this list should be a singleton) -> [OutStgArg] -- Arguments that form the sum (NOT including the tag). -- Can't have void args. + -> InStgExpr -> UnariseEnv - -> UnariseEnv + -> (UnariseEnv, OutStgExpr) -mapSumIdBinders [id] args rho0 +mapSumIdBinders [id] args rhs rho0 = assert (not (any (isZeroBitTy . stgArgType) args)) $ let + -- Slots representing the whole sum arg_slots = map primRepSlot $ concatMap (typePrimRep . stgArgType) args + -- The slots representing the field of the sum we bind. id_slots = map primRepSlot $ typePrimRep (idType id) layout1 = layoutUbxSum arg_slots id_slots + + -- See Note [Casting slot arguments] + -- Arg id's which make up the field. + id_arg_exprs = [ args !! i | i <- layout1 ] + id_vars = [v | StgVarArg v <- id_arg_exprs] + + update_id_type v ty + | (typePrimRep $ idType v) == (typePrimRep ty) = v + | otherwise = setIdType v ty + + -- types for the field binders based on their rep + id_tys = map primRepToType $ typePrimRep (idType id) + -- Arg id's with the typ set to one matching the fields rep. + typed_id_args = zipWithEqual "typed_id_args" (\var t -> StgVarArg (update_id_type var t)) id_vars id_tys + -- We can shadow the original argument id here since the binder for the field will only be used + -- at one specific type in this branch. + (rhs_with_casts) = foldr castArgShadow rhs $ zip id_vars id_tys in + -- pprTrace "mapSumIdBinders" + -- (text "id_tys" <+> ppr id_tys $$ + -- text "id_args" <+> ppr id_arg_exprs $$ + -- text "rhs" <+> ppr rhs $$ + -- text "rhs_with_casts" <+> ppr rhs_with_casts + -- ) $ if isMultiValBndr id - then extendRho rho0 id (MultiVal [ args !! i | i <- layout1 ]) - else assert (layout1 `lengthIs` 1) - extendRho rho0 id (UnaryVal (args !! head layout1)) + then (extendRho rho0 id (MultiVal typed_id_args), rhs_with_casts) + else assert (typed_id_args `lengthIs` 1) + (extendRho rho0 id (UnaryVal (head typed_id_args)), rhs_with_casts) -mapSumIdBinders ids sum_args _ +mapSumIdBinders ids sum_args _rhs _ = pprPanic "mapSumIdBinders" (ppr ids $$ ppr sum_args) +-- Convert the argument to the given type, and wrap the case doing the +-- conversion around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, target_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 target_ty) + in foldr (mkCast (StgVarArg arg) arg) (in_rhs) ops + +-- Convert the argument to the given type, and wrap the conversion +-- around the given expression. Use the given Id as a name for the +-- converted value. +castArgRename :: [(PrimOp,Type)] ->StgArg -> Id -> StgExpr -> StgExpr +castArgRename ops in_arg out_id in_rhs = + case ops of + [] -> in_rhs + op1:rest_ops -> + mkCast in_arg out_id op1 $ + foldr (mkCast (StgVarArg out_id) out_id) in_rhs rest_ops + -- pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + -- in foldr (mkCast in_arg out_id) (in_rhs) ops + +-- Variable to cast, (type to cast to, result_ty), rhs +mkCast :: StgArg -> OutId -> (PrimOp,Type) -> StgExpr -> StgExpr +mkCast arg_in out_id (cast_op,ty2) (in_rhs) = + let r2 = typePrimRep1 ty2 + scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + alt_ty = PrimAlt r2 + in (StgCase scrut (setIdType out_id ty2) alt_ty [alt]) + -- | Build a unboxed sum term from arguments of an alternative. -- -- Example, for (# x | #) :: (# (# #) | Int #) we call @@ -655,8 +858,11 @@ mkUbxSum :: DataCon -- Sum data con -> [Type] -- Type arguments of the sum data con -> [OutStgArg] -- Actual arguments of the alternative. - -> [OutStgArg] -- Final tuple arguments -mkUbxSum dc ty_args args0 + -> UniqSupply + -> ([OutStgArg] -- Final tuple arguments + ,(StgExpr->StgExpr) -- We might need to cast the args first + ) +mkUbxSum dc ty_args args0 us = let (_ : sum_slots) = ubxSumRepType (map typePrimRep ty_args) -- drop tag slot @@ -667,16 +873,55 @@ mkUbxSum dc ty_args args0 tag_arg = StgLitArg (LitNumber LitNumInt (fromIntegral tag)) arg_idxs = IM.fromList (zipEqual "mkUbxSum" layout' args0) - mkTupArgs :: Int -> [SlotTy] -> IM.IntMap StgArg -> [StgArg] - mkTupArgs _ [] _ - = [] - mkTupArgs arg_idx (slot : slots_left) arg_map - | Just stg_arg <- IM.lookup arg_idx arg_map - = stg_arg : mkTupArgs (arg_idx + 1) slots_left arg_map - | otherwise - = ubxSumRubbishArg slot : mkTupArgs (arg_idx + 1) slots_left arg_map + ((_idx,_idx_map,_us,wrapper),slot_args) + = assert (length arg_idxs <= length sum_slots ) $ + mapAccumL mkTupArg (0,arg_idxs,us,id) sum_slots + + mkTupArg :: (Int, IM.IntMap StgArg,UniqSupply,StgExpr->StgExpr) + -> SlotTy + -> ((Int,IM.IntMap StgArg,UniqSupply,StgExpr->StgExpr), StgArg) + mkTupArg (arg_idx, arg_map, us, wrapper) slot + | Just stg_arg <- IM.lookup arg_idx arg_map + = case castArg us slot stg_arg of + -- Slot and arg type missmatched, do a cast + Just (casted_arg,us',wrapper') -> + ( (arg_idx+1, arg_map, us', wrapper . wrapper') + , casted_arg) + -- Use the arg as-is + Nothing -> + ( (arg_idx+1, arg_map, us, wrapper) + , stg_arg) + -- Garbage slot, fill with rubbish + | otherwise + = ( (arg_idx+1, arg_map, us, wrapper) + , ubxSumRubbishArg slot) + + castArg :: UniqSupply -> SlotTy -> StgArg -> Maybe (StgArg,UniqSupply,StgExpr -> StgExpr) + castArg us slot_ty arg + -- Cast the argument to the type of the slot if required + | slotPrimRep slot_ty /= typePrimRep1 (stgArgType arg) + , out_ty <- primRepToType $ slotPrimRep slot_ty + , ops <- getCasts (typePrimRep1 $ stgArgType arg) $ typePrimRep1 out_ty + , not . null $ ops + = let (u1,us') = takeUniqFromSupply us + out_name_fs + | (StgVarArg v_arg) <- arg + = getOccFS v_arg `appendFS` fsLit "_cst" + | otherwise = fsLit "cst_lit" + out_id = mkSysLocal out_name_fs u1 Many out_ty + casts = castArgRename ops arg out_id :: StgExpr -> StgExpr + in Just (StgVarArg out_id,us',casts) + -- No need for casting + | otherwise = Nothing + + tup_args = tag_arg : slot_args in - tag_arg : mkTupArgs 0 sum_slots arg_idxs + -- pprTrace "mkUbxSum" ( + -- text "ty_args (slots)" <+> ppr ty_args $$ + -- text "args0" <+> ppr args0 $$ + -- text "wrapper" <+> + -- (ppr $ wrapper $ StgLit $ LitChar '_')) + (tup_args, wrapper) -- | Return a rubbish value for the given slot type. @@ -787,7 +1032,7 @@ unariseArgBinder is_con_arg rho x = -- | MultiVal a function argument. Never returns an empty list. unariseFunArg :: UnariseEnv -> StgArg -> [StgArg] unariseFunArg rho (StgVarArg x) = - case lookupVarEnv rho x of + case lookupRho rho x of Just (MultiVal []) -> [voidArg] -- NB: do not remove void args Just (MultiVal as) -> as Just (UnaryVal arg) -> [arg] @@ -809,7 +1054,7 @@ unariseFunArgBinder = unariseArgBinder False -- | MultiVal a DataCon argument. Returns an empty list when argument is void. unariseConArg :: UnariseEnv -> InStgArg -> [OutStgArg] unariseConArg rho (StgVarArg x) = - case lookupVarEnv rho x of + case lookupRho rho x of Just (UnaryVal arg) -> [arg] Just (MultiVal as) -> as -- 'as' can be empty Nothing ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -245,7 +245,8 @@ ubxSumRepType constrs0 in sumRep -layoutUbxSum :: SortedSlotTys -- Layout of sum. Does not include tag. +layoutUbxSum :: HasDebugCallStack + => SortedSlotTys -- Layout of sum. Does not include tag. -- We assume that they are in increasing order -> [SlotTy] -- Slot types of things we want to map to locations in the -- sum layout @@ -268,7 +269,8 @@ layoutUbxSum sum_slots0 arg_slots0 = | otherwise = findSlot arg (slot_idx + 1) slots useds findSlot _ _ [] _ - = pprPanic "findSlot" (text "Can't find slot" $$ ppr sum_slots0 $$ ppr arg_slots0) + = pprPanic "findSlot" (text "Can't find slot" $$ text "sum_slots:" <> ppr sum_slots0 + $$ text "arg_slots:" <> ppr arg_slots0 ) -------------------------------------------------------------------------------- @@ -347,18 +349,17 @@ fitsIn ty1 ty2 = Just ty1 | isWordSlot ty1 && isWordSlot ty2 = Just (max ty1 ty2) - | isFloatSlot ty1 && isFloatSlot ty2 - = Just (max ty1 ty2) | otherwise = Nothing + -- We used to share slots between Float/Double but currently we can't easily + -- covert between float/double in a way that is both work free and safe. + -- So we put them in different slots. + -- See Note [Casting slot arguments] where isWordSlot Word64Slot = True isWordSlot WordSlot = True isWordSlot _ = False - isFloatSlot DoubleSlot = True - isFloatSlot FloatSlot = True - isFloatSlot _ = False {- ********************************************************************** ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -387,6 +387,7 @@ data SDocContext = SDC , sdocSuppressUniques :: !Bool , sdocSuppressModulePrefixes :: !Bool , sdocSuppressStgExts :: !Bool + , sdocSuppressStgReps :: !Bool , sdocErrorSpans :: !Bool , sdocStarIsType :: !Bool , sdocLinearTypes :: !Bool @@ -447,6 +448,7 @@ defaultSDocContext = SDC , sdocSuppressUniques = False , sdocSuppressModulePrefixes = False , sdocSuppressStgExts = False + , sdocSuppressStgReps = True , sdocErrorSpans = False , sdocStarIsType = False , sdocLinearTypes = False ===================================== compiler/ghc.cabal.in ===================================== @@ -168,6 +168,7 @@ Library GHC.Builtin.Names GHC.Builtin.Names.TH GHC.Builtin.PrimOps + GHC.Builtin.PrimOps.Casts GHC.Builtin.PrimOps.Ids GHC.Builtin.Types GHC.Builtin.Types.Literals ===================================== docs/users_guide/debugging.rst ===================================== @@ -946,6 +946,16 @@ parts that you are not interested in. Suppress the printing of core size stats per binding +.. ghc-flag:: -dsuppress-stg-reps + :shortdesc: Suppress rep annotations on STG args. + :type: dynamic + + :since: 9.6.1 + + default: enabled + + Disabling this will annoate certain stg arguments with their prim rep. + .. _checking-consistency: ===================================== testsuite/driver/testlib.py ===================================== @@ -1447,7 +1447,8 @@ def compile_cmp_asm(name: TestName, ext: str, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile only, extra args = ', extra_hc_opts) result = simple_build(name + '.' + ext, way, '-keep-s-files -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): @@ -1474,7 +1475,8 @@ def compile_grep_asm(name: TestName, is_substring: bool, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile and grep asm, extra args = ', extra_hc_opts) result = simple_build(name + '.' + ext, way, '-keep-s-files -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): @@ -1495,7 +1497,8 @@ def compile_grep_core(name: TestName, way: WayName, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile only, extra args = ', extra_hc_opts) result = simple_build(name + '.hs', way, '-ddump-to-file -dsuppress-all -ddump-simpl -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): ===================================== testsuite/tests/unboxedsums/GenManyUbxSums.hs ===================================== @@ -0,0 +1,109 @@ +#!/usr/bin/env runghc +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} + +-- This little piece of code constructs a large set of functions +-- constructing and deconstructing unboxed tuples of various types. +module Main where + +import GHC.Exts +import System.IO +import Data.List (intersperse) +inputs = ["Int", "Word"] +sizes = ["","8","16","32","64"] + +-- ["Addr#","Int#","Int8#","Int16#","Int32#","Int64#","Word#","Word8#","Word16#","Word32#","Word64#"] +types = "Addr#" : do + r <- inputs + s <- sizes + return $ r++s++"#" + +-- We eventually build two sums, one of type (# t1 | t2 #) and one of (# t1 | t3). +-- So we build all possible combinations of three types here. +combos = do + t1 <- types + t2 <- types + t3 <- types + return (t1,t2,t3) + +mkCon ty = case ty of + "Addr#" -> "Addr" + "Int#" -> "I#" + "Int8#" -> "I8#" + "Int16#" -> "I16#" + "Int32#" -> "I32#" + "Int64#" -> "I64#" + "Word#" -> "W#" + "Word8#" -> "W8#" + "Word16#" -> "W16#" + "Word32#" -> "W32#" + "Word64#" -> "W64#" + +-- Construct a function like the one below, varying the types in the sums based on the +-- given type tuples. +-- We need to NOINLINE or the function will be constant folded away. +-- {-# NOINLINE fun0 #-} +-- fun0 :: (# Addr# | I16# #) -> (# Addr# | I# #) +-- fun0 x = case x of +-- (# x1 | #) -> (# x1 | #) :: (# Addr# | I# #) +mkFun n (t1,t2,t3) = + "{-# NOINLINE fun" ++ show n ++ " #-}\n" ++ + "fun" ++ show n ++ " :: (# " ++ t1 ++" | " ++ t2 ++ " #) -> (# " ++ t1 ++" | " ++ t3 ++ " #)\n" ++ + "fun" ++ show n ++ " x = case x of\n" ++ + " (# x1 | #) -> (# x1 | #) :: (# " ++ t1 ++ " | " ++ t3 ++ " #)" + +-- Generate functions for all the tuple combinations. +mkFuns _ [] = "" +mkFuns n (combo:combos) = + mkFun n combo ++ "\n" ++ mkFuns (n+1) combos + +-- generate a test that will put a value into a unboxed sum and then retrieve it later on. +-- It generates code like the one below: +-- test0 = +-- let in_val = maxBound +-- out_val = case in_val of I# x -> case fun0 (# x | #) of (# y | #) -> I# y +-- in in_val == out_val +mkTest n (t1,_,_)= + let test_name = "test" ++ show n + test_code = test_name ++ " =\n" ++ + " let in_val = (maxBound)\n" ++ + " out_val = case in_val of " ++ mkCon t1 ++ " x -> case fun" ++ show n ++ " (# x | #) of (# y | #) -> " ++ mkCon t1 ++ " y\n" ++ + " in in_val == out_val" + in (test_code,test_name) + +-- Test all the tuples +mkTests n combos = + let (defs, names) = unzip $ zipWith mkTest [0..] combos + assert_results = "\nassert_results = and [" ++ (concat $ intersperse "," names) ++ "]\n" :: String + in unlines defs ++ assert_results + +header = + "{-# LANGUAGE MagicHash #-}\n\ + \{-# LANGUAGE UnboxedTuples #-}\n\ + \{-# LANGUAGE UnboxedSums #-}\n\ + \module Main where\n\ + \import GHC.Exts\n\ + \import GHC.Word\n\ + \import GHC.Int\n\ + \import ManyUbxSums_Addr\n" +main = do + out <- openFile "ManyUbxSums.hs" WriteMode + hPutStrLn out header + + let combo:_ = combos + -- putStrLn $ mkFun 1 combo + hPutStrLn out $ mkFuns 0 combos + + hPutStrLn out $ mkTests 0 combos + hPutStrLn out "main = do" + + hPutStrLn out $ " putStrLn . show $ assert_results" + + -- The snippet below would print all individual test results. + -- But for CI really just check if all results match the input + -- let runTest n = + -- hPutStrLn out $ " putStrLn $ \"test" ++ show n ++ " \" ++ (show test" ++ show n ++ ")" + -- mapM runTest [0 .. length combos - 1] + + hClose out ===================================== testsuite/tests/unboxedsums/ManyUbxSums.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs ===================================== @@ -0,0 +1,26 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} + +{-# OPTIONS_GHC -Wno-missing-methods #-} + +module ManyUbxSums_Addr where + +import GHC.Exts +-- import GHC.Word +-- import GHC.Int +--import GHC.Utils.Misc + +data Addr = Addr Addr# + +instance Eq Addr where + (Addr x) == (Addr y) = case (eqAddr# x y) of + 1# -> True + 0# -> False + +instance Num Addr where + fromInteger x = case fromIntegral x of I# x1 -> Addr (int2Addr# x1) + +instance Bounded Addr where + maxBound = fromIntegral (maxBound :: Word) + minBound = 0 \ No newline at end of file ===================================== testsuite/tests/unboxedsums/T22208.hs ===================================== @@ -0,0 +1,41 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +module M where + +import GHC.Base + +-- Reproducer from #22208 +foo :: (# Float# | Double# #) -> (# Float# | Float #) +foo (# x | #) = (# x | #) +bar :: (# Word# | Int64# #) -> (# Double# | Word# #) +bar (# y | #) = let x = y in (# | x #) +baz :: (# Word# | Word64# #) -> (# Word# | (##) #) +baz (# x | #) = (# x | #) + +foo1 :: (# Float# | Double# #) -> (# Float# | Float #) +foo1 (# x | #) = (# x | #) +bar1 :: (# Word# | Int64# #) -> (# Double# | Word# #) +bar1 (# y | #) = let x = y in (# | x #) +baz1 :: (# Word# | Word64# #) -> (# Word# | (##) #) +baz1 (# x | #) = (# x | #) + +-- i8 value from w64 slot +baz2 :: (# Int8# | Word64# #) -> (# Int8# | (##) #) +baz2 (# x | #) = (# x | #) + +-- w8 value from w64 slot +baz3 :: (# Word8# | Word64# #) -> (# Word8# | (##) #) +baz3 (# x | #) = (# x | #) + +-- w8 from w slot +baz4 :: (# Word8# | Word# #) -> (# Word8# | (##) #) +baz4 (# x | #) = (# x | #) + +-- w from w slot +baz5 :: (# Word8# | Word# #) -> (# Word# | (##) #) +baz5 (# | x #) = (# x | #) + +-- addr from w slot +baz6 :: (# Addr# | Word# #) -> (# Addr# | (##) #) +baz6 (# x | #) = (# x | #) \ No newline at end of file ===================================== testsuite/tests/unboxedsums/all.T ===================================== @@ -35,3 +35,12 @@ test('T20858b', [extra_files(['T20858.hs']) ,extra_hc_opts("-fprint-explicit-runtime-reps -fprint-explicit-kinds")] , ghci_script, ['T20858b.script']) test('T20859', normal, compile, ['']) +test('T22208', normal, compile, ['-dstg-lint -dcmm-lint']) +test('ManyUbxSums', + [ pre_cmd('{compiler} --run ./GenManyUbxSums.hs'), + extra_files(['GenManyUbxSums.hs', 'ManyUbxSums_Addr.hs']), + ], + multi_compile_and_run, + ['ManyUbxSums', + [('ManyUbxSums_Addr.hs','')] + , '-v0 -dstg-lint -dcmm-lint']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f44242de91575f81b8cd6fea0c9d6a838a61c526 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f44242de91575f81b8cd6fea0c9d6a838a61c526 You're receiving 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 Nov 1 15:09:04 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 01 Nov 2022 11:09:04 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Properly convert values before/after storing them in unboxed sums. Message-ID: <63613690f0466_815bc515a43351af@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 63b63a85 by Andreas Klebinger at 2022-11-01T16:06:33+01:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 17 changed files: - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - testsuite/driver/testlib.py - + testsuite/tests/unboxedsums/GenManyUbxSums.hs - + testsuite/tests/unboxedsums/ManyUbxSums.stdout - + testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs - + testsuite/tests/unboxedsums/T22208.hs - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -0,0 +1,213 @@ +{- +This module contains helpers to cast variables +between different Int/WordReps in StgLand. + +-} + +module GHC.Builtin.PrimOps.Casts + ( getCasts ) +where + +import GHC.Prelude + +import GHC.Core.TyCon +import GHC.Utils.Outputable +import GHC.Utils.Panic +import GHC.Utils.Panic.Plain +import GHC.Types.RepType +import GHC.Core.Type +import GHC.Builtin.Types.Prim +import GHC.Builtin.Types + +import GHC.Builtin.PrimOps +import GHC.Plugins (HasDebugCallStack) + +{- Note [PrimRep based casting] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This module contains a number of utility functions useful when +converting between variables of differing PrimReps. + +The general pattern is: +* We have two primReps `from_rep` and `to_rep`. +* We want a list of PrimOps we can apply to a variable of rep `from_rep`. +Applying the list of primOps in order takes us to `to_rep` from `from_rep` giving +us a variable of the returned type at each step. + +E.g. we call `getCasts from_rep to_rep` and get back [(op1#,ty1),(op2#,ty2)]. +We can use this list of primOps to construct a function of type +`StgExpr -> StgExpr` by construction an expression + + case op1# of (x' :: ty1) -> case op2# x' of x' -> + +Ideally backends will compile the sequence of PrimOps to a no-op. E.g. by reusing +the same register but just relabeling it as another width. +However this is might not always be possible or the required optimizations +simply not implemented in the backend. This means currently many of these casts +will be cheap but not all of them will be completely zero-cost. + +-} + +-- | `getCasts from_rep to_rep` gives us a list of primops which when applied in order convert from_rep to to_rep. +-- See Note [PrimRep based casting] +getCasts :: PrimRep -> PrimRep -> [(PrimOp,Type)] +getCasts from_rep to_rep + -- No-op + | -- pprTrace "getCasts" (ppr (from_rep,to_rep)) $ + to_rep == from_rep + = [] + + -- Float <-> Double + | to_rep == FloatRep = + assertPpr (from_rep == DoubleRep) (ppr from_rep <+> ppr to_rep) $ + [(DoubleToFloatOp,floatPrimTy)] + | to_rep == DoubleRep = + assertPpr (from_rep == FloatRep) (ppr from_rep <+> ppr to_rep) $ + [(FloatToDoubleOp,doublePrimTy)] + + -- Addr <-> Word/Int + | to_rep == AddrRep = wordOrIntToAddrRep from_rep + | from_rep == AddrRep = addrToWordOrIntRep to_rep + + -- Int* -> Int* + | primRepIsInt from_rep + , primRepIsInt to_rep + = sizedIntToSizedInt from_rep to_rep + + -- Word* -> Word* + | primRepIsWord from_rep + , primRepIsWord to_rep + = sizedWordToSizedWord from_rep to_rep + + -- Word* -> Int* + | primRepIsWord from_rep + , primRepIsInt to_rep + = let (op1,r1) = wordToIntRep from_rep + in (op1,primRepToType r1):sizedIntToSizedInt r1 to_rep + + -- Int* -> Word* + | primRepIsInt from_rep + , primRepIsWord to_rep + = let (op1,r1) = intToWordRep from_rep + in (op1,primRepToType r1):sizedWordToSizedWord r1 to_rep + + | otherwise = pprPanic "getCasts:Unexpect rep combination" + (ppr (from_rep,to_rep)) + +wordOrIntToAddrRep :: HasDebugCallStack => PrimRep -> [(PrimOp,Type)] +wordOrIntToAddrRep AddrRep = [] -- No-op argument is already AddrRep +wordOrIntToAddrRep IntRep = [(IntToAddrOp, addrPrimTy)] +wordOrIntToAddrRep WordRep = [(WordToIntOp,intPrimTy), (IntToAddrOp,addrPrimTy)] +wordOrIntToAddrRep r + | primRepIsInt r = (intToMachineInt r,intPrimTy):[(IntToAddrOp,addrPrimTy)] + | primRepIsWord r = + let (op1,r1) = wordToIntRep r + in (op1, primRepToType r1):[(intToMachineInt r1,intPrimTy), (IntToAddrOp,addrPrimTy)] + | otherwise = pprPanic "Rep not word or int rep" (ppr r) + +addrToWordOrIntRep :: HasDebugCallStack => PrimRep -> [(PrimOp,Type)] +-- Machine sizes +addrToWordOrIntRep IntRep = [(AddrToIntOp, intPrimTy)] +addrToWordOrIntRep WordRep = [(AddrToIntOp,intPrimTy), (IntToWordOp,wordPrimTy)] +-- Explicitly sized reps +addrToWordOrIntRep r + | primRepIsWord r = (AddrToIntOp,intPrimTy) : (IntToWordOp,wordPrimTy) : sizedWordToSizedWord WordRep r + | primRepIsInt r = (AddrToIntOp,intPrimTy) : sizedIntToSizedInt IntRep r + | otherwise = pprPanic "Target rep not word or int rep" (ppr r) + + +-- WordX# -> IntX# (same size), argument is source rep +wordToIntRep :: HasDebugCallStack => PrimRep -> (PrimOp,PrimRep) +wordToIntRep rep + = case rep of + (WordRep) -> (WordToIntOp, IntRep) + (Word8Rep) -> (Word8ToInt8Op, Int8Rep) + (Word16Rep) -> (Word16ToInt16Op, Int16Rep) + (Word32Rep) -> (Word32ToInt32Op, Int32Rep) + (Word64Rep) -> (Word64ToInt64Op, Int64Rep) + _ -> pprPanic "Rep not a wordRep" (ppr rep) + +-- IntX# -> WordX#, argument is source rep +intToWordRep :: HasDebugCallStack => PrimRep -> (PrimOp,PrimRep) +intToWordRep rep + = case rep of + (IntRep) -> (IntToWordOp, WordRep) + (Int8Rep) -> (Int8ToWord8Op, Word8Rep) + (Int16Rep) -> (Int16ToWord16Op, Word16Rep) + (Int32Rep) -> (Int32ToWord32Op, Word32Rep) + (Int64Rep) -> (Int64ToWord64Op, Word64Rep) + _ -> pprPanic "Rep not a wordRep" (ppr rep) + +-- Casts between any size int to any other size of int +sizedIntToSizedInt :: HasDebugCallStack => PrimRep -> PrimRep -> [(PrimOp,Type)] +sizedIntToSizedInt r1 r2 + | r1 == r2 = [] +-- Cast to Int# +sizedIntToSizedInt r IntRep = [(intToMachineInt r,intTy)] +-- Cast from Int# +sizedIntToSizedInt IntRep r = [(intFromMachineInt r,primRepToType r)] +-- Sized to differently sized must go over machine word. +sizedIntToSizedInt r1 r2 = (intToMachineInt r1,intTy) : [(intFromMachineInt r2,primRepToType r2)] + +-- Casts between any size Word to any other size of Word +sizedWordToSizedWord :: HasDebugCallStack => PrimRep -> PrimRep -> [(PrimOp,Type)] +sizedWordToSizedWord r1 r2 + | r1 == r2 = [] +-- Cast to Word# +sizedWordToSizedWord r WordRep = [(wordToMachineWord r,wordPrimTy)] +-- Cast from Word# +sizedWordToSizedWord WordRep r = [(wordFromMachineWord r, primRepToType r)] +-- Conversion between different non-machine sizes must go via machine word. +sizedWordToSizedWord r1 r2 = (wordToMachineWord r1,wordPrimTy) : [(wordFromMachineWord r2, primRepToType r2)] + + +-- Prefer the definitions above this line if possible +---------------------- + + +-- Int*# to Int# +{-# INLINE intToMachineInt #-} +intToMachineInt :: HasDebugCallStack => PrimRep -> PrimOp +intToMachineInt r = + assertPpr (primRepIsInt r) (ppr r) $ + case r of + (Int8Rep) -> Int8ToIntOp + (Int16Rep) -> Int16ToIntOp + (Int32Rep) -> Int32ToIntOp + (Int64Rep) -> Int64ToIntOp + _ -> pprPanic "Source rep not int" $ ppr r + +-- Int# to Int*# +{-# INLINE intFromMachineInt #-} +intFromMachineInt :: HasDebugCallStack => PrimRep -> PrimOp +intFromMachineInt r = + assertPpr (primRepIsInt r) (ppr r) $ + case r of + Int8Rep -> IntToInt8Op + Int16Rep -> IntToInt16Op + Int32Rep -> IntToInt32Op + Int64Rep -> IntToInt64Op + _ -> pprPanic "Dest rep not sized int" $ ppr r + +-- Word# to Word*# +{-# INLINE wordFromMachineWord #-} +wordFromMachineWord :: HasDebugCallStack => PrimRep -> PrimOp +wordFromMachineWord r = + assert (primRepIsWord r) $ + case r of + Word8Rep -> WordToWord8Op + Word16Rep -> WordToWord16Op + Word32Rep -> WordToWord32Op + Word64Rep -> WordToWord64Op + _ -> pprPanic "Dest rep not sized word" $ ppr r + +-- Word*# to Word# +{-# INLINE wordToMachineWord #-} +wordToMachineWord :: HasDebugCallStack => PrimRep -> PrimOp +wordToMachineWord r = + assertPpr (primRepIsWord r) (text "Not a word rep:" <> ppr r) $ + case r of + Word8Rep -> Word8ToWordOp + Word16Rep -> Word16ToWordOp + Word32Rep -> Word32ToWordOp + Word64Rep -> Word64ToWordOp + _ -> pprPanic "Dest rep not sized word" $ ppr r \ No newline at end of file ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -1399,7 +1399,10 @@ instance OutputableP Platform CLabel where pdoc !platform lbl = getPprStyle $ \pp_sty -> case pp_sty of PprDump{} -> pprCLabel platform CStyle lbl - _ -> pprPanic "Labels in code should be printed with pprCLabel" (pprCLabel platform CStyle lbl) + -- Workaround for #22218 + _ -> (pprCLabel platform CStyle lbl) + -- _ -> pprPanic "Labels in code should be printed with pprCLabel" (pprCLabel platform CStyle lbl) + pprCLabel :: Platform -> LabelStyle -> CLabel -> SDoc pprCLabel !platform !sty lbl = -- see Note [Bangs in CLabel] ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -129,6 +129,7 @@ module GHC.Core.TyCon( primRepIsFloat, primRepsCompatible, primRepCompatible, + primRepIsWord, primRepIsInt, ) where @@ -1785,6 +1786,24 @@ primRepIsFloat DoubleRep = Just True primRepIsFloat (VecRep _ _) = Nothing primRepIsFloat _ = Just False +-- Rep is one of the word reps. +primRepIsWord :: PrimRep -> Bool +primRepIsWord WordRep = True +primRepIsWord (Word8Rep) = True +primRepIsWord (Word16Rep) = True +primRepIsWord (Word32Rep) = True +primRepIsWord (Word64Rep) = True +primRepIsWord _ = False + +-- Rep is one of the int reps. +primRepIsInt :: PrimRep -> Bool +primRepIsInt (IntRep) = True +primRepIsInt (Int8Rep) = True +primRepIsInt (Int16Rep) = True +primRepIsInt (Int32Rep) = True +primRepIsInt (Int64Rep) = True +primRepIsInt _ = False + {- ************************************************************************ * * ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -422,6 +422,7 @@ data GeneralFlag -- variables that have otherwise identical names. | Opt_SuppressUniques | Opt_SuppressStgExts + | Opt_SuppressStgReps | Opt_SuppressTicks -- Replaces Opt_PprShowTicks | Opt_SuppressTimestamps -- ^ Suppress timestamps in dumps | Opt_SuppressCoreSizes -- ^ Suppress per binding Core size stats in dumps ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2393,6 +2393,7 @@ dynamic_flags_deps = [ setGeneralFlag Opt_SuppressIdInfo setGeneralFlag Opt_SuppressTicks setGeneralFlag Opt_SuppressStgExts + setGeneralFlag Opt_SuppressStgReps setGeneralFlag Opt_SuppressTypeSignatures setGeneralFlag Opt_SuppressCoreSizes setGeneralFlag Opt_SuppressTimestamps) @@ -3344,6 +3345,7 @@ dFlagsDeps = [ depFlagSpec' "suppress-stg-free-vars" Opt_SuppressStgExts (useInstead "-d" "suppress-stg-exts"), flagSpec "suppress-stg-exts" Opt_SuppressStgExts, + flagSpec "suppress-stg-reps" Opt_SuppressStgReps, flagSpec "suppress-coercions" Opt_SuppressCoercions, flagSpec "suppress-coercion-types" Opt_SuppressCoercionTypes, flagSpec "suppress-idinfo" Opt_SuppressIdInfo, @@ -3796,7 +3798,8 @@ defaultFlags settings Opt_VersionMacros, Opt_RPath, Opt_DumpWithWays, - Opt_CompactUnwind + Opt_CompactUnwind, + Opt_SuppressStgReps ] ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns] @@ -5020,6 +5023,7 @@ initSDocContext dflags style = SDC , sdocSuppressUniques = gopt Opt_SuppressUniques dflags , sdocSuppressModulePrefixes = gopt Opt_SuppressModulePrefixes dflags , sdocSuppressStgExts = gopt Opt_SuppressStgExts dflags + , sdocSuppressStgReps = gopt Opt_SuppressStgReps dflags , sdocErrorSpans = gopt Opt_ErrorSpans dflags , sdocStarIsType = xopt LangExt.StarIsType dflags , sdocLinearTypes = xopt LangExt.LinearTypes dflags ===================================== compiler/GHC/Stg/Syntax.hs ===================================== @@ -87,7 +87,7 @@ import GHC.Core.Ppr( {- instances -} ) import GHC.Builtin.PrimOps ( PrimOp, PrimCall ) import GHC.Core.TyCon ( PrimRep(..), TyCon ) import GHC.Core.Type ( Type ) -import GHC.Types.RepType ( typePrimRep1 ) +import GHC.Types.RepType ( typePrimRep1, typePrimRep ) import GHC.Utils.Panic.Plain {- @@ -740,12 +740,23 @@ pprStgTopBinding = pprGenStgTopBinding pprStgTopBindings :: OutputablePass pass => StgPprOpts -> [GenStgTopBinding pass] -> SDoc pprStgTopBindings = pprGenStgTopBindings +pprIdWithRep :: Id -> SDoc +pprIdWithRep v = ppr v <> pprTypeRep (idType v) + +pprTypeRep :: Type -> SDoc +pprTypeRep ty = + ppUnlessOption sdocSuppressStgReps $ + char ':' <> case typePrimRep ty of + [r] -> ppr r + r -> ppr r + + instance Outputable StgArg where ppr = pprStgArg pprStgArg :: StgArg -> SDoc -pprStgArg (StgVarArg var) = ppr var -pprStgArg (StgLitArg con) = ppr con +pprStgArg (StgVarArg var) = pprIdWithRep var +pprStgArg (StgLitArg con) = ppr con <> pprTypeRep (literalType con) instance OutputablePass pass => Outputable (GenStgExpr pass) where ppr = pprStgExpr panicStgPprOpts ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -186,6 +186,132 @@ So we pass type arguments of the DataCon's TyCon in StgConApp to decide what layout to use. Note that unlifted values can't be let-bound, so we don't need types in StgRhsCon. +Note [Casting slot arguments] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this function which selects between Float# and Double# from a unboxed sum. + + foo :: (# Float# | Double# #) -> FD + foo x = case x of + (# x1 | #) -> F x1 + (# | x2 #) -> D x2 + +Naturally we would expect x1 to have a PrimRep of FloatRep and x2 of DoubleRep. +However we used to generate this (bogus) code after Unarise giving rise to #22208: + + M.foo :: (# GHC.Prim.Float# | GHC.Prim.Double# #) -> M.FD + [GblId, Arity=1, Unf=OtherCon []] = + {} \r [sum_tag sum_field] + case sum_tag of tag_gsc { + __DEFAULT -> M.F [sum_field]; + 2# -> M.D [sum_field]; + }; + +Where sum_field is used both as Float# and Double# depending on the branch +because they share the same SlotTy. +This usually works out since we put floats/doubles in the same sort of register. +However this caused issues down the road where we would assign between variables +of different reps causing lint errors or in the case of #22208 even compiler panics. +For now our solution is to construct proper casts between the PrimRep of the slot and +the variables we want to store in, or read out of these slots. + +This means when we have a sum (# Float# | Double# #) if we want to store a float +we convert it to a double on construction of the tuple value, and convert it back +to a float once when want to use the field. +Conversion for values coming out of a strict field happen in mapSumIdBinders. While +conversion during the construction of sums happen inside mkUbxSum. + +------------- A full example of casting during sum construction ---------------- + +To give a full example if we *construct* a unboxed sum of +type (# Int32# | Int64# ) in an expression like `let sum = (# | #) x` +Then we will call mkUbxSum to determine which arguments we have to pass in which +order to the unboxed tuple that represents the unboxed sum. + +Int32# and Int# in this case will share the same slot in the unboxed sum. This +means we want to upcast the argument in order to match up the reps of the +variables. To do this mkUbxSum will produce a casting expression with a hole for +the original rhs to go into. That is the call to mkUbxSum and it's result will +look something like: + + >>> mkUbxSum (#|#) [Int32#, Int#] (x::Int32#) us(x') + ([x'::Double#], case int32ToInt# x of x' -> <_hole_> ) + +We will use the returned arguments to construct an application to an unboxed tuple: + + (# #) 1# x' + +Which we will then use to construct an expression that casts `x` to the right type +and places it into x': + + >>> (\_hole_ -> case int32ToInt# x of x' -> _hole_) ((# #) 1# x') + case int32ToInt# x of x' -> (# #) 1# x' + +Which results in the this definition for `sum` after all is said and done: + + let sum = case int32ToInt# x of { x' -> (# #) 1# x' } + +You might wonder why we bother renaming `x` to `x'`. It's quite subtle. Consider +a definition like this: + + let sum_shadow :: (# (# Int32#, Int32# ) | Int64# #) + let sum_shadow = (# |#) (# x, x #) + +We compute the required slots for the tuple and come up with +`[WordSlot, Word64Slot]`. For the first sum constructor we will place `x` both +in a Word and a Word64Slot. If we would not rename the constructor what we would +get would be: + + let sum_shadow = case int32ToInt# x of + { x -> + (# #) 1# x x -- With the unboxed tuple having type (# #) :: (# Int#, Int#, Int64 #) + } + +Clearly this is somewhat bogus, we would end up using the same `x` as a +Int# and a Int64# value! + +------------- A full example of casting during sum matching -------------------- + +When matching on the same unboxed sum constructor as above we start out with +something like this the pre-unarise: + + f sum = case sum of + (# x |#) -> ... x ... -- (# x |#) :: (# Int32, Int#) + ... + +We start desugaring and get: + + f sum_tag sum_slot_arg_1 = case sum_tag of + 1# -> ??? + +Now we need to match the slot arguments to binders in the original case +alternative. This is done by mapSumIdBinders which we we call for our +example alternative like this: + + >>> mapSumIdBinders [x] [sum_slot_arg_1] alt_rhs env + (env', alt_rhs') + +mapSumIdBinders first matches up the list of binders with the slots passed to +the function which is trivial in this case. Then we check if the slot and the +variable residing inside it agree on their Rep. If all binders and slot reps +agree we just extend the environment with a mapping from `x` to `sum_slot_arg_1` +and we return the rhs as is. +If the reps do not agree then we wrap the whole RHS in a case which casts the +bound variable to a type of the correct representation. Here `x` is of Int32Rep +while `sum_slot_arg_1` will be of IntRep. This means instead of retuning the +original alt_rhs we will return: + + case intToInt32# (x :: Int#) of + (x :: Int32#) -> original_alt_rhs + +We then run unarise on this expression, which will replace the first occurence +of `x` with sum_slot_arg_1 giving us post-unarise: + + f sum_tag sum_slot_arg_1 = + case sum_tag of + 1# -> case intToInt32# sum_slot_arg_1 of + x -> ... x ... + ... + Note [UnariseEnv] ~~~~~~~~~~~~~~~~~~ At any variable occurrence 'v', @@ -258,8 +384,8 @@ import GHC.Prelude import GHC.Types.Basic import GHC.Core import GHC.Core.DataCon -import GHC.Core.TyCon ( isVoidRep ) -import GHC.Data.FastString (FastString, mkFastString) +import GHC.Core.TyCon +import GHC.Data.FastString (FastString, mkFastString, fsLit, appendFS) import GHC.Types.Id import GHC.Types.Literal import GHC.Core.Make (aBSENT_SUM_FIELD_ERROR_ID) @@ -281,7 +407,12 @@ import GHC.Types.Var.Env import Data.Bifunctor (second) import Data.Maybe (mapMaybe) import qualified Data.IntMap as IM +import GHC.Builtin.PrimOps +import GHC.Builtin.PrimOps.Casts +import Data.List (mapAccumL) +import GHC.Types.Name +-- import GHC.Utils.Trace -------------------------------------------------------------------------------- -- | A mapping from binders to the Ids they were expanded/renamed to. @@ -306,8 +437,10 @@ import qualified Data.IntMap as IM -- INVARIANT: OutStgArgs in the range only have NvUnaryTypes -- (i.e. no unboxed tuples, sums or voids) -- -type UnariseEnv = VarEnv UnariseVal +newtype UnariseEnv = UnariseEnv { ue_rho :: (VarEnv UnariseVal) } +initUnariseEnv :: VarEnv UnariseVal -> UnariseEnv +initUnariseEnv = UnariseEnv data UnariseVal = MultiVal [OutStgArg] -- MultiVal to tuple. Can be empty list (void). | UnaryVal OutStgArg -- See Note [Renaming during unarisation]. @@ -320,25 +453,27 @@ instance Outputable UnariseVal where -- The id is mapped to one or more things. -- See Note [UnariseEnv] extendRho :: UnariseEnv -> Id -> UnariseVal -> UnariseEnv -extendRho rho x (MultiVal args) +extendRho env x (MultiVal args) = assert (all (isNvUnaryType . stgArgType) args) - extendVarEnv rho x (MultiVal args) -extendRho rho x (UnaryVal val) + env { ue_rho = extendVarEnv (ue_rho env) x (MultiVal args) } +extendRho env x (UnaryVal val) = assert (isNvUnaryType (stgArgType val)) - extendVarEnv rho x (UnaryVal val) + env { ue_rho = extendVarEnv (ue_rho env) x (UnaryVal val) } -- Properly shadow things from an outer scope. -- See Note [UnariseEnv] -- The id stands for itself so we don't record a mapping. -- See Note [UnariseEnv] extendRhoWithoutValue :: UnariseEnv -> Id -> UnariseEnv -extendRhoWithoutValue rho x = delVarEnv rho x +extendRhoWithoutValue env x = env { ue_rho = delVarEnv (ue_rho env) x } +lookupRho :: UnariseEnv -> Id -> Maybe UnariseVal +lookupRho env v = lookupVarEnv (ue_rho env) v -------------------------------------------------------------------------------- unarise :: UniqSupply -> [StgTopBinding] -> [StgTopBinding] -unarise us binds = initUs_ us (mapM (unariseTopBinding emptyVarEnv) binds) +unarise us binds = initUs_ us (mapM (unariseTopBinding (initUnariseEnv emptyVarEnv)) binds) unariseTopBinding :: UnariseEnv -> StgTopBinding -> UniqSM StgTopBinding unariseTopBinding rho (StgTopLifted bind) @@ -366,7 +501,7 @@ unariseRhs rho (StgRhsCon ccs con mu ts args) unariseExpr :: UnariseEnv -> StgExpr -> UniqSM StgExpr unariseExpr rho e@(StgApp f []) - = case lookupVarEnv rho f of + = case lookupRho rho f of Just (MultiVal args) -- Including empty tuples -> return (mkTuple args) Just (UnaryVal (StgVarArg f')) @@ -379,7 +514,7 @@ unariseExpr rho e@(StgApp f []) unariseExpr rho e@(StgApp f args) = return (StgApp f' (unariseFunArgs rho args)) where - f' = case lookupVarEnv rho f of + f' = case lookupRho rho f of Just (UnaryVal (StgVarArg f')) -> f' Nothing -> f err -> pprPanic "unariseExpr - app2" (pprStgExpr panicStgPprOpts e $$ ppr err) @@ -390,12 +525,17 @@ unariseExpr _ (StgLit l) = return (StgLit l) unariseExpr rho (StgConApp dc n args ty_args) - | Just args' <- unariseMulti_maybe rho dc args ty_args - = return (mkTuple args') - - | otherwise - , let args' = unariseConArgs rho args - = return (StgConApp dc n args' (map stgArgType args')) + | isUnboxedSumDataCon dc || isUnboxedTupleDataCon dc + = do + us <- getUniqueSupplyM + case unariseUbxSumOrTupleArgs rho us dc args ty_args of + (args', Just cast_wrapper) + -> return $ cast_wrapper (mkTuple args') + (args', Nothing) + -> return $ (mkTuple args') + | otherwise = + let args' = unariseConArgs rho args in + return $ (StgConApp dc n args' (map stgArgType args')) unariseExpr rho (StgOpApp op args ty) = return (StgOpApp op (unariseFunArgs rho args) ty) @@ -403,15 +543,19 @@ unariseExpr rho (StgOpApp op args ty) unariseExpr rho (StgCase scrut bndr alt_ty alts) -- tuple/sum binders in the scrutinee can always be eliminated | StgApp v [] <- scrut - , Just (MultiVal xs) <- lookupVarEnv rho v + , Just (MultiVal xs) <- lookupRho rho v = elimCase rho xs bndr alt_ty alts -- Handle strict lets for tuples and sums: -- case (# a,b #) of r -> rhs -- and analogously for sums | StgConApp dc _n args ty_args <- scrut - , Just args' <- unariseMulti_maybe rho dc args ty_args - = elimCase rho args' bndr alt_ty alts + , isUnboxedSumDataCon dc || isUnboxedTupleDataCon dc + = do + us <- getUniqueSupplyM + case unariseUbxSumOrTupleArgs rho us dc args ty_args of + (args',Just wrapper) -> wrapper <$> elimCase rho args' bndr alt_ty alts + (args',Nothing) -> elimCase rho args' bndr alt_ty alts -- See (3) of Note [Rubbish literals] in GHC.Types.Literal | StgLit lit <- scrut @@ -436,17 +580,21 @@ unariseExpr rho (StgTick tick e) = StgTick tick <$> unariseExpr rho e -- Doesn't return void args. -unariseMulti_maybe :: UnariseEnv -> DataCon -> [InStgArg] -> [Type] -> Maybe [OutStgArg] -unariseMulti_maybe rho dc args ty_args +unariseUbxSumOrTupleArgs :: UnariseEnv -> UniqSupply -> DataCon -> [InStgArg] -> [Type] + -> ( [OutStgArg] -- Arguments representing the unboxed sum + , Maybe (StgExpr -> StgExpr)) -- Transformation to apply to the arguments, to bring them + -- into the right Rep +unariseUbxSumOrTupleArgs rho us dc args ty_args | isUnboxedTupleDataCon dc - = Just (unariseConArgs rho args) + = (unariseConArgs rho args, Nothing) | isUnboxedSumDataCon dc , let args1 = assert (isSingleton args) (unariseConArgs rho args) - = Just (mkUbxSum dc ty_args args1) + = let (args2, cast_wrapper) = mkUbxSum dc ty_args args1 us + in (args2, Just cast_wrapper) | otherwise - = Nothing + = panic "unariseUbxSumOrTupleArgs: Constructor not a unboxed sum or tuple" -- Doesn't return void args. unariseRubbish_maybe :: Literal -> Maybe [OutStgArg] @@ -473,15 +621,15 @@ elimCase rho args bndr (MultiValAlt _) [GenStgAlt{ alt_con = _ , alt_bndrs = bndrs , alt_rhs = rhs}] = do let rho1 = extendRho rho bndr (MultiVal args) - rho2 + (rho2, rhs') | isUnboxedTupleBndr bndr - = mapTupleIdBinders bndrs args rho1 + = (mapTupleIdBinders bndrs args rho1, rhs) | otherwise = assert (isUnboxedSumBndr bndr) $ - if null bndrs then rho1 - else mapSumIdBinders bndrs args rho1 + if null bndrs then (rho1, rhs) + else mapSumIdBinders bndrs args rhs rho1 - unariseExpr rho2 rhs + unariseExpr rho2 rhs' elimCase rho args bndr (MultiValAlt _) alts | isUnboxedSumBndr bndr @@ -576,12 +724,12 @@ unariseSumAlt rho args GenStgAlt{ alt_con = DataAlt sumCon , alt_bndrs = bs , alt_rhs = e } - = do let rho' = mapSumIdBinders bs args rho - lit_case = LitAlt (LitNumber LitNumInt (fromIntegral (dataConTag sumCon))) - GenStgAlt lit_case mempty <$> unariseExpr rho' e + = do let (rho',e') = mapSumIdBinders bs args e rho + lit_case = LitAlt (LitNumber LitNumInt (fromIntegral (dataConTag sumCon))) + GenStgAlt lit_case mempty <$> unariseExpr rho' e' unariseSumAlt _ scrt alt - = pprPanic "unariseSumAlt" (ppr scrt $$ pprPanicAlt alt) + = pprPanic "unariseSumAlt3" (ppr scrt $$ pprPanicAlt alt) -------------------------------------------------------------------------------- @@ -623,24 +771,79 @@ mapSumIdBinders -- only have one binder, so this list should be a singleton) -> [OutStgArg] -- Arguments that form the sum (NOT including the tag). -- Can't have void args. + -> InStgExpr -> UnariseEnv - -> UnariseEnv + -> (UnariseEnv, OutStgExpr) -mapSumIdBinders [id] args rho0 +mapSumIdBinders [id] args rhs rho0 = assert (not (any (isZeroBitTy . stgArgType) args)) $ let + -- Slots representing the whole sum arg_slots = map primRepSlot $ concatMap (typePrimRep . stgArgType) args + -- The slots representing the field of the sum we bind. id_slots = map primRepSlot $ typePrimRep (idType id) layout1 = layoutUbxSum arg_slots id_slots + + -- See Note [Casting slot arguments] + -- Arg id's which make up the field. + id_arg_exprs = [ args !! i | i <- layout1 ] + id_vars = [v | StgVarArg v <- id_arg_exprs] + + update_id_type v ty + | (typePrimRep $ idType v) == (typePrimRep ty) = v + | otherwise = setIdType v ty + + -- types for the field binders based on their rep + id_tys = map primRepToType $ typePrimRep (idType id) + -- Arg id's with the typ set to one matching the fields rep. + typed_id_args = zipWithEqual "typed_id_args" (\var t -> StgVarArg (update_id_type var t)) id_vars id_tys + -- We can shadow the original argument id here since the binder for the field will only be used + -- at one specific type in this branch. + (rhs_with_casts) = foldr castArgShadow rhs $ zip id_vars id_tys in + -- pprTrace "mapSumIdBinders" + -- (text "id_tys" <+> ppr id_tys $$ + -- text "id_args" <+> ppr id_arg_exprs $$ + -- text "rhs" <+> ppr rhs $$ + -- text "rhs_with_casts" <+> ppr rhs_with_casts + -- ) $ if isMultiValBndr id - then extendRho rho0 id (MultiVal [ args !! i | i <- layout1 ]) - else assert (layout1 `lengthIs` 1) - extendRho rho0 id (UnaryVal (args !! head layout1)) + then (extendRho rho0 id (MultiVal typed_id_args), rhs_with_casts) + else assert (typed_id_args `lengthIs` 1) + (extendRho rho0 id (UnaryVal (head typed_id_args)), rhs_with_casts) -mapSumIdBinders ids sum_args _ +mapSumIdBinders ids sum_args _rhs _ = pprPanic "mapSumIdBinders" (ppr ids $$ ppr sum_args) +-- Convert the argument to the given type, and wrap the case doing the +-- conversion around the given expression. +castArgShadow :: (Id,Type) -> StgExpr -> StgExpr +castArgShadow (arg, target_ty) (in_rhs) = + let ops = getCasts (typePrimRep1 $ idType arg) (typePrimRep1 target_ty) + in foldr (mkCast (StgVarArg arg) arg) (in_rhs) ops + +-- Convert the argument to the given type, and wrap the conversion +-- around the given expression. Use the given Id as a name for the +-- converted value. +castArgRename :: [(PrimOp,Type)] ->StgArg -> Id -> StgExpr -> StgExpr +castArgRename ops in_arg out_id in_rhs = + case ops of + [] -> in_rhs + op1:rest_ops -> + mkCast in_arg out_id op1 $ + foldr (mkCast (StgVarArg out_id) out_id) in_rhs rest_ops + -- pprTrace "castArgRename" (ppr (in_arg,out_id)) $ + -- in foldr (mkCast in_arg out_id) (in_rhs) ops + +-- Variable to cast, (type to cast to, result_ty), rhs +mkCast :: StgArg -> OutId -> (PrimOp,Type) -> StgExpr -> StgExpr +mkCast arg_in out_id (cast_op,ty2) (in_rhs) = + let r2 = typePrimRep1 ty2 + scrut = StgOpApp (StgPrimOp cast_op) [arg_in] ty2 + alt = GenStgAlt { alt_con = DEFAULT, alt_bndrs = [], alt_rhs = in_rhs} + alt_ty = PrimAlt r2 + in (StgCase scrut (setIdType out_id ty2) alt_ty [alt]) + -- | Build a unboxed sum term from arguments of an alternative. -- -- Example, for (# x | #) :: (# (# #) | Int #) we call @@ -655,8 +858,11 @@ mkUbxSum :: DataCon -- Sum data con -> [Type] -- Type arguments of the sum data con -> [OutStgArg] -- Actual arguments of the alternative. - -> [OutStgArg] -- Final tuple arguments -mkUbxSum dc ty_args args0 + -> UniqSupply + -> ([OutStgArg] -- Final tuple arguments + ,(StgExpr->StgExpr) -- We might need to cast the args first + ) +mkUbxSum dc ty_args args0 us = let (_ : sum_slots) = ubxSumRepType (map typePrimRep ty_args) -- drop tag slot @@ -667,16 +873,55 @@ mkUbxSum dc ty_args args0 tag_arg = StgLitArg (LitNumber LitNumInt (fromIntegral tag)) arg_idxs = IM.fromList (zipEqual "mkUbxSum" layout' args0) - mkTupArgs :: Int -> [SlotTy] -> IM.IntMap StgArg -> [StgArg] - mkTupArgs _ [] _ - = [] - mkTupArgs arg_idx (slot : slots_left) arg_map - | Just stg_arg <- IM.lookup arg_idx arg_map - = stg_arg : mkTupArgs (arg_idx + 1) slots_left arg_map - | otherwise - = ubxSumRubbishArg slot : mkTupArgs (arg_idx + 1) slots_left arg_map + ((_idx,_idx_map,_us,wrapper),slot_args) + = assert (length arg_idxs <= length sum_slots ) $ + mapAccumL mkTupArg (0,arg_idxs,us,id) sum_slots + + mkTupArg :: (Int, IM.IntMap StgArg,UniqSupply,StgExpr->StgExpr) + -> SlotTy + -> ((Int,IM.IntMap StgArg,UniqSupply,StgExpr->StgExpr), StgArg) + mkTupArg (arg_idx, arg_map, us, wrapper) slot + | Just stg_arg <- IM.lookup arg_idx arg_map + = case castArg us slot stg_arg of + -- Slot and arg type missmatched, do a cast + Just (casted_arg,us',wrapper') -> + ( (arg_idx+1, arg_map, us', wrapper . wrapper') + , casted_arg) + -- Use the arg as-is + Nothing -> + ( (arg_idx+1, arg_map, us, wrapper) + , stg_arg) + -- Garbage slot, fill with rubbish + | otherwise + = ( (arg_idx+1, arg_map, us, wrapper) + , ubxSumRubbishArg slot) + + castArg :: UniqSupply -> SlotTy -> StgArg -> Maybe (StgArg,UniqSupply,StgExpr -> StgExpr) + castArg us slot_ty arg + -- Cast the argument to the type of the slot if required + | slotPrimRep slot_ty /= typePrimRep1 (stgArgType arg) + , out_ty <- primRepToType $ slotPrimRep slot_ty + , ops <- getCasts (typePrimRep1 $ stgArgType arg) $ typePrimRep1 out_ty + , not . null $ ops + = let (u1,us') = takeUniqFromSupply us + out_name_fs + | (StgVarArg v_arg) <- arg + = getOccFS v_arg `appendFS` fsLit "_cst" + | otherwise = fsLit "cst_lit" + out_id = mkSysLocal out_name_fs u1 Many out_ty + casts = castArgRename ops arg out_id :: StgExpr -> StgExpr + in Just (StgVarArg out_id,us',casts) + -- No need for casting + | otherwise = Nothing + + tup_args = tag_arg : slot_args in - tag_arg : mkTupArgs 0 sum_slots arg_idxs + -- pprTrace "mkUbxSum" ( + -- text "ty_args (slots)" <+> ppr ty_args $$ + -- text "args0" <+> ppr args0 $$ + -- text "wrapper" <+> + -- (ppr $ wrapper $ StgLit $ LitChar '_')) + (tup_args, wrapper) -- | Return a rubbish value for the given slot type. @@ -787,7 +1032,7 @@ unariseArgBinder is_con_arg rho x = -- | MultiVal a function argument. Never returns an empty list. unariseFunArg :: UnariseEnv -> StgArg -> [StgArg] unariseFunArg rho (StgVarArg x) = - case lookupVarEnv rho x of + case lookupRho rho x of Just (MultiVal []) -> [voidArg] -- NB: do not remove void args Just (MultiVal as) -> as Just (UnaryVal arg) -> [arg] @@ -809,7 +1054,7 @@ unariseFunArgBinder = unariseArgBinder False -- | MultiVal a DataCon argument. Returns an empty list when argument is void. unariseConArg :: UnariseEnv -> InStgArg -> [OutStgArg] unariseConArg rho (StgVarArg x) = - case lookupVarEnv rho x of + case lookupRho rho x of Just (UnaryVal arg) -> [arg] Just (MultiVal as) -> as -- 'as' can be empty Nothing ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -245,7 +245,8 @@ ubxSumRepType constrs0 in sumRep -layoutUbxSum :: SortedSlotTys -- Layout of sum. Does not include tag. +layoutUbxSum :: HasDebugCallStack + => SortedSlotTys -- Layout of sum. Does not include tag. -- We assume that they are in increasing order -> [SlotTy] -- Slot types of things we want to map to locations in the -- sum layout @@ -268,7 +269,8 @@ layoutUbxSum sum_slots0 arg_slots0 = | otherwise = findSlot arg (slot_idx + 1) slots useds findSlot _ _ [] _ - = pprPanic "findSlot" (text "Can't find slot" $$ ppr sum_slots0 $$ ppr arg_slots0) + = pprPanic "findSlot" (text "Can't find slot" $$ text "sum_slots:" <> ppr sum_slots0 + $$ text "arg_slots:" <> ppr arg_slots0 ) -------------------------------------------------------------------------------- @@ -347,18 +349,17 @@ fitsIn ty1 ty2 = Just ty1 | isWordSlot ty1 && isWordSlot ty2 = Just (max ty1 ty2) - | isFloatSlot ty1 && isFloatSlot ty2 - = Just (max ty1 ty2) | otherwise = Nothing + -- We used to share slots between Float/Double but currently we can't easily + -- covert between float/double in a way that is both work free and safe. + -- So we put them in different slots. + -- See Note [Casting slot arguments] where isWordSlot Word64Slot = True isWordSlot WordSlot = True isWordSlot _ = False - isFloatSlot DoubleSlot = True - isFloatSlot FloatSlot = True - isFloatSlot _ = False {- ********************************************************************** ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -387,6 +387,7 @@ data SDocContext = SDC , sdocSuppressUniques :: !Bool , sdocSuppressModulePrefixes :: !Bool , sdocSuppressStgExts :: !Bool + , sdocSuppressStgReps :: !Bool , sdocErrorSpans :: !Bool , sdocStarIsType :: !Bool , sdocLinearTypes :: !Bool @@ -447,6 +448,7 @@ defaultSDocContext = SDC , sdocSuppressUniques = False , sdocSuppressModulePrefixes = False , sdocSuppressStgExts = False + , sdocSuppressStgReps = True , sdocErrorSpans = False , sdocStarIsType = False , sdocLinearTypes = False ===================================== compiler/ghc.cabal.in ===================================== @@ -168,6 +168,7 @@ Library GHC.Builtin.Names GHC.Builtin.Names.TH GHC.Builtin.PrimOps + GHC.Builtin.PrimOps.Casts GHC.Builtin.PrimOps.Ids GHC.Builtin.Types GHC.Builtin.Types.Literals ===================================== docs/users_guide/debugging.rst ===================================== @@ -946,6 +946,16 @@ parts that you are not interested in. Suppress the printing of core size stats per binding +.. ghc-flag:: -dsuppress-stg-reps + :shortdesc: Suppress rep annotations on STG args. + :type: dynamic + + :since: 9.6.1 + + default: enabled + + Disabling this will annoate certain stg arguments with their prim rep. + .. _checking-consistency: ===================================== testsuite/driver/testlib.py ===================================== @@ -1447,7 +1447,8 @@ def compile_cmp_asm(name: TestName, ext: str, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile only, extra args = ', extra_hc_opts) result = simple_build(name + '.' + ext, way, '-keep-s-files -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): @@ -1474,7 +1475,8 @@ def compile_grep_asm(name: TestName, is_substring: bool, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile and grep asm, extra args = ', extra_hc_opts) result = simple_build(name + '.' + ext, way, '-keep-s-files -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): @@ -1495,7 +1497,8 @@ def compile_grep_core(name: TestName, way: WayName, extra_hc_opts: str ) -> PassFail: - print('Compile only, extra args = ', extra_hc_opts) + if extra_hc_opts: + print('Compile only, extra args = ', extra_hc_opts) result = simple_build(name + '.hs', way, '-ddump-to-file -dsuppress-all -ddump-simpl -O ' + extra_hc_opts, False, None, [], False, False) if badResult(result): ===================================== testsuite/tests/unboxedsums/GenManyUbxSums.hs ===================================== @@ -0,0 +1,109 @@ +#!/usr/bin/env runghc +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} + +-- This little piece of code constructs a large set of functions +-- constructing and deconstructing unboxed tuples of various types. +module Main where + +import GHC.Exts +import System.IO +import Data.List (intersperse) +inputs = ["Int", "Word"] +sizes = ["","8","16","32","64"] + +-- ["Addr#","Int#","Int8#","Int16#","Int32#","Int64#","Word#","Word8#","Word16#","Word32#","Word64#"] +types = "Addr#" : do + r <- inputs + s <- sizes + return $ r++s++"#" + +-- We eventually build two sums, one of type (# t1 | t2 #) and one of (# t1 | t3). +-- So we build all possible combinations of three types here. +combos = do + t1 <- types + t2 <- types + t3 <- types + return (t1,t2,t3) + +mkCon ty = case ty of + "Addr#" -> "Addr" + "Int#" -> "I#" + "Int8#" -> "I8#" + "Int16#" -> "I16#" + "Int32#" -> "I32#" + "Int64#" -> "I64#" + "Word#" -> "W#" + "Word8#" -> "W8#" + "Word16#" -> "W16#" + "Word32#" -> "W32#" + "Word64#" -> "W64#" + +-- Construct a function like the one below, varying the types in the sums based on the +-- given type tuples. +-- We need to NOINLINE or the function will be constant folded away. +-- {-# NOINLINE fun0 #-} +-- fun0 :: (# Addr# | I16# #) -> (# Addr# | I# #) +-- fun0 x = case x of +-- (# x1 | #) -> (# x1 | #) :: (# Addr# | I# #) +mkFun n (t1,t2,t3) = + "{-# NOINLINE fun" ++ show n ++ " #-}\n" ++ + "fun" ++ show n ++ " :: (# " ++ t1 ++" | " ++ t2 ++ " #) -> (# " ++ t1 ++" | " ++ t3 ++ " #)\n" ++ + "fun" ++ show n ++ " x = case x of\n" ++ + " (# x1 | #) -> (# x1 | #) :: (# " ++ t1 ++ " | " ++ t3 ++ " #)" + +-- Generate functions for all the tuple combinations. +mkFuns _ [] = "" +mkFuns n (combo:combos) = + mkFun n combo ++ "\n" ++ mkFuns (n+1) combos + +-- generate a test that will put a value into a unboxed sum and then retrieve it later on. +-- It generates code like the one below: +-- test0 = +-- let in_val = maxBound +-- out_val = case in_val of I# x -> case fun0 (# x | #) of (# y | #) -> I# y +-- in in_val == out_val +mkTest n (t1,_,_)= + let test_name = "test" ++ show n + test_code = test_name ++ " =\n" ++ + " let in_val = (maxBound)\n" ++ + " out_val = case in_val of " ++ mkCon t1 ++ " x -> case fun" ++ show n ++ " (# x | #) of (# y | #) -> " ++ mkCon t1 ++ " y\n" ++ + " in in_val == out_val" + in (test_code,test_name) + +-- Test all the tuples +mkTests n combos = + let (defs, names) = unzip $ zipWith mkTest [0..] combos + assert_results = "\nassert_results = and [" ++ (concat $ intersperse "," names) ++ "]\n" :: String + in unlines defs ++ assert_results + +header = + "{-# LANGUAGE MagicHash #-}\n\ + \{-# LANGUAGE UnboxedTuples #-}\n\ + \{-# LANGUAGE UnboxedSums #-}\n\ + \module Main where\n\ + \import GHC.Exts\n\ + \import GHC.Word\n\ + \import GHC.Int\n\ + \import ManyUbxSums_Addr\n" +main = do + out <- openFile "ManyUbxSums.hs" WriteMode + hPutStrLn out header + + let combo:_ = combos + -- putStrLn $ mkFun 1 combo + hPutStrLn out $ mkFuns 0 combos + + hPutStrLn out $ mkTests 0 combos + hPutStrLn out "main = do" + + hPutStrLn out $ " putStrLn . show $ assert_results" + + -- The snippet below would print all individual test results. + -- But for CI really just check if all results match the input + -- let runTest n = + -- hPutStrLn out $ " putStrLn $ \"test" ++ show n ++ " \" ++ (show test" ++ show n ++ ")" + -- mapM runTest [0 .. length combos - 1] + + hClose out ===================================== testsuite/tests/unboxedsums/ManyUbxSums.stdout ===================================== @@ -0,0 +1 @@ +True ===================================== testsuite/tests/unboxedsums/ManyUbxSums_Addr.hs ===================================== @@ -0,0 +1,26 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} + +{-# OPTIONS_GHC -Wno-missing-methods #-} + +module ManyUbxSums_Addr where + +import GHC.Exts +-- import GHC.Word +-- import GHC.Int +--import GHC.Utils.Misc + +data Addr = Addr Addr# + +instance Eq Addr where + (Addr x) == (Addr y) = case (eqAddr# x y) of + 1# -> True + 0# -> False + +instance Num Addr where + fromInteger x = case fromIntegral x of I# x1 -> Addr (int2Addr# x1) + +instance Bounded Addr where + maxBound = fromIntegral (maxBound :: Word) + minBound = 0 \ No newline at end of file ===================================== testsuite/tests/unboxedsums/T22208.hs ===================================== @@ -0,0 +1,41 @@ +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE UnboxedSums #-} +{-# LANGUAGE UnboxedTuples #-} +module M where + +import GHC.Base + +-- Reproducer from #22208 +foo :: (# Float# | Double# #) -> (# Float# | Float #) +foo (# x | #) = (# x | #) +bar :: (# Word# | Int64# #) -> (# Double# | Word# #) +bar (# y | #) = let x = y in (# | x #) +baz :: (# Word# | Word64# #) -> (# Word# | (##) #) +baz (# x | #) = (# x | #) + +foo1 :: (# Float# | Double# #) -> (# Float# | Float #) +foo1 (# x | #) = (# x | #) +bar1 :: (# Word# | Int64# #) -> (# Double# | Word# #) +bar1 (# y | #) = let x = y in (# | x #) +baz1 :: (# Word# | Word64# #) -> (# Word# | (##) #) +baz1 (# x | #) = (# x | #) + +-- i8 value from w64 slot +baz2 :: (# Int8# | Word64# #) -> (# Int8# | (##) #) +baz2 (# x | #) = (# x | #) + +-- w8 value from w64 slot +baz3 :: (# Word8# | Word64# #) -> (# Word8# | (##) #) +baz3 (# x | #) = (# x | #) + +-- w8 from w slot +baz4 :: (# Word8# | Word# #) -> (# Word8# | (##) #) +baz4 (# x | #) = (# x | #) + +-- w from w slot +baz5 :: (# Word8# | Word# #) -> (# Word# | (##) #) +baz5 (# | x #) = (# x | #) + +-- addr from w slot +baz6 :: (# Addr# | Word# #) -> (# Addr# | (##) #) +baz6 (# x | #) = (# x | #) \ No newline at end of file ===================================== testsuite/tests/unboxedsums/all.T ===================================== @@ -35,3 +35,12 @@ test('T20858b', [extra_files(['T20858.hs']) ,extra_hc_opts("-fprint-explicit-runtime-reps -fprint-explicit-kinds")] , ghci_script, ['T20858b.script']) test('T20859', normal, compile, ['']) +test('T22208', normal, compile, ['-dstg-lint -dcmm-lint']) +test('ManyUbxSums', + [ pre_cmd('{compiler} --run ./GenManyUbxSums.hs'), + extra_files(['GenManyUbxSums.hs', 'ManyUbxSums_Addr.hs']), + ], + multi_compile_and_run, + ['ManyUbxSums', + [('ManyUbxSums_Addr.hs','')] + , '-v0 -dstg-lint -dcmm-lint']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/63b63a8544b19ceba7a8af41f4eea0f90d6b846f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/63b63a8544b19ceba7a8af41f4eea0f90d6b846f You're receiving 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 Nov 1 16:01:29 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 01 Nov 2022 12:01:29 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] 5 commits: Replace use of Prelude with Prelude.Basic Message-ID: <636142d97aa11_815bc51568382465@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: 9e87adc6 by Andreas Klebinger at 2022-11-01T16:17:45+01:00 Replace use of Prelude with Prelude.Basic - - - - - 18891ee1 by Andreas Klebinger at 2022-11-01T16:37:50+01:00 Make GHC.Utils.Ppr prelude importable - - - - - 7c59fd38 by Andreas Klebinger at 2022-11-01T16:50:22+01:00 Make outputable prelude importable - - - - - 20a20eb0 by Andreas Klebinger at 2022-11-01T16:55:44+01:00 Remove Ppr.Doc - - - - - 95cd19f5 by Andreas Klebinger at 2022-11-01T16:59:03+01:00 wip - - - - - 25 changed files: - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/FastString/Type.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Prelude.hs - + compiler/GHC/Prelude/Basic.hs - compiler/GHC/Utils/BufHandle.hs - compiler/GHC/Utils/Constants.hs - compiler/GHC/Utils/Exception.hs - compiler/GHC/Utils/Fingerprint.hs - compiler/GHC/Utils/GlobalVars.hs - compiler/GHC/Utils/IO/Unsafe.hs - compiler/GHC/Utils/Misc.hs - compiler/GHC/Utils/Outputable.hs - − compiler/GHC/Utils/Outputable/SDoc.hs - compiler/GHC/Utils/Panic/Plain.hs - compiler/GHC/Utils/Ppr.hs - compiler/GHC/Utils/Ppr/Colour.hs - − compiler/GHC/Utils/Ppr/Doc.hs - compiler/GHC/Utils/Trace.hs - compiler/GHC/Utils/Trace.hs-boot - compiler/Setup.hs - compiler/ghc.cabal.in - hadrian/src/Rules/Generate.hs Changes: ===================================== compiler/GHC/Data/Bool.hs ===================================== @@ -4,7 +4,7 @@ module GHC.Data.Bool ) where -import Prelude +import GHC.Prelude.Basic data OverridingBool = Auto ===================================== compiler/GHC/Data/FastMutInt.hs ===================================== @@ -13,7 +13,7 @@ module GHC.Data.FastMutInt( atomicFetchAddFastMut ) where -import GHC.Prelude +import GHC.Prelude.Basic import GHC.Base ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -109,7 +109,7 @@ module GHC.Data.FastString lengthPS ) where -import GHC.Prelude +import GHC.Prelude.Basic import GHC.Data.FastString.Type ===================================== compiler/GHC/Data/FastString/Type.hs ===================================== @@ -52,7 +52,7 @@ module GHC.Data.FastString.Type ) where -import Prelude +import GHC.Prelude.Basic import Control.DeepSeq import Data.ByteString (ByteString) ===================================== compiler/GHC/Driver/Config/StgToCmm.hs ===================================== @@ -2,6 +2,8 @@ module GHC.Driver.Config.StgToCmm ( initStgToCmmConfig ) where +import GHC.Prelude.Basic + import GHC.StgToCmm.Config import GHC.Driver.Backend @@ -12,9 +14,6 @@ import GHC.Utils.Error import GHC.Unit.Module import GHC.Utils.Outputable -import Data.Maybe -import Prelude - initStgToCmmConfig :: DynFlags -> Module -> StgToCmmConfig initStgToCmmConfig dflags mod = StgToCmmConfig -- settings ===================================== compiler/GHC/Prelude.hs ===================================== @@ -13,11 +13,8 @@ -- * Explicitly imports GHC.Prelude module GHC.Prelude - (module X - ,Applicative (..) - ,module Bits + (module GHC.Prelude ,module GHC.Utils.Trace - ,shiftL, shiftR ) where @@ -49,9 +46,7 @@ NoImplicitPrelude. There are two motivations for this: extensions. -} -import Prelude as X hiding ((<>), Applicative(..)) -import Control.Applicative (Applicative(..)) -import Data.Foldable as X (foldl') +import GHC.Prelude.Basic as GHC.Prelude import {-# SOURCE #-} GHC.Utils.Trace ( pprTrace @@ -64,52 +59,3 @@ import {-# SOURCE #-} GHC.Utils.Trace , warnPprTrace , pprTraceUserWarning ) - -#if MIN_VERSION_base(4,16,0) -import GHC.Bits as Bits hiding (shiftL, shiftR) -# if defined(DEBUG) -import qualified GHC.Bits as Bits (shiftL, shiftR) -# endif - -#else ---base <4.15 -import Data.Bits as Bits hiding (shiftL, shiftR) -# if defined(DEBUG) -import qualified Data.Bits as Bits (shiftL, shiftR) -# endif -#endif - -{- Note [Default to unsafe shifts inside GHC] - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The safe shifts can introduce branches which come -at the cost of performance. We still want the additional -debugability for debug builds. So we define it as one or the -other depending on the DEBUG setting. - -Why do we then continue on to re-export the rest of Data.Bits? -If we would not what is likely to happen is: -* Someone imports Data.Bits, uses xor. Things are fine. -* They add a shift and get an ambiguous definition error. -* The are puzzled for a bit. -* They either: - + Remove the import of Data.Bits and get an error because xor is not in scope. - + Add the hiding clause to the Data.Bits import for the shifts. - -Either is quite annoying. Simply re-exporting all of Data.Bits avoids this -making for a smoother developer experience. At the cost of having a few more -names in scope at all time. But that seems like a fair tradeoff. - -See also #19618 --} - --- We always want the Data.Bits method to show up for rules etc. -{-# INLINE shiftL #-} -{-# INLINE shiftR #-} -shiftL, shiftR :: Bits.Bits a => a -> Int -> a -#if defined(DEBUG) -shiftL = Bits.shiftL -shiftR = Bits.shiftR -#else -shiftL = Bits.unsafeShiftL -shiftR = Bits.unsafeShiftR -#endif ===================================== compiler/GHC/Prelude/Basic.hs ===================================== @@ -0,0 +1,104 @@ +{-# LANGUAGE CPP #-} +{-# OPTIONS_HADDOCK not-home #-} +{-# OPTIONS_GHC -O2 #-} -- See Note [-O2 Prelude] + +-- | Custom minimal GHC "Prelude" +-- +-- This module serves as a replacement for the "Prelude" module +-- and abstracts over differences between the bootstrapping +-- GHC version, and may also provide a common default vocabulary. + +-- Every module in GHC +-- * Is compiled with -XNoImplicitPrelude +-- * Explicitly imports GHC.BasicPrelude or GHC.Prelude +-- * The later provides some functionality with within ghc itself +-- like pprTrace. + +module GHC.Prelude.Basic + (module X + ,Applicative (..) + ,module Bits + ,shiftL, shiftR + ) where + + +{- Note [-O2 Prelude] +~~~~~~~~~~~~~~~~~~~~~ +There is some code in GHC that is *always* compiled with -O[2] because +of it's impact on compile time performance. Some of this code might depend +on the definitions like shiftL being defined here being performant. + +So we always compile this module with -O2. It's (currently) tiny so I +have little reason to suspect this impacts overall GHC compile times +negatively. + +-} +-- We export the 'Semigroup' class but w/o the (<>) operator to avoid +-- clashing with the (Outputable.<>) operator which is heavily used +-- through GHC's code-base. + +{- +Note [Why do we import Prelude here?] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The files ghc-boot-th.cabal, ghc-boot.cabal, ghci.cabal and +ghc-heap.cabal contain the directive default-extensions: +NoImplicitPrelude. There are two motivations for this: + - Consistency with the compiler directory, which enables + NoImplicitPrelude; + - Allows loading the above dependent packages with ghc-in-ghci, + giving a smoother development experience when adding new + extensions. +-} + +import Prelude as X hiding ((<>), Applicative(..)) +import Control.Applicative (Applicative(..)) +import Data.Foldable as X (foldl') + +#if MIN_VERSION_base(4,16,0) +import GHC.Bits as Bits hiding (shiftL, shiftR) +# if defined(DEBUG) +import qualified GHC.Bits as Bits (shiftL, shiftR) +# endif + +#else +--base <4.15 +import Data.Bits as Bits hiding (shiftL, shiftR) +# if defined(DEBUG) +import qualified Data.Bits as Bits (shiftL, shiftR) +# endif +#endif + +{- Note [Default to unsafe shifts inside GHC] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The safe shifts can introduce branches which come +at the cost of performance. We still want the additional +debugability for debug builds. So we define it as one or the +other depending on the DEBUG setting. + +Why do we then continue on to re-export the rest of Data.Bits? +If we would not what is likely to happen is: +* Someone imports Data.Bits, uses xor. Things are fine. +* They add a shift and get an ambiguous definition error. +* The are puzzled for a bit. +* They either: + + Remove the import of Data.Bits and get an error because xor is not in scope. + + Add the hiding clause to the Data.Bits import for the shifts. + +Either is quite annoying. Simply re-exporting all of Data.Bits avoids this +making for a smoother developer experience. At the cost of having a few more +names in scope at all time. But that seems like a fair tradeoff. + +See also #19618 +-} + +-- We always want the Data.Bits method to show up for rules etc. +{-# INLINE shiftL #-} +{-# INLINE shiftR #-} +shiftL, shiftR :: Bits.Bits a => a -> Int -> a +#if defined(DEBUG) +shiftL = Bits.shiftL +shiftR = Bits.shiftR +#else +shiftL = Bits.unsafeShiftL +shiftR = Bits.unsafeShiftR +#endif ===================================== compiler/GHC/Utils/BufHandle.hs ===================================== @@ -24,7 +24,7 @@ module GHC.Utils.BufHandle ( bFlush, ) where -import GHC.Prelude +import GHC.Prelude.Basic import GHC.Data.FastString import GHC.Data.FastMutInt ===================================== compiler/GHC/Utils/Constants.hs ===================================== @@ -8,7 +8,7 @@ module GHC.Utils.Constants ) where -import GHC.Prelude +import GHC.Prelude.Basic {- ===================================== compiler/GHC/Utils/Exception.hs ===================================== @@ -8,7 +8,7 @@ module GHC.Utils.Exception ) where -import Prelude +import GHC.Prelude.Basic import GHC.IO (catchException) import Control.Exception as CE hiding (assert) ===================================== compiler/GHC/Utils/Fingerprint.hs ===================================== @@ -22,7 +22,7 @@ module GHC.Utils.Fingerprint ( getFileHash ) where -import GHC.Prelude +import GHC.Prelude.Basic import Foreign import GHC.IO ===================================== compiler/GHC/Utils/GlobalVars.hs ===================================== @@ -22,7 +22,7 @@ module GHC.Utils.GlobalVars ) where -import GHC.Prelude +import GHC.Prelude.Basic import GHC.Conc.Sync ( sharedCAF ) ===================================== compiler/GHC/Utils/IO/Unsafe.hs ===================================== @@ -9,7 +9,7 @@ module GHC.Utils.IO.Unsafe ) where -import GHC.Prelude () +import GHC.Prelude.Basic () import GHC.Exts import GHC.IO (IO(..)) ===================================== compiler/GHC/Utils/Misc.hs ===================================== @@ -124,7 +124,7 @@ module GHC.Utils.Misc ( HasDebugCallStack, ) where -import GHC.Prelude hiding ( head, init, last, tail ) +import GHC.Prelude.Basic hiding ( head, init, last, tail ) import GHC.Utils.Exception import GHC.Utils.Panic.Plain ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -6,11 +6,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} --- The SDoc IsString instance requires the text function from this module. --- Given the choice between an orphan instance and using a boot module I chose --- the orphan instance. Mostly for performance reasons. -{-# OPTIONS_GHC -Wno-orphans #-} - {- (c) The University of Glasgow 2006-2012 (c) The GRASP Project, Glasgow University, 1992-1998 @@ -111,13 +106,12 @@ module GHC.Utils.Outputable ( ) where -import GHC.Prelude - -import GHC.Utils.Outputable.SDoc import Language.Haskell.Syntax.Module.Name ( ModuleName(..) ) -import {-# SOURCE #-} GHC.Unit.Types ( moduleName ) --- import {-# SOURCE #-} GHC.Types.Name.Occurrence( OccName ) +import GHC.Prelude.Basic + +import {-# SOURCE #-} GHC.Unit.Types ( Unit, Module, moduleName ) +import {-# SOURCE #-} GHC.Types.Name.Occurrence( OccName ) import GHC.Utils.BufHandle (BufHandle) import GHC.Data.FastString @@ -154,8 +148,77 @@ import Data.Time.Format.ISO8601 import GHC.Fingerprint import GHC.Show ( showMultiLineString ) import GHC.Utils.Exception --- import GHC.Exts (oneShot) +import GHC.Exts (oneShot) + +{- +************************************************************************ +* * +\subsection{The @PprStyle@ data type} +* * +************************************************************************ +-} + +data PprStyle + = PprUser PrintUnqualified Depth Coloured + -- Pretty-print in a way that will make sense to the + -- ordinary user; must be very close to Haskell + -- syntax, etc. + -- Assumes printing tidied code: non-system names are + -- printed without uniques. + + | PprDump PrintUnqualified + -- For -ddump-foo; less verbose than in ppr-debug mode, but more than PprUser + -- Does not assume tidied code: non-external names + -- are printed with uniques. + + | PprCode -- ^ Print code; either C or assembler + +data Depth + = AllTheWay + | PartWay Int -- ^ 0 => stop + | DefaultDepth -- ^ Use 'sdocDefaultDepth' field as depth + +data Coloured + = Uncoloured + | Coloured + +-- ----------------------------------------------------------------------------- +-- Printing original names +-- | When printing code that contains original names, we need to map the +-- original names back to something the user understands. This is the +-- purpose of the triple of functions that gets passed around +-- when rendering 'SDoc'. +data PrintUnqualified = QueryQualify { + queryQualifyName :: QueryQualifyName, + queryQualifyModule :: QueryQualifyModule, + queryQualifyPackage :: QueryQualifyPackage +} + +-- | Given a `Name`'s `Module` and `OccName`, decide whether and how to qualify +-- it. +type QueryQualifyName = Module -> OccName -> QualifyName + +-- | For a given module, we need to know whether to print it with +-- a package name to disambiguate it. +type QueryQualifyModule = Module -> Bool + +-- | For a given package, we need to know whether to print it with +-- the component id to disambiguate it. +type QueryQualifyPackage = Unit -> Bool + +-- See Note [Printing original names] in GHC.Types.Name.Ppr +data QualifyName -- Given P:M.T + = NameUnqual -- It's in scope unqualified as "T" + -- OR nothing called "T" is in scope + + | NameQual ModuleName -- It's in scope qualified as "X.T" + + | NameNotInScope1 -- It's not in scope at all, but M.T is not bound + -- in the current scope, so we can refer to it as "M.T" + + | NameNotInScope2 -- It's not in scope at all, and M.T is already bound in + -- the current scope, so we must refer to it as "P:M.T" instance Outputable QualifyName where ppr NameUnqual = text "NameUnqual" @@ -253,8 +316,85 @@ shown. The following test decides whether or not we are actually generating code (either C or assembly), or generating interface files. +************************************************************************ +* * +\subsection{The @SDoc@ data type} +* * +************************************************************************ -} +-- | Represents a pretty-printable document. +-- +-- To display an 'SDoc', use 'printSDoc', 'printSDocLn', 'bufLeftRenderSDoc', +-- or 'renderWithContext'. Avoid calling 'runSDoc' directly as it breaks the +-- abstraction layer. +newtype SDoc = SDoc' (SDocContext -> Doc) + +-- See Note [The one-shot state monad trick] in GHC.Utils.Monad +{-# COMPLETE SDoc #-} +pattern SDoc :: (SDocContext -> Doc) -> SDoc +pattern SDoc m <- SDoc' m + where + SDoc m = SDoc' (oneShot m) + +runSDoc :: SDoc -> (SDocContext -> Doc) +runSDoc (SDoc m) = m + +data SDocContext = SDC + { sdocStyle :: !PprStyle + , sdocColScheme :: !Col.Scheme + , sdocLastColour :: !Col.PprColour + -- ^ The most recently used colour. + -- This allows nesting colours. + , sdocShouldUseColor :: !Bool + , sdocDefaultDepth :: !Int + , sdocLineLength :: !Int + , sdocCanUseUnicode :: !Bool + -- ^ True if Unicode encoding is supported + -- and not disabled by GHC_NO_UNICODE environment variable + , sdocHexWordLiterals :: !Bool + , sdocPprDebug :: !Bool + , sdocPrintUnicodeSyntax :: !Bool + , sdocPrintCaseAsLet :: !Bool + , sdocPrintTypecheckerElaboration :: !Bool + , sdocPrintAxiomIncomps :: !Bool + , sdocPrintExplicitKinds :: !Bool + , sdocPrintExplicitCoercions :: !Bool + , sdocPrintExplicitRuntimeReps :: !Bool + , sdocPrintExplicitForalls :: !Bool + , sdocPrintPotentialInstances :: !Bool + , sdocPrintEqualityRelations :: !Bool + , sdocSuppressTicks :: !Bool + , sdocSuppressTypeSignatures :: !Bool + , sdocSuppressTypeApplications :: !Bool + , sdocSuppressIdInfo :: !Bool + , sdocSuppressCoercions :: !Bool + , sdocSuppressCoercionTypes :: !Bool + , sdocSuppressUnfoldings :: !Bool + , sdocSuppressVarKinds :: !Bool + , sdocSuppressUniques :: !Bool + , sdocSuppressModulePrefixes :: !Bool + , sdocSuppressStgExts :: !Bool + , sdocErrorSpans :: !Bool + , sdocStarIsType :: !Bool + , sdocLinearTypes :: !Bool + , sdocListTuplePuns :: !Bool + , sdocPrintTypeAbbreviations :: !Bool + , sdocUnitIdForUser :: !(FastString -> SDoc) + -- ^ Used to map UnitIds to more friendly "package-version:component" + -- strings while pretty-printing. + -- + -- Use `GHC.Unit.State.pprWithUnitState` to set it. Users should never + -- have to set it to pretty-print SDocs emitted by GHC, otherwise it's a + -- bug. It's an internal field used to thread the UnitState so that the + -- Outputable instance of UnitId can use it. + -- + -- See Note [Pretty-printing UnitId] in "GHC.Unit" for more details. + -- + -- Note that we use `FastString` instead of `UnitId` to avoid boring + -- module inter-dependency issues. + } + instance IsString SDoc where fromString = text ===================================== compiler/GHC/Utils/Outputable/SDoc.hs deleted ===================================== @@ -1,171 +0,0 @@ -{-# LANGUAGE PatternSynonyms #-} - --- Having the SDoc type in it's own module allows us to export --- trace functions from our prelude. --- See Note [Exporting pprTrace from GHC.Prelude] -module GHC.Utils.Outputable.SDoc where - -import Prelude - -import GHC.Utils.Ppr.Doc -import Language.Haskell.Syntax.Module.Name.Type ( ModuleName(..) ) -import qualified GHC.Utils.Ppr.Colour as Col - -import {-# SOURCE #-} GHC.Unit.Types ( Unit, Module ) -import {-# SOURCE #-} GHC.Types.Name.Occurrence( OccName ) - -import GHC.Data.FastString.Type ( FastString ) -import GHC.Exts (oneShot) - -{- -************************************************************************ -* * -\subsection{The @SDoc@ data type} -* * -************************************************************************ --} - --- | Represents a pretty-printable document. --- --- To display an 'SDoc', use 'printSDoc', 'printSDocLn', 'bufLeftRenderSDoc', --- or 'renderWithContext'. Avoid calling 'runSDoc' directly as it breaks the --- abstraction layer. -newtype SDoc = SDoc' (SDocContext -> Doc) - --- See Note [The one-shot state monad trick] in GHC.Utils.Monad -{-# COMPLETE SDoc #-} -pattern SDoc :: (SDocContext -> Doc) -> SDoc -pattern SDoc m <- SDoc' m - where - SDoc m = SDoc' (oneShot m) - -runSDoc :: SDoc -> (SDocContext -> Doc) -runSDoc (SDoc m) = m - -data SDocContext = SDC - { sdocStyle :: !PprStyle - , sdocColScheme :: !Col.Scheme - , sdocLastColour :: !Col.PprColour - -- ^ The most recently used colour. - -- This allows nesting colours. - , sdocShouldUseColor :: !Bool - , sdocDefaultDepth :: !Int - , sdocLineLength :: !Int - , sdocCanUseUnicode :: !Bool - -- ^ True if Unicode encoding is supported - -- and not disabled by GHC_NO_UNICODE environment variable - , sdocHexWordLiterals :: !Bool - , sdocPprDebug :: !Bool - , sdocPrintUnicodeSyntax :: !Bool - , sdocPrintCaseAsLet :: !Bool - , sdocPrintTypecheckerElaboration :: !Bool - , sdocPrintAxiomIncomps :: !Bool - , sdocPrintExplicitKinds :: !Bool - , sdocPrintExplicitCoercions :: !Bool - , sdocPrintExplicitRuntimeReps :: !Bool - , sdocPrintExplicitForalls :: !Bool - , sdocPrintPotentialInstances :: !Bool - , sdocPrintEqualityRelations :: !Bool - , sdocSuppressTicks :: !Bool - , sdocSuppressTypeSignatures :: !Bool - , sdocSuppressTypeApplications :: !Bool - , sdocSuppressIdInfo :: !Bool - , sdocSuppressCoercions :: !Bool - , sdocSuppressCoercionTypes :: !Bool - , sdocSuppressUnfoldings :: !Bool - , sdocSuppressVarKinds :: !Bool - , sdocSuppressUniques :: !Bool - , sdocSuppressModulePrefixes :: !Bool - , sdocSuppressStgExts :: !Bool - , sdocErrorSpans :: !Bool - , sdocStarIsType :: !Bool - , sdocLinearTypes :: !Bool - , sdocListTuplePuns :: !Bool - , sdocPrintTypeAbbreviations :: !Bool - , sdocUnitIdForUser :: !(FastString -> SDoc) - -- ^ Used to map UnitIds to more friendly "package-version:component" - -- strings while pretty-printing. - -- - -- Use `GHC.Unit.State.pprWithUnitState` to set it. Users should never - -- have to set it to pretty-print SDocs emitted by GHC, otherwise it's a - -- bug. It's an internal field used to thread the UnitState so that the - -- Outputable instance of UnitId can use it. - -- - -- See Note [Pretty-printing UnitId] in "GHC.Unit" for more details. - -- - -- Note that we use `FastString` instead of `UnitId` to avoid boring - -- module inter-dependency issues. - } - - -{- -************************************************************************ -* * -\subsection{The @PprStyle@ data type} -* * -************************************************************************ --} - -data PprStyle - = PprUser PrintUnqualified Depth Coloured - -- Pretty-print in a way that will make sense to the - -- ordinary user; must be very close to Haskell - -- syntax, etc. - -- Assumes printing tidied code: non-system names are - -- printed without uniques. - - | PprDump PrintUnqualified - -- For -ddump-foo; less verbose than in ppr-debug mode, but more than PprUser - -- Does not assume tidied code: non-external names - -- are printed with uniques. - - | PprCode -- ^ Print code; either C or assembler - -data Depth - = AllTheWay - | PartWay Int -- ^ 0 => stop - | DefaultDepth -- ^ Use 'sdocDefaultDepth' field as depth - -data Coloured - = Uncoloured - | Coloured - --- ----------------------------------------------------------------------------- --- Printing original names - --- | When printing code that contains original names, we need to map the --- original names back to something the user understands. This is the --- purpose of the triple of functions that gets passed around --- when rendering 'SDoc'. -data PrintUnqualified = QueryQualify { - queryQualifyName :: QueryQualifyName, - queryQualifyModule :: QueryQualifyModule, - queryQualifyPackage :: QueryQualifyPackage -} - - - --- | Given a `Name`'s `Module` and `OccName`, decide whether and how to qualify --- it. -type QueryQualifyName = Module -> OccName -> QualifyName - --- | For a given module, we need to know whether to print it with --- a package name to disambiguate it. -type QueryQualifyModule = Module -> Bool - --- | For a given package, we need to know whether to print it with --- the component id to disambiguate it. -type QueryQualifyPackage = Unit -> Bool - --- See Note [Printing original names] in GHC.Types.Name.Ppr -data QualifyName -- Given P:M.T - = NameUnqual -- It's in scope unqualified as "T" - -- OR nothing called "T" is in scope - - | NameQual ModuleName -- It's in scope qualified as "X.T" - - | NameNotInScope1 -- It's not in scope at all, but M.T is not bound - -- in the current scope, so we can refer to it as "M.T" - - | NameNotInScope2 -- It's not in scope at all, and M.T is already bound in - -- the current scope, so we must refer to it as "P:M.T" \ No newline at end of file ===================================== compiler/GHC/Utils/Panic/Plain.hs ===================================== @@ -28,7 +28,7 @@ import GHC.Settings.Config import GHC.Utils.Constants import GHC.Utils.Exception as Exception import GHC.Stack -import GHC.Prelude +import GHC.Prelude.Basic import System.IO.Unsafe -- | This type is very similar to 'GHC.Utils.Panic.GhcException', but it omits ===================================== compiler/GHC/Utils/Ppr.hs ===================================== @@ -1,10 +1,6 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE MagicHash #-} --- The Doc Show instance requires the fullRender function from this module. --- Given the choice between an orphan instance and using a boot module I chose --- the orphan instance. Mostly for performance reasons. -{-# OPTIONS_GHC -Wno-orphans #-} ----------------------------------------------------------------------------- -- | -- Module : GHC.Utils.Ppr @@ -115,7 +111,7 @@ module GHC.Utils.Ppr ( ) where -import GHC.Prelude hiding (error) +import GHC.Prelude.Basic hiding (error) import GHC.Utils.BufHandle import GHC.Data.FastString @@ -127,7 +123,6 @@ import Numeric (showHex) import GHC.Base ( unpackCString#, unpackNBytes#, Int(..) ) import GHC.Ptr ( Ptr(..) ) -import GHC.Utils.Ppr.Doc -- --------------------------------------------------------------------------- -- The Doc calculus @@ -211,6 +206,72 @@ infixl 6 <+> infixl 5 $$, $+$ +-- --------------------------------------------------------------------------- +-- The Doc data type + +-- | The abstract type of documents. +-- A Doc represents a *set* of layouts. A Doc with +-- no occurrences of Union or NoDoc represents just one layout. +data Doc + = Empty -- empty + | NilAbove Doc -- text "" $$ x + | TextBeside !TextDetails {-# UNPACK #-} !Int Doc -- text s <> x + | Nest {-# UNPACK #-} !Int Doc -- nest k x + | Union Doc Doc -- ul `union` ur + | NoDoc -- The empty set of documents + | Beside Doc Bool Doc -- True <=> space between + | Above Doc Bool Doc -- True <=> never overlap + +{- +Here are the invariants: + +1) The argument of NilAbove is never Empty. Therefore + a NilAbove occupies at least two lines. + +2) The argument of @TextBeside@ is never @Nest at . + +3) The layouts of the two arguments of @Union@ both flatten to the same + string. + +4) The arguments of @Union@ are either @TextBeside@, or @NilAbove at . + +5) A @NoDoc@ may only appear on the first line of the left argument of an + union. Therefore, the right argument of an union can never be equivalent + to the empty set (@NoDoc@). + +6) An empty document is always represented by @Empty at . It can't be + hidden inside a @Nest@, or a @Union@ of two @Empty at s. + +7) The first line of every layout in the left argument of @Union@ is + longer than the first line of any layout in the right argument. + (1) ensures that the left argument has a first line. In view of + (3), this invariant means that the right argument must have at + least two lines. + +Notice the difference between + * NoDoc (no documents) + * Empty (one empty document; no height and no width) + * text "" (a document containing the empty string; + one line high, but has no width) +-} + + +-- | RDoc is a "reduced GDoc", guaranteed not to have a top-level Above or Beside. +type RDoc = Doc + +-- | The TextDetails data type +-- +-- A TextDetails represents a fragment of text that will be +-- output at some point. +data TextDetails = Chr {-# UNPACK #-} !Char -- ^ A single Char fragment + | Str String -- ^ A whole String fragment + | PStr FastString -- a hashed string + | ZStr FastZString -- a z-encoded string + | LStr {-# UNPACK #-} !PtrString + -- a '\0'-terminated array of bytes + | RStr {-# UNPACK #-} !Int {-# UNPACK #-} !Char + -- a repeated character (e.g., ' ') + instance Show Doc where showsPrec _ doc cont = fullRender (mode style) (lineLength style) (ribbonsPerLine style) ===================================== compiler/GHC/Utils/Ppr/Colour.hs ===================================== @@ -1,5 +1,5 @@ module GHC.Utils.Ppr.Colour where -import Prelude +import GHC.Prelude.Basic import Data.Maybe (fromMaybe) import GHC.Data.Bool ===================================== compiler/GHC/Utils/Ppr/Doc.hs deleted ===================================== @@ -1,76 +0,0 @@ --- | This module contains some ppr internals which need to live in their own --- module to avoid module loops. --- Avoid importing it directly and instead import GHC.Utils.Ppr instead if --- possible. --- See Note [Exporting pprTrace from GHC.Prelude] - -module GHC.Utils.Ppr.Doc where - -import Prelude - -import GHC.Data.FastString.Type ( FastString, FastZString, PtrString ) --- --------------------------------------------------------------------------- --- The Doc data type - --- | The abstract type of documents. --- A Doc represents a *set* of layouts. A Doc with --- no occurrences of Union or NoDoc represents just one layout. -data Doc - = Empty -- empty - | NilAbove Doc -- text "" $$ x - | TextBeside !TextDetails {-# UNPACK #-} !Int Doc -- text s <> x - | Nest {-# UNPACK #-} !Int Doc -- nest k x - | Union Doc Doc -- ul `union` ur - | NoDoc -- The empty set of documents - | Beside Doc Bool Doc -- True <=> space between - | Above Doc Bool Doc -- True <=> never overlap - -{- -Here are the invariants: - -1) The argument of NilAbove is never Empty. Therefore - a NilAbove occupies at least two lines. - -2) The argument of @TextBeside@ is never @Nest at . - -3) The layouts of the two arguments of @Union@ both flatten to the same - string. - -4) The arguments of @Union@ are either @TextBeside@, or @NilAbove at . - -5) A @NoDoc@ may only appear on the first line of the left argument of an - union. Therefore, the right argument of an union can never be equivalent - to the empty set (@NoDoc@). - -6) An empty document is always represented by @Empty at . It can't be - hidden inside a @Nest@, or a @Union@ of two @Empty at s. - -7) The first line of every layout in the left argument of @Union@ is - longer than the first line of any layout in the right argument. - (1) ensures that the left argument has a first line. In view of - (3), this invariant means that the right argument must have at - least two lines. - -Notice the difference between - * NoDoc (no documents) - * Empty (one empty document; no height and no width) - * text "" (a document containing the empty string; - one line high, but has no width) --} - - --- | RDoc is a "reduced GDoc", guaranteed not to have a top-level Above or Beside. -type RDoc = Doc - --- | The TextDetails data type --- --- A TextDetails represents a fragment of text that will be --- output at some point. -data TextDetails = Chr {-# UNPACK #-} !Char -- ^ A single Char fragment - | Str String -- ^ A whole String fragment - | PStr FastString -- a hashed string - | ZStr FastZString -- a z-encoded string - | LStr {-# UNPACK #-} !PtrString - -- a '\0'-terminated array of bytes - | RStr {-# UNPACK #-} !Int {-# UNPACK #-} !Char - -- a repeated character (e.g., ' ') ===================================== compiler/GHC/Utils/Trace.hs ===================================== @@ -43,7 +43,7 @@ So we don't provide a boot-export for this function to avoid people using it accidentally. -} -import Prelude +import GHC.Prelude.Basic import GHC.Utils.Outputable import GHC.Utils.Exception import GHC.Utils.Panic ===================================== compiler/GHC/Utils/Trace.hs-boot ===================================== @@ -15,9 +15,10 @@ module GHC.Utils.Trace ) where -import Prelude -import GHC.Utils.Outputable.SDoc -import GHC.Utils.Exception +import GHC.Prelude.Basic + +import GHC.Utils.Outputable ( SDoc ) +import GHC.Utils.Exception ( ExceptionMonad ) import GHC.Stack import Debug.Trace (trace) ===================================== compiler/Setup.hs ===================================== @@ -116,7 +116,7 @@ generateConfigHs settings = either error id $ do , " , cStage" , " ) where" , "" - , "import GHC.Prelude" + , "import GHC.Prelude.Basic" , "" , "import GHC.Version" , "" ===================================== compiler/ghc.cabal.in ===================================== @@ -561,6 +561,7 @@ Library GHC.Platform.X86_64 GHC.Plugins GHC.Prelude + GHC.Prelude.Basic GHC.Rename.Bind GHC.Rename.Doc GHC.Rename.Env @@ -802,12 +803,10 @@ Library GHC.Utils.Monad GHC.Utils.Monad.State.Strict GHC.Utils.Outputable - GHC.Utils.Outputable.SDoc GHC.Utils.Panic GHC.Utils.Panic.Plain GHC.Utils.Ppr GHC.Utils.Ppr.Colour - GHC.Utils.Ppr.Doc GHC.Utils.TmpFs GHC.Utils.Trace ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -384,7 +384,7 @@ generateConfigHs = do , " , cStage" , " ) where" , "" - , "import GHC.Prelude" + , "import GHC.Prelude.Basic" , "" , "import GHC.Version" , "" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2f3727c4167263a5548f7ee3fd103cfc0cd35d33...95cd19f5c8332f2de3ca1057aac33971caaaafa6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2f3727c4167263a5548f7ee3fd103cfc0cd35d33...95cd19f5c8332f2de3ca1057aac33971caaaafa6 You're receiving 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 Nov 1 16:24:27 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 01 Nov 2022 12:24:27 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] Get rid of Data.FastString.Type Message-ID: <6361483b5ab12_815bc514283830a6@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: 8cc72d3e by Andreas Klebinger at 2022-11-01T17:20:51+01:00 Get rid of Data.FastString.Type - - - - - 5 changed files: - compiler/GHC/Data/FastString.hs - − compiler/GHC/Data/FastString/Type.hs - compiler/GHC/Types/Name/Occurrence.hs-boot - compiler/Language/Haskell/Syntax/Module/Name/Type.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Data/FastString.hs ===================================== @@ -8,7 +8,6 @@ {-# LANGUAGE UnliftedFFITypes #-} {-# OPTIONS_GHC -O2 -funbox-strict-fields #-} -{-# OPTIONS_GHC -Wno-orphans #-} -- See Note [Exporting pprTrace from GHC.Prelude] -- We always optimise this, otherwise performance of a non-optimised -- compiler is severely affected @@ -109,9 +108,7 @@ module GHC.Data.FastString lengthPS ) where -import GHC.Prelude.Basic - -import GHC.Data.FastString.Type +import GHC.Prelude.Basic as Prelude import GHC.Utils.Encoding import GHC.Utils.IO.Unsafe @@ -171,7 +168,9 @@ hashFastString :: FastString -> Int hashFastString fs = hashStr $ fs_sbs fs -- ----------------------------------------------------------------------------- --- FastZString + +newtype FastZString = FastZString ByteString + deriving NFData hPutFZS :: Handle -> FastZString -> IO () hPutFZS handle (FastZString bs) = BS.hPut handle bs @@ -187,7 +186,28 @@ mkFastZStringString :: String -> FastZString mkFastZStringString str = FastZString (BSC.pack str) -- ----------------------------------------------------------------------------- --- FastString + +{-| A 'FastString' is a UTF-8 encoded string together with a unique ID. All +'FastString's are stored in a global hashtable to support fast O(1) +comparison. + +It is also associated with a lazy reference to the Z-encoding +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_sbs :: {-# UNPACK #-} !ShortByteString, + fs_zenc :: FastZString + -- ^ Lazily computed Z-encoding of this string. See Note [Z-Encoding] in + -- GHC.Utils.Encoding. + -- + -- Since 'FastString's are globally memoized this is computed at most + -- once for any given string. + } + +instance Eq FastString where + f1 == f2 = uniq f1 == uniq f2 -- We don't provide any "Ord FastString" instance to force you to think about -- which ordering you want: @@ -633,6 +653,9 @@ hPutFS handle fs = BS.hPut handle $ bytesFS fs -- ----------------------------------------------------------------------------- -- PtrStrings, here for convenience only. +-- | A 'PtrString' is a pointer to some array of Latin-1 encoded chars. +data PtrString = PtrString !(Ptr Word8) !Int + -- | Wrap an unboxed address into a 'PtrString'. mkPtrString# :: Addr# -> PtrString {-# INLINE mkPtrString# #-} ===================================== compiler/GHC/Data/FastString/Type.hs deleted ===================================== @@ -1,99 +0,0 @@ -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE CPP #-} -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE DerivingStrategies #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE UnliftedFFITypes #-} - -{-# OPTIONS_GHC -O2 -funbox-strict-fields #-} --- We always optimise this, otherwise performance of a non-optimised --- compiler is severely affected - --- | --- There are two principal string types used internally by GHC: --- --- ['FastString'] --- --- * A compact, hash-consed, representation of character strings. --- * Generated by 'fsLit'. --- * You can get a 'GHC.Types.Unique.Unique' from them. --- * Equality test is O(1) (it uses the Unique). --- * Comparison is O(1) or O(n): --- * O(n) but deterministic with lexical comparison (`lexicalCompareFS`) --- * O(1) but non-deterministic with Unique comparison (`uniqCompareFS`) --- * Turn into 'GHC.Utils.Outputable.SDoc' with 'GHC.Utils.Outputable.ftext'. --- --- ['PtrString'] --- --- * Pointer and size of a Latin-1 encoded string. --- * Practically no operations. --- * Outputting them is fast. --- * Generated by 'mkPtrString#'. --- * Length of string literals (mkPtrString# "abc"#) is computed statically --- * Turn into 'GHC.Utils.Outputable.SDoc' with 'GHC.Utils.Outputable.ptext' --- * Requires manual memory management. --- Improper use may lead to memory leaks or dangling pointers. --- * It assumes Latin-1 as the encoding, therefore it cannot represent --- arbitrary Unicode strings. --- --- Use 'PtrString' unless you want the facilities of 'FastString'. -module GHC.Data.FastString.Type - ( - -- * FastZString - FastZString(..), - - -- * FastStrings - FastString(..), -- not abstract, for now. - - -- * PtrStrings - PtrString (..), - - ) where - -import GHC.Prelude.Basic - -import Control.DeepSeq -import Data.ByteString (ByteString) -import Data.ByteString.Short (ShortByteString) -#if !MIN_VERSION_bytestring(0,11,0) -import qualified Data.ByteString.Short.Internal as SBS -#endif - -import Data.Word -import Foreign - --- ----------------------------------------------------------------------------- - -newtype FastZString = FastZString ByteString - deriving NFData - --- ----------------------------------------------------------------------------- - -{-| A 'FastString' is a UTF-8 encoded string together with a unique ID. All -'FastString's are stored in a global hashtable to support fast O(1) -comparison. - -It is also associated with a lazy reference to the Z-encoding -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_sbs :: {-# UNPACK #-} !ShortByteString, - fs_zenc :: FastZString - -- ^ Lazily computed Z-encoding of this string. See Note [Z-Encoding] in - -- GHC.Utils.Encoding. - -- - -- Since 'FastString's are globally memoized this is computed at most - -- once for any given string. - } - -instance Eq FastString where - f1 == f2 = uniq f1 == uniq f2 - --- ----------------------------------------------------------------------------- - --- | A 'PtrString' is a pointer to some array of Latin-1 encoded chars. -data PtrString = PtrString !(Ptr Word8) !Int \ No newline at end of file ===================================== compiler/GHC/Types/Name/Occurrence.hs-boot ===================================== @@ -1,6 +1,6 @@ module GHC.Types.Name.Occurrence where -import GHC.Data.FastString.Type ( FastString ) +import GHC.Data.FastString ( FastString ) data OccName ===================================== compiler/Language/Haskell/Syntax/Module/Name/Type.hs ===================================== @@ -2,7 +2,7 @@ module Language.Haskell.Syntax.Module.Name.Type where import Prelude -import GHC.Data.FastString.Type ( FastString ) +import GHC.Data.FastString ( FastString ) -- | A ModuleName is essentially a simple string, e.g. @Data.List at . newtype ModuleName = ModuleName FastString deriving (Eq) \ No newline at end of file ===================================== compiler/ghc.cabal.in ===================================== @@ -370,7 +370,6 @@ Library GHC.Data.FastMutInt GHC.Data.FastString GHC.Data.FastString.Env - GHC.Data.FastString.Type GHC.Data.FiniteMap GHC.Data.Graph.Base GHC.Data.Graph.Color View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cc72d3e654f5d3fea585db95583b21f8c6fa6e8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cc72d3e654f5d3fea585db95583b21f8c6fa6e8 You're receiving 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 Nov 1 16:47:36 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 01 Nov 2022 12:47:36 -0400 Subject: [Git][ghc/ghc][master] Drop a kludge for binutils<2.17, which is now over 10 years old. Message-ID: <63614da8b8b33_815bc514c8395224@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 2 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs Changes: ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2928,25 +2928,10 @@ genSwitch expr targets = do let op = OpAddr (AddrBaseIndex (EABaseReg tableReg) (EAIndex reg (platformWordSizeInBytes platform)) (ImmInt 0)) - offsetReg <- getNewRegNat (intFormat (platformWordWidth platform)) - return $ if is32bit || os == OSDarwin - then e_code `appOL` t_code `appOL` toOL [ + return $ e_code `appOL` t_code `appOL` toOL [ ADD (intFormat (platformWordWidth platform)) op (OpReg tableReg), JMP_TBL (OpReg tableReg) ids rosection lbl ] - else -- HACK: On x86_64 binutils<2.17 is only able to generate - -- PC32 relocations, hence we only get 32-bit offsets in - -- the jump table. As these offsets are always negative - -- we need to properly sign extend them to 64-bit. This - -- hack should be removed in conjunction with the hack in - -- PprMach.hs/pprDataItem once binutils 2.17 is standard. - e_code `appOL` t_code `appOL` toOL [ - MOVSxL II32 op (OpReg offsetReg), - ADD (intFormat (platformWordWidth platform)) - (OpReg offsetReg) - (OpReg tableReg), - JMP_TBL (OpReg tableReg) ids rosection lbl - ] else do (reg,e_code) <- getSomeReg indexExpr lbl <- getNewLabelNat ===================================== compiler/GHC/CmmToAsm/X86/Ppr.hs ===================================== @@ -532,29 +532,7 @@ pprDataItem config lit <> int (fromIntegral (fromIntegral (x `shiftR` 32) :: Word32))] _ -> panic "X86.Ppr.ppr_item: no match for II64" - | otherwise -> - [text "\t.quad\t" <> pprImm platform imm] - _ - | target32Bit platform -> - [text "\t.quad\t" <> pprImm platform imm] - | otherwise -> - -- x86_64: binutils can't handle the R_X86_64_PC64 - -- relocation type, which means we can't do - -- pc-relative 64-bit addresses. Fortunately we're - -- assuming the small memory model, in which all such - -- offsets will fit into 32 bits, so we have to stick - -- to 32-bit offset fields and modify the RTS - -- appropriately - -- - -- See Note [x86-64-relative] in rts/include/rts/storage/InfoTables.h - -- - case lit of - -- A relative relocation: - CmmLabelDiffOff _ _ _ _ -> - [text "\t.long\t" <> pprImm platform imm, - text "\t.long\t0"] - _ -> - [text "\t.quad\t" <> pprImm platform imm] + _ -> [text "\t.quad\t" <> pprImm platform imm] asmComment :: SDoc -> SDoc View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d45d8cb3d9bce11729b840bc96ec4616f559809e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d45d8cb3d9bce11729b840bc96ec4616f559809e You're receiving 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 Nov 1 16:48:14 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 01 Nov 2022 12:48:14 -0400 Subject: [Git][ghc/ghc][master] 3 commits: rts: `name` argument of `createOSThread` can be `const` Message-ID: <63614dce49e92_815bc515683990cb@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - 4 changed files: - rts/include/rts/OSThreads.h - rts/posix/OSThreads.c - rts/posix/ticker/Pthread.c - rts/win32/OSThreads.c Changes: ===================================== rts/include/rts/OSThreads.h ===================================== @@ -173,8 +173,12 @@ extern void yieldThread ( void ); typedef void* OSThreadProcAttr OSThreadProc(void *); -extern int createOSThread ( OSThreadId* tid, char *name, +extern int createOSThread ( OSThreadId* tid, const char *name, OSThreadProc *startProc, void *param); +#if !defined(mingw32_HOST_OS) +extern int createAttachedOSThread( OSThreadId *tid, const char *name, + OSThreadProc *startProc, void *param); +#endif extern bool osThreadIsAlive ( OSThreadId id ); extern void interruptOSThread ( OSThreadId id ); extern void joinOSThread ( OSThreadId id ); ===================================== rts/posix/OSThreads.c ===================================== @@ -198,35 +198,50 @@ struct ThreadDesc { static void * start_thread (void *param) { - struct ThreadDesc desc = *(struct ThreadDesc *) param; - stgFree(param); + struct ThreadDesc *desc = (struct ThreadDesc *) param; + OSThreadProc *startProc = desc->startProc; + void *startParam = desc->param; #if defined(HAVE_PTHREAD_SET_NAME_NP) - pthread_set_name_np(pthread_self(), desc.name); + pthread_set_name_np(pthread_self(), desc->name); #elif defined(HAVE_PTHREAD_SETNAME_NP) - pthread_setname_np(pthread_self(), desc.name); + pthread_setname_np(pthread_self(), desc->name); #elif defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) - pthread_setname_np(desc.name); + pthread_setname_np(desc->name); #elif defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) - pthread_setname_np(pthread_self(), "%s", desc.name); + pthread_setname_np(pthread_self(), "%s", desc->name); #endif - return desc.startProc(desc.param); + stgFree(desc->name); + stgFree(desc); + + return startProc(startParam); } int -createOSThread (OSThreadId* pId, char *name STG_UNUSED, +createOSThread (OSThreadId* pId, const char *name, OSThreadProc *startProc, void *param) { - struct ThreadDesc *desc = stgMallocBytes(sizeof(struct ThreadDesc), "createOSThread"); + int result = createAttachedOSThread(pId, name, startProc, param); + if (!result) { + pthread_detach(*pId); + } + return result; +} + +int +createAttachedOSThread (OSThreadId *pId, const char *name, + OSThreadProc *startProc, void *param) +{ + struct ThreadDesc *desc = stgMallocBytes(sizeof(struct ThreadDesc), "createAttachedOSThread"); desc->startProc = startProc; desc->param = param; - desc->name = name; + desc->name = stgMallocBytes(strlen(name) + 1, "createAttachedOSThread"); + strcpy(desc->name, name); int result = pthread_create(pId, NULL, start_thread, desc); - if (!result) { - pthread_detach(*pId); - } else { + if (result) { + stgFree(desc->name); stgFree(desc); } return result; ===================================== rts/posix/ticker/Pthread.c ===================================== @@ -188,15 +188,6 @@ initTicker (Time interval, TickProc handle_tick) #endif /* - * We can't use the RTS's createOSThread here as we need to remain attached - * to the thread we create so we can later join to it if requested - * - * On FreeBSD 12.2 pthread_set_name_np() is unconditionally declared in - * , while pthread_setname_np() is conditionally declared in - * when _POSIX_SOURCE is not defined, but we're including - * , so must use pthread_set_name_np() instead. See - * similar code in "rts/posix/OSThreads.c". - * * Create the thread with all blockable signals blocked, leaving signal * handling to the main and/or other threads. This is especially useful in * the non-threaded runtime, where applications might expect sigprocmask(2) @@ -206,23 +197,13 @@ initTicker (Time interval, TickProc handle_tick) sigfillset(&mask); sigret = pthread_sigmask(SIG_SETMASK, &mask, &omask); #endif - ret = pthread_create(&thread, NULL, itimer_thread_func, (void*)handle_tick); + ret = createAttachedOSThread(&thread, "ghc_ticker", itimer_thread_func, (void*)handle_tick); #if defined(HAVE_SIGNAL_H) if (sigret == 0) pthread_sigmask(SIG_SETMASK, &omask, NULL); #endif - if (ret == 0) { -#if defined(HAVE_PTHREAD_SET_NAME_NP) - pthread_set_name_np(thread, "ghc_ticker"); -#elif defined(HAVE_PTHREAD_SETNAME_NP) - pthread_setname_np(thread, "ghc_ticker"); -#elif defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) - pthread_setname_np("ghc_ticker"); -#elif defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) - pthread_setname_np(thread, "%s", "ghc_ticker"); -#endif - } else { + if (ret != 0) { barf("Ticker: Failed to spawn thread: %s", strerror(errno)); } } ===================================== rts/win32/OSThreads.c ===================================== @@ -42,7 +42,7 @@ shutdownThread() } int -createOSThread (OSThreadId* pId, char *name STG_UNUSED, +createOSThread (OSThreadId* pId, const char *name STG_UNUSED, OSThreadProc *startProc, void *param) { HANDLE h; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d45d8cb3d9bce11729b840bc96ec4616f559809e...edd175c9f9f2988e2836fc3bdc70d627f0f0c5cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d45d8cb3d9bce11729b840bc96ec4616f559809e...edd175c9f9f2988e2836fc3bdc70d627f0f0c5cf You're receiving 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 Nov 1 16:48:52 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 01 Nov 2022 12:48:52 -0400 Subject: [Git][ghc/ghc][master] Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core Message-ID: <63614df414ade_815bc51568402524@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 5 changed files: - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Unit/Module/WholeCoreBindings.hs - docs/users_guide/phases.rst - testsuite/tests/driver/fat-iface/Makefile Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -867,7 +867,7 @@ hscRecompStatus -- If missing object code, just say we need to recompile because of object code. (_, OutOfDateItem reason _) -> OutOfDateItem reason Nothing -- If just missing byte code, just use the object code - -- so you should use -fprefer-byte-code with -fwrite-if-simplfied-core or you'll + -- so you should use -fprefer-byte-code with -fwrite-if-simplified-core or you'll -- end up using bytecode on recompilation (_, UpToDateItem {} ) -> just_o @@ -876,7 +876,7 @@ hscRecompStatus -- If missing object code, just say we need to recompile because of object code. (_, OutOfDateItem reason _) -> OutOfDateItem reason Nothing -- If just missing byte code, just use the object code - -- so you should use -fprefer-byte-code with -fwrite-if-simplfied-core or you'll + -- so you should use -fprefer-byte-code with -fwrite-if-simplified-core or you'll -- end up using bytecode on recompilation (OutOfDateItem reason _, _ ) -> OutOfDateItem reason Nothing @@ -1129,7 +1129,7 @@ hscDesugarAndSimplify summary (FrontendTypecheck tc_result) tc_warnings mb_old_h return $ HscUpdate iface - -- We are not generating code or writing an interface with simplfied core so we can skip simplification + -- We are not generating code or writing an interface with simplified core so we can skip simplification -- and generate a simple interface. _ -> do (iface, _details) <- liftIO $ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -3481,7 +3481,7 @@ fFlagsDeps = [ flagSpec "strictness" Opt_Strictness, flagSpec "use-rpaths" Opt_RPath, flagSpec "write-interface" Opt_WriteInterface, - flagSpec "write-if-simplfied-core" Opt_WriteIfSimplifiedCore, + flagSpec "write-if-simplified-core" Opt_WriteIfSimplifiedCore, flagSpec "write-ide-info" Opt_WriteHie, flagSpec "unbox-small-strict-fields" Opt_UnboxSmallStrictFields, flagSpec "unbox-strict-fields" Opt_UnboxStrictFields, ===================================== compiler/GHC/Unit/Module/WholeCoreBindings.hs ===================================== @@ -34,7 +34,7 @@ The lifecycle of a WholeCoreBindings typically proceeds as follows: 3. Then when bytecode is needed, the LoadedBCOs value is inspected and unpacked and the linkable is used as before. -The flag `-fwrite-if-simplfied-core` determines whether the extra information is written +The flag `-fwrite-if-simplified-core` determines whether the extra information is written to an interface file. The program which is written is the core bindings of the module after whatever simplification the user requested has been performed. So the simplified core bindings of the interface file agree with the optimisation level as reported by the interface @@ -43,7 +43,7 @@ file. Note [Size of Interface Files with Core Definitions] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -How much overhead does `-fwrite-if-simplfied-core` add to a typical interface file? +How much overhead does `-fwrite-if-simplified-core` add to a typical interface file? As an experiment I compiled the `Cabal` library and `ghc` library (Aug 22) with | Project | .hi | .hi (fat) | .o | ===================================== docs/users_guide/phases.rst ===================================== @@ -641,7 +641,7 @@ Options affecting code generation useful if you want to type check over multiple runs of GHC without compiling dependencies. -.. ghc-flag:: -fwrite-if-simplfied-core +.. ghc-flag:: -fwrite-if-simplified-core :shortdesc: Write an interface file containing the simplified core of the module. :type: dynamic :category: codegen @@ -679,9 +679,9 @@ Options affecting code generation :category: codegen Generate object code and byte-code. This is useful with the flags - :ghc-flag:`-fprefer-byte-code` and :ghc-flag:`-fwrite-if-simplfied-core`. + :ghc-flag:`-fprefer-byte-code` and :ghc-flag:`-fwrite-if-simplified-core`. - This flag implies :ghc-flag:`-fwrite-if-simplfied-core`. + This flag implies :ghc-flag:`-fwrite-if-simplified-core`. :ghc-flag:`-fbyte-code` and :ghc-flag:`-fobject-code` disable this flag as they specify that GHC should *only* write object code or byte-code respectively. @@ -787,7 +787,7 @@ Options affecting code generation and object file (if that's available) to evaluate and run TH splices. This is useful with flags such as :ghc-flag:`-fbyte-code-and-object-code`, which - tells the compiler to generate byte-code, and :ghc-flag:`-fwrite-if-simplfied-core` which + tells the compiler to generate byte-code, and :ghc-flag:`-fwrite-if-simplified-core` which allows byte-code to be generated from an interface file. This flag also interacts with :ghc-flag:`-fno-code`, if this flag is enabled ===================================== testsuite/tests/driver/fat-iface/Makefile ===================================== @@ -8,7 +8,7 @@ clean: rm -f *.hi *.hi-fat *.o fat001: clean - "$(TEST_HC)" $(TEST_HC_OPTS) -c Fat.hs -fwrite-if-simplfied-core -dno-typeable-binds + "$(TEST_HC)" $(TEST_HC_OPTS) -c Fat.hs -fwrite-if-simplified-core -dno-typeable-binds test -f Fat.hi "$(TEST_HC)" $(TEST_HC_OPTS) --show-iface Fat.hi | grep -A3 "extra decls" @@ -23,30 +23,30 @@ fat007: clean fat006: clean - "$(TEST_HC)" $(TEST_HC_OPTS) -c Fat.hs -dno-typeable-binds -fno-code -fwrite-if-simplfied-core + "$(TEST_HC)" $(TEST_HC_OPTS) -c Fat.hs -dno-typeable-binds -fno-code -fwrite-if-simplified-core test -f Fat.hi "$(TEST_HC)" $(TEST_HC_OPTS) --show-iface Fat.hi | grep -A3 "extra decls" test ! -f Fat.o fat006a: clean - "$(TEST_HC)" $(TEST_HC_OPTS) -c Fat.hs -dno-typeable-binds -fno-code -fwrite-if-simplfied-core -O2 + "$(TEST_HC)" $(TEST_HC_OPTS) -c Fat.hs -dno-typeable-binds -fno-code -fwrite-if-simplified-core -O2 fat008: clean - "$(TEST_HC)" $(TEST_HC_OPTS) FatTH.hs -fwrite-if-simplfied-core -fprefer-byte-code + "$(TEST_HC)" $(TEST_HC_OPTS) FatTH.hs -fwrite-if-simplified-core -fprefer-byte-code echo >> "FatTH.hs" # Observe that FatQuote.hs is not recompiled and the fat interface is used. - "$(TEST_HC)" $(TEST_HC_OPTS) FatTH.hs -fwrite-if-simplfied-core -fprefer-byte-code + "$(TEST_HC)" $(TEST_HC_OPTS) FatTH.hs -fwrite-if-simplified-core -fprefer-byte-code # Same as fat008 but with ghci, broken due to recompilation checking wibbles fat009: clean - echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) FatTH.hs -fwrite-if-simplfied-core - echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) FatTH.hs -fwrite-if-simplfied-core + echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) FatTH.hs -fwrite-if-simplified-core + echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) FatTH.hs -fwrite-if-simplified-core fat010: clean - "$(TEST_HC)" $(TEST_HC_OPTS) THC.hs -fhide-source-paths -fwrite-if-simplfied-core -fprefer-byte-code + "$(TEST_HC)" $(TEST_HC_OPTS) THC.hs -fhide-source-paths -fwrite-if-simplified-core -fprefer-byte-code echo >> "THB.hs" - "$(TEST_HC)" $(TEST_HC_OPTS) THC.hs -fhide-source-paths -fwrite-if-simplfied-core -fprefer-byte-code + "$(TEST_HC)" $(TEST_HC_OPTS) THC.hs -fhide-source-paths -fwrite-if-simplified-core -fprefer-byte-code View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b7a001132202e1ebf03dd21c6c7b4cd7a24df501 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b7a001132202e1ebf03dd21c6c7b4cd7a24df501 You're receiving 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 Nov 1 16:49:26 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 01 Nov 2022 12:49:26 -0400 Subject: [Git][ghc/ghc][master] ThToHs: fix overzealous parenthesization Message-ID: <63614e1661eb9_815bc515a44061d8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 7 changed files: - compiler/GHC/ThToHs.hs - testsuite/tests/th/T13776.stderr - testsuite/tests/th/T14681.stderr - testsuite/tests/th/T17608.stderr - + testsuite/tests/th/TH_fun_par.hs - + testsuite/tests/th/TH_fun_par.stderr - testsuite/tests/th/all.T Changes: ===================================== compiler/GHC/ThToHs.hs ===================================== @@ -979,17 +979,13 @@ cvtl e = wrapLA (cvt e) l' <- cvt_lit l let e' = mk_expr l' if is_compound_lit l' then wrapParLA gHsPar e' else pure e' - cvt (AppE x@(LamE _ _) y) = do { x' <- cvtl x; y' <- cvtl y - ; return $ HsApp noComments (mkLHsPar x') - (mkLHsPar y')} - cvt (AppE x y) = do { x' <- cvtl x; y' <- cvtl y - ; return $ HsApp noComments (mkLHsPar x') - (mkLHsPar y')} - cvt (AppTypeE e t) = do { e' <- cvtl e - ; t' <- cvtType t - ; let tp = parenthesizeHsType appPrec t' + cvt (AppE e1 e2) = do { e1' <- parenthesizeHsExpr opPrec <$> cvtl e1 + ; e2' <- parenthesizeHsExpr appPrec <$> cvtl e2 + ; return $ HsApp noComments e1' e2' } + cvt (AppTypeE e t) = do { e' <- parenthesizeHsExpr opPrec <$> cvtl e + ; t' <- parenthesizeHsType appPrec <$> cvtType t ; return $ HsAppType noExtField e' noHsTok - $ mkHsWildCardBndrs tp } + $ mkHsWildCardBndrs t' } cvt (LamE [] e) = cvt e -- Degenerate case. We convert the body as its -- own expression to avoid pretty-printing -- oddities that can result from zero-argument ===================================== testsuite/tests/th/T13776.stderr ===================================== @@ -5,7 +5,7 @@ T13776.hs:7:15-62: Splicing type T13776.hs:14:15-75: Splicing expression conE '(,) `appE` litE (integerL 1) `appE` litE (integerL 1) ======> - ((,) 1) 1 + (,) 1 1 T13776.hs:17:15-24: Splicing expression conE '[] ======> [] T13776.hs:20:13-62: Splicing pattern conP '(,) [litP (integerL 1), litP (integerL 1)] ======> (,) 1 1 ===================================== testsuite/tests/th/T14681.stderr ===================================== @@ -8,4 +8,4 @@ T14681.hs:(8,2)-(9,63): Splicing declarations $ VarE '(+) `AppE` LitE (IntegerL (- 1)) `AppE` (LitE (IntegerL (- 1)))>] ======> - g = ((+) (-1)) (-1) + g = (+) (-1) (-1) ===================================== testsuite/tests/th/T17608.stderr ===================================== @@ -24,7 +24,7 @@ T17608.hs:(4,2)-(20,7): Splicing declarations infixl 4 `h` h :: () -> Bool -> Bool h _ _ = True - in (h ()) ((g ()) ()) + in h () (g () ()) where infixl 4 `g` g :: () -> () -> Bool ===================================== testsuite/tests/th/TH_fun_par.hs ===================================== @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskell #-} + +module TH_fun_par where + +import Data.Foldable (for_) +import System.IO +import Language.Haskell.TH + +do let eLam = [e| \a b -> (b,a) |] + eOp = [e| even . length |] + e1 <- [e| const @Int @Bool (1 + 2) True |] + e2 <- [e| $eLam (Just 'x') False |] + e3 <- [e| $eOp "Hello" |] + for_ [e1, e2, e3] $ \e -> do + runIO $ hPutStrLn stderr $ pprint e + return [] ===================================== testsuite/tests/th/TH_fun_par.stderr ===================================== @@ -0,0 +1,3 @@ +GHC.Base.const @GHC.Types.Int @GHC.Types.Bool (1 GHC.Num.+ 2) GHC.Types.True +(\a_0 b_1 -> (b_1, a_0)) (GHC.Maybe.Just 'x') GHC.Types.False +(GHC.Real.even GHC.Base.. Data.Foldable.length) "Hello" ===================================== testsuite/tests/th/all.T ===================================== @@ -555,3 +555,4 @@ test('Lift_ByteArray', normal, compile_and_run, ['']) test('T21920', normal, compile_and_run, ['']) test('T21723', normal, compile_and_run, ['']) test('T21942', normal, compile_and_run, ['']) +test('TH_fun_par', normal, compile, ['']) \ No newline at end of file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30e625e6d4bdd15960edce8ecc40b85ce3d72b28 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30e625e6d4bdd15960edce8ecc40b85ce3d72b28 You're receiving 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 Nov 1 16:50:04 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 01 Nov 2022 12:50:04 -0400 Subject: [Git][ghc/ghc][master] Add accurate skolem info when quantifying Message-ID: <63614e3ccc2c1_815bc515a440976a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 9 changed files: - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - testsuite/tests/deriving/should_fail/T21871.stderr - testsuite/tests/indexed-types/should_fail/T15870.stderr - + testsuite/tests/polykinds/T22379a.hs - + testsuite/tests/polykinds/T22379b.hs - testsuite/tests/polykinds/all.T Changes: ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -3489,6 +3489,8 @@ bindTyClTyVars tycon_name thing_inside bindTyClTyVarsAndZonk :: Name -> ([TyConBinder] -> Kind -> TcM a) -> TcM a -- Like bindTyClTyVars, but in addition -- zonk the skolem TcTyVars of a PolyTcTyCon to TyVars +-- We always do this same zonking after a call to bindTyClTyVars, but +-- here we do it right away because there are no more unifications to come bindTyClTyVarsAndZonk tycon_name thing_inside = bindTyClTyVars tycon_name $ \ tc_bndrs tc_kind -> do { ze <- mkEmptyZonkEnv NoFlexi ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -411,21 +411,27 @@ TcTyCons are used for two distinct purposes 2. When checking a type/class declaration (in module GHC.Tc.TyCl), we come upon knowledge of the eventual tycon in bits and pieces, and we use a TcTyCon to record what we know before we are ready to build the - final TyCon. + final TyCon. Here is the plan: - We first build a MonoTcTyCon, then generalise to a PolyTcTyCon - See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType - Specifically: + Step 1 (inferInitialKinds, inference only, skipped for checking): + Make a MonoTcTyCon whose binders are TcTyVars, + which may contain free unification variables - S1) In kcTyClGroup, we use checkInitialKinds to get the - utterly-final Kind of all TyCons in the group that - (a) have a kind signature or - (b) have a CUSK. - This produces a PolyTcTyCon, that is, a TcTyCon in which the binders - and result kind are full of TyVars (not TcTyVars). No unification - variables here; everything is in its final form. + Step 2 (generaliseTcTyCon) + Generalise that MonoTcTyCon to make a PolyTcTyCon + Its binders are skolem TcTyVars, with accurate SkolemInfo + + Step 3 (tcTyClDecl) + Typecheck the type and class decls to produce a final TyCon + Its binders are final TyVars, not TcTyVars + + Note that a MonoTcTyCon can contain unification variables, + but a PolyTcTyCon does not: only skolem TcTyVars. See + Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType + + More details about /kind inference/: - S2) In kcTyClGroup, we use inferInitialKinds to look over the + S1) In kcTyClGroup, we use inferInitialKinds to look over the declaration of any TyCon that lacks a kind signature or CUSK, to determine its "shape"; for example, the number of parameters, and any kind signatures. @@ -434,27 +440,30 @@ TcTyCons are used for two distinct purposes "mono" because it has not been been generalised, and its binders and result kind may have free unification variables. - S3) Still in kcTyClGroup, we use kcLTyClDecl to kind-check the + S2) Still in kcTyClGroup, we use kcLTyClDecl to kind-check the body (class methods, data constructors, etc.) of each of these MonoTcTyCons, which has the effect of filling in the metavariables in the tycon's initial kind. - S4) Still in kcTyClGroup, we use generaliseTyClDecl to generalize - each MonoTcTyCon to get a PolyTcTyCon, with final TyVars in it, + S3) Still in kcTyClGroup, we use generaliseTyClDecl to generalize + each MonoTcTyCon to get a PolyTcTyCon, with skolem TcTyVars in it, and a final, fixed kind. - S5) Finally, back in TcTyClDecls, we extend the environment with + S4) Finally, back in TcTyClDecls, we extend the environment with the PolyTcTyCons, and typecheck each declaration (regardless of kind signatures etc) to get final TyCon. - These TcTyCons are stored in the local environment in GHC.Tc.TyCl, - until the real full TyCons can be created during desugaring. A - desugared program should never have a TcTyCon. + More details about /kind checking/ -3. A MonoTcTyCon can contain unification variables, but a PolyTcTyCon - does not: only skolem TcTyVars. + S5) In kcTyClGroup, we use checkInitialKinds to get the + utterly-final Kind of all TyCons in the group that + (a) have a separate kind signature or + (b) have a CUSK. + This produces a PolyTcTyCon, that is, a TcTyCon in which the binders + and result kind are full of TyVars (not TcTyVars). No unification + variables here; everything is in its final form. -4. tyConScopedTyVars. A challenging piece in all of this is that we +3. tyConScopedTyVars. A challenging piece in all of this is that we end up taking three separate passes over every declaration: - one in inferInitialKind (this pass look only at the head, not the body) - one in kcTyClDecls (to kind-check the body) @@ -2425,15 +2434,15 @@ tcClassDecl1 :: RolesInfo -> Name -> Maybe (LHsContext GhcRn) -> TcM Class tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs = fixM $ \ clas -> -- We need the knot because 'clas' is passed into tcClassATs - bindTyClTyVars class_name $ \ binders res_kind -> + bindTyClTyVars class_name $ \ tc_bndrs res_kind -> do { checkClassKindSig res_kind - ; traceTc "tcClassDecl 1" (ppr class_name $$ ppr binders) + ; traceTc "tcClassDecl 1" (ppr class_name $$ ppr tc_bndrs) ; let tycon_name = class_name -- We use the same name roles = roles_info tycon_name -- for TyCon and Class ; (ctxt, fds, sig_stuff, at_stuff) - <- pushLevelAndSolveEqualities skol_info binders $ - -- The (binderVars binders) is needed bring into scope the + <- pushLevelAndSolveEqualities skol_info tc_bndrs $ + -- The (binderVars tc_bndrs) is needed bring into scope the -- skolems bound by the class decl header (#17841) do { ctxt <- tcHsContext hs_ctxt ; fds <- mapM (addLocMA tc_fundep) fundeps @@ -2458,9 +2467,10 @@ tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs -- any unfilled coercion variables unless there is such an error -- The zonk also squeeze out the TcTyCons, and converts -- Skolems to tyvars. - ; ze <- mkEmptyZonkEnv NoFlexi - ; ctxt <- zonkTcTypesToTypesX ze ctxt - ; sig_stuff <- mapM (zonkTcMethInfoToMethInfoX ze) sig_stuff + ; ze <- mkEmptyZonkEnv NoFlexi + ; (ze, bndrs) <- zonkTyVarBindersX ze tc_bndrs -- From TcTyVars to TyVars + ; ctxt <- zonkTcTypesToTypesX ze ctxt + ; sig_stuff <- mapM (zonkTcMethInfoToMethInfoX ze) sig_stuff -- ToDo: do we need to zonk at_stuff? -- TODO: Allow us to distinguish between abstract class, @@ -2482,8 +2492,8 @@ tcClassDecl1 roles_info class_name hs_ctxt meths fundeps sigs ats at_defs | otherwise = Just (ctxt, at_stuff, sig_stuff, mindef) - ; clas <- buildClass class_name binders roles fds body - ; traceTc "tcClassDecl" (ppr fundeps $$ ppr binders $$ + ; clas <- buildClass class_name bndrs roles fds body + ; traceTc "tcClassDecl" (ppr fundeps $$ ppr bndrs $$ ppr fds) ; return clas } where @@ -2712,7 +2722,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info , fdResultSig = L _ sig , fdInjectivityAnn = inj }) | DataFamily <- fam_info - = bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> do + = bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> do { traceTc "tcFamDecl1 data family:" (ppr tc_name) ; checkFamFlag tc_name @@ -2729,8 +2739,8 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info -- See also Note [Datatype return kinds] ; checkDataKindSig DataFamilySort res_kind ; tc_rep_name <- newTyConRepName tc_name - ; let inj = Injective $ replicate (length binders) True - tycon = mkFamilyTyCon tc_name binders + ; let inj = Injective $ replicate (length tc_bndrs) True + tycon = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) (DataFamilyTyCon tc_rep_name) @@ -2738,12 +2748,12 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info ; return tycon } | OpenTypeFamily <- fam_info - = bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> do + = bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> do { traceTc "tcFamDecl1 open type family:" (ppr tc_name) ; checkFamFlag tc_name - ; inj' <- tcInjectivity binders inj + ; inj' <- tcInjectivity tc_bndrs inj ; checkResultSigFlag tc_name sig -- check after injectivity for better errors - ; let tycon = mkFamilyTyCon tc_name binders res_kind + ; let tycon = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) OpenSynFamilyTyCon parent inj' ; return tycon } @@ -2754,10 +2764,10 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info do { traceTc "tcFamDecl1 Closed type family:" (ppr tc_name) -- the variables in the header scope only over the injectivity -- declaration but this is not involved here - ; (inj', binders, res_kind) - <- bindTyClTyVarsAndZonk tc_name $ \ binders res_kind -> - do { inj' <- tcInjectivity binders inj - ; return (inj', binders, res_kind) } + ; (inj', tc_bndrs, res_kind) + <- bindTyClTyVarsAndZonk tc_name $ \ tc_bndrs res_kind -> + do { inj' <- tcInjectivity tc_bndrs inj + ; return (inj', tc_bndrs, res_kind) } ; checkFamFlag tc_name -- make sure we have -XTypeFamilies ; checkResultSigFlag tc_name sig @@ -2766,14 +2776,14 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info -- but eqns might be empty in the Just case as well ; case mb_eqns of Nothing -> - return $ mkFamilyTyCon tc_name binders res_kind + return $ mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) AbstractClosedSynFamilyTyCon parent inj' Just eqns -> do { -- Process the equations, creating CoAxBranches - ; let tc_fam_tc = mkTcTyCon tc_name binders res_kind + ; let tc_fam_tc = mkTcTyCon tc_name tc_bndrs res_kind noTcTyConScopedTyVars False {- this doesn't matter here -} ClosedTypeFamilyFlavour @@ -2792,7 +2802,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info | null eqns = Nothing -- mkBranchedCoAxiom fails on empty list | otherwise = Just (mkBranchedCoAxiom co_ax_name fam_tc branches) - fam_tc = mkFamilyTyCon tc_name binders res_kind (resultVariableName sig) + fam_tc = mkFamilyTyCon tc_name tc_bndrs res_kind (resultVariableName sig) (ClosedSynFamilyTyCon mb_co_ax) parent inj' -- We check for instance validity later, when doing validity @@ -2853,10 +2863,10 @@ tcInjectivity tcbs (Just (L loc (InjectivityAnn _ _ lInjNames))) tcTySynRhs :: RolesInfo -> Name -> LHsType GhcRn -> TcM TyCon tcTySynRhs roles_info tc_name hs_ty - = bindTyClTyVars tc_name $ \ binders res_kind -> + = bindTyClTyVars tc_name $ \ tc_bndrs res_kind -> do { env <- getLclEnv ; traceTc "tc-syn" (ppr tc_name $$ ppr (tcl_env env)) - ; rhs_ty <- pushLevelAndSolveEqualities skol_info binders $ + ; rhs_ty <- pushLevelAndSolveEqualities skol_info tc_bndrs $ tcCheckLHsType hs_ty (TheKind res_kind) -- See Note [Error on unconstrained meta-variables] in GHC.Tc.Utils.TcMType @@ -2870,11 +2880,11 @@ tcTySynRhs roles_info tc_name hs_ty , ppr rhs_ty ] ) } ; doNotQuantifyTyVars dvs mk_doc - ; ze <- mkEmptyZonkEnv NoFlexi - ; (ze, binders) <- zonkTyVarBindersX ze binders - ; rhs_ty <- zonkTcTypeToTypeX ze rhs_ty + ; ze <- mkEmptyZonkEnv NoFlexi + ; (ze, bndrs) <- zonkTyVarBindersX ze tc_bndrs + ; rhs_ty <- zonkTcTypeToTypeX ze rhs_ty ; let roles = roles_info tc_name - ; return (buildSynTyCon tc_name binders res_kind roles rhs_ty) } + ; return (buildSynTyCon tc_name bndrs res_kind roles rhs_ty) } where skol_info = TyConSkol TypeSynonymFlavour tc_name ===================================== compiler/GHC/Tc/Utils/TcMType.hs ===================================== @@ -1735,12 +1735,6 @@ quantifyTyVars skol_info ns_strat dvs = return Nothing -- this can happen for a covar that's associated with -- a coercion hole. Test case: typecheck/should_compile/T2494 --- Omit: no TyVars now --- | not (isTcTyVar tkv) --- = return (Just tkv) -- For associated types in a class with a standalone --- -- kind signature, we have the class variables in --- -- scope, and they are TyVars not TcTyVars - | otherwise = Just <$> skolemiseQuantifiedTyVar skol_info tkv @@ -1785,13 +1779,19 @@ skolemiseQuantifiedTyVar :: SkolemInfo -> TcTyVar -> TcM TcTyVar skolemiseQuantifiedTyVar skol_info tv = case tcTyVarDetails tv of - SkolemTv {} -> do { kind <- zonkTcType (tyVarKind tv) - ; return (setTyVarKind tv kind) } - -- It might be a skolem type variable, - -- for example from a user type signature - MetaTv {} -> skolemiseUnboundMetaTyVar skol_info tv + SkolemTv _ lvl _ -- It might be a skolem type variable, + -- for example from a user type signature + -- But it might also be a shared meta-variable across several + -- type declarations, each with its own skol_info. The first + -- will skolemise it, but the other uses must update its + -- skolem info (#22379) + -> do { kind <- zonkTcType (tyVarKind tv) + ; let details = SkolemTv skol_info lvl False + name = tyVarName tv + ; return (mkTcTyVar name kind details) } + _other -> pprPanic "skolemiseQuantifiedTyVar" (ppr tv) -- RuntimeUnk -- | Default a type variable using the given defaulting strategy. ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -428,7 +428,7 @@ Invariants: - Flag tcTyConIsPoly = True; this is used only to short-cut zonking - tyConBinders are still TcTyConBinders, but they are /skolem/ TcTyVars, - with fixed kinds: no unification variables here + with fixed kinds, and accurate skolem info: no unification variables here tyConBinders includes the Inferred binders if any ===================================== testsuite/tests/deriving/should_fail/T21871.stderr ===================================== @@ -3,7 +3,7 @@ T21871.hs:13:36: error: [GHC-25897] • Couldn't match kind ‘k’ with ‘*’ Expected kind ‘* -> *’, but ‘m’ has kind ‘k -> *’ ‘k’ is a rigid type variable bound by - the newtype declaration for ‘FooT’ + a `deriving' clause at T21871.hs:(10,1)-(13,36) • In the second argument of ‘ReaderT’, namely ‘m’ In the newtype declaration for ‘FooT’ ===================================== testsuite/tests/indexed-types/should_fail/T15870.stderr ===================================== @@ -3,7 +3,7 @@ T15870.hs:32:34: error: [GHC-25897] • Couldn't match kind ‘k’ with ‘*’ Expected kind ‘Optic @{k} a’, but ‘g2’ has kind ‘Optic @{*} b’ ‘k’ is a rigid type variable bound by - the instance declaration + a family instance declaration at T15870.hs:(27,1)-(32,35) • In the second argument of ‘Get’, namely ‘g2’ In the type ‘Get a g2’ ===================================== testsuite/tests/polykinds/T22379a.hs ===================================== @@ -0,0 +1,31 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind +import Data.Proxy (Proxy) + +data Delayed (env :: Type) (c :: Type) +data Handler (a :: Type) +data Router (a :: Type) + +-- class decl, then type decl + +class HasServer api where + type ServerT api (m :: Type -> Type) :: Type + + route :: + Proxy api + -> Delayed env (Server api) + -> Router env + + hoistServerWithContext + :: Proxy api + -> (forall x. m x -> n x) + -> ServerT api m + -> ServerT api n + +type Server aqi = ServerT aqi Handler + ===================================== testsuite/tests/polykinds/T22379b.hs ===================================== @@ -0,0 +1,30 @@ +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TypeFamilies #-} +module Bug where + +import Data.Kind +import Data.Proxy (Proxy) + +data Delayed (env :: Type) (c :: Type) +data Handler (a :: Type) +data Router (a :: Type) + +-- type decl, then class decl + +type Server aqi = ServerT aqi Handler + +class HasServer api where + type ServerT api (m :: Type -> Type) :: Type + + route :: + Proxy api + -> Delayed env (Server api) + -> Router env + + hoistServerWithContext + :: Proxy api + -> (forall x. m x -> n x) + -> ServerT api m + -> ServerT api n ===================================== testsuite/tests/polykinds/all.T ===================================== @@ -239,3 +239,5 @@ test('T19739a', normal, compile, ['']) test('T19739b', normal, compile, ['']) test('T19739c', normal, compile, ['']) test('T19739d', normal, compile, ['']) +test('T22379a', normal, compile, ['']) +test('T22379b', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0560821f637fa2a4318fb068a969f4802acb5a89 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0560821f637fa2a4318fb068a969f4802acb5a89 You're receiving 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 Nov 1 16:50:39 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 01 Nov 2022 12:50:39 -0400 Subject: [Git][ghc/ghc][master] Expose UnitEnvGraphKey for user-code Message-ID: <63614e5fdadaa_815bc5159041329a@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 1 changed file: - compiler/GHC/Unit/Env.hs Changes: ===================================== compiler/GHC/Unit/Env.hs ===================================== @@ -37,6 +37,7 @@ module GHC.Unit.Env , addHomeModInfoToHug -- * UnitEnvGraph , UnitEnvGraph (..) + , UnitEnvGraphKey , unitEnv_insert , unitEnv_delete , unitEnv_adjust View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38d19668aa60edee495008be84072c15a038dc05 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/38d19668aa60edee495008be84072c15a038dc05 You're receiving 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 Nov 1 16:51:20 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 01 Nov 2022 12:51:20 -0400 Subject: [Git][ghc/ghc][master] 2 commits: Shrink test case for #22357 Message-ID: <63614e8863e0a_815bc5156841661@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 8 changed files: - + testsuite/tests/simplCore/should_compile/T17366.hs - + testsuite/tests/simplCore/should_compile/T17366.stderr - + testsuite/tests/simplCore/should_compile/T17366_AR.hs - + testsuite/tests/simplCore/should_compile/T17366_AR.stderr - + testsuite/tests/simplCore/should_compile/T17366_ARa.hs - + testsuite/tests/simplCore/should_compile/T17366a.hs - testsuite/tests/simplCore/should_compile/T22357.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== testsuite/tests/simplCore/should_compile/T17366.hs ===================================== @@ -0,0 +1,9 @@ +module T17366 where +import Data.Functor.Identity +import T17366a + +g :: Identity a -> a +g a = f a + +h :: Tagged tag a -> a +h a = f a ===================================== testsuite/tests/simplCore/should_compile/T17366.stderr ===================================== @@ -0,0 +1,2 @@ +Rule fired: SPEC/T17366 f @Identity @_ (T17366) +Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) ===================================== testsuite/tests/simplCore/should_compile/T17366_AR.hs ===================================== @@ -0,0 +1,21 @@ +{-# LANGUAGE DataKinds #-} +module T17366_AR where + +import T17366_ARa + +--{-# SPECIALIZE test :: Eff es () #-} + +--testSpec :: Eff '[] () -- Specialization of 'test' works. +testSpec :: Eff es () -- Specialization of 'test' doesn't work. +testSpec = do + test + test + test + +-- Specialization of 'smallTest' works only if the INLINABLE pragma for 'smallTest' +-- is commented out (!!!). +smallTestSpec :: Eff es () +smallTestSpec = do + smallTest + smallTest + smallTest ===================================== testsuite/tests/simplCore/should_compile/T17366_AR.stderr ===================================== @@ -0,0 +1,6 @@ +Rule fired: SPEC/T17366_AR test @(Eff es) (T17366_AR) +Rule fired: SPEC/T17366_AR test @(Eff es) (T17366_AR) +Rule fired: SPEC/T17366_AR test @(Eff es) (T17366_AR) +Rule fired: SPEC/T17366_AR smallTest @(Eff es) (T17366_AR) +Rule fired: SPEC/T17366_AR smallTest @(Eff es) (T17366_AR) +Rule fired: SPEC/T17366_AR smallTest @(Eff es) (T17366_AR) ===================================== testsuite/tests/simplCore/should_compile/T17366_ARa.hs ===================================== @@ -0,0 +1,57 @@ +{-# LANGUAGE DataKinds #-} +module T17366_ARa where + +import Control.Monad.IO.Class +import Data.Kind + +type Effect = (Type -> Type) -> Type -> Type + +data Env (es :: [Effect]) = Env + +newtype Eff (es :: [Effect]) a = Eff { unEff :: Env es -> IO a } + deriving Functor + +instance Applicative (Eff es) where + pure a = Eff $ \_ -> pure a + f <*> a = Eff $ \es -> unEff f es <*> unEff a es + +instance Monad (Eff es) where + m >>= f = Eff $ \es -> unEff m es >>= (`unEff` es) . f + +instance MonadIO (Eff es) where + liftIO m = Eff $ \_ -> m + +---------------------------------------- + +smallTest :: MonadIO m => m () +smallTest = do + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" +{-# INLINABLE smallTest #-} -- When uncommented, smallTestSpec no longer uses specialized smallTest. + +test :: MonadIO m => m () +test = do + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" + liftIO $ putStrLn "test" +{-# INLINABLE test #-} ===================================== testsuite/tests/simplCore/should_compile/T17366a.hs ===================================== @@ -0,0 +1,17 @@ +module T17366a where +import Data.Functor.Identity + +class C f where + c :: f a -> a + +instance C Identity where + c (Identity a) = a + +newtype Tagged tag a = Tagged a + +instance C (Tagged tag) where + c (Tagged a) = a + +f :: C f => f a -> a +f a = c a +{-# INLINABLE[0] f #-} ===================================== testsuite/tests/simplCore/should_compile/T22357.hs ===================================== @@ -1,256 +1,36 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE BangPatterns #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE Haskell2010 #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE TypeOperators #-} -{-# LANGUAGE UndecidableInstances #-} +module T22358 + ( FunctorWithIndex(..) + , FoldableWithIndex(..) + , TraversableWithIndex(..) + ) where -#if __GLASGOW_HASKELL__ >= 702 -{-# LANGUAGE Trustworthy #-} -{-# LANGUAGE DefaultSignatures #-} -#endif - -#if __GLASGOW_HASKELL__ >= 706 -{-# LANGUAGE PolyKinds #-} -#endif -module WithIndex where - -import Prelude - (Either (..), Functor (..), Int, Maybe (..), Monad (..), Num (..), error, - flip, id, seq, snd, ($!), ($), (.), zip) - -import Control.Applicative - (Applicative (..), Const (..), ZipList (..), (<$>), liftA2) -import Control.Applicative.Backwards (Backwards (..)) -import Control.Monad.Trans.Identity (IdentityT (..)) -import Control.Monad.Trans.Reader (ReaderT (..)) -import Data.Array (Array) -import Data.Foldable (Foldable (..)) -import Data.Functor.Compose (Compose (..)) -import Data.Functor.Constant (Constant (..)) -import Data.Functor.Identity (Identity (..)) -import Data.Functor.Product (Product (..)) -import Data.Functor.Reverse (Reverse (..)) -import Data.Functor.Sum (Sum (..)) -import Data.IntMap (IntMap) -import Data.Ix (Ix (..)) -import Data.List.NonEmpty (NonEmpty (..)) -import Data.Map (Map) -import Data.Monoid (Dual (..), Endo (..), Monoid (..)) -import Data.Proxy (Proxy (..)) -import Data.Semigroup (Semigroup (..)) -import Data.Sequence (Seq) -import Data.Traversable (Traversable (..)) -import Data.Tree (Tree (..)) -import Data.Void (Void) - -#if __GLASGOW_HASKELL__ >= 702 -import GHC.Generics - (K1 (..), Par1 (..), Rec1 (..), U1 (..), V1, (:*:) (..), (:+:) (..), - (:.:) (..)) -#else -import Generics.Deriving - (K1 (..), Par1 (..), Rec1 (..), U1 (..), V1, (:*:) (..), (:+:) (..), - (:.:) (..)) -#endif - -import Data.Type.Equality -import qualified Data.Array as Array -import qualified Data.IntMap as IntMap -import qualified Data.Map as Map -import qualified Data.Sequence as Seq - -#ifdef MIN_VERSION_base_orphans -import Data.Orphans () -#endif - -#if __GLASGOW_HASKELL__ >=708 +import Control.Applicative (Const(..)) import Data.Coerce (Coercible, coerce) -#else -import Unsafe.Coerce (unsafeCoerce) -#endif +import Data.Monoid (Dual(..), Endo(..)) +import Data.Tree (Tree (..)) -------------------------------------------------------------------------------- --- FunctorWithIndex -------------------------------------------------------------------------------- - --- | A 'Functor' with an additional index. --- --- Instances must satisfy a modified form of the 'Functor' laws: --- --- @ --- 'imap' f '.' 'imap' g ≡ 'imap' (\\i -> f i '.' g i) --- 'imap' (\\_ a -> a) ≡ 'id' --- @ class Functor f => FunctorWithIndex i f | f -> i where - -- | Map with access to the index. imap :: (i -> a -> b) -> f a -> f b -#if __GLASGOW_HASKELL__ >= 704 - default imap :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b - imap = imapDefault - {-# INLINE imap #-} -#endif - -imapDefault :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b --- imapDefault f = runIdentity #. itraverse (\i a -> Identity (f i a)) -imapDefault f = runIdentity #. itraverse (Identity #.. f) -{-# INLINE imapDefault #-} - -------------------------------------------------------------------------------- --- FoldableWithIndex -------------------------------------------------------------------------------- - --- | A container that supports folding with an additional index. class Foldable f => FoldableWithIndex i f | f -> i where - -- - -- | Fold a container by mapping value to an arbitrary 'Monoid' with access to the index @i at . - -- - -- When you don't need access to the index then 'foldMap' is more flexible in what it accepts. - -- - -- @ - -- 'foldMap' ≡ 'ifoldMap' '.' 'const' - -- @ ifoldMap :: Monoid m => (i -> a -> m) -> f a -> m -#if __GLASGOW_HASKELL__ >= 704 - default ifoldMap :: (TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m - ifoldMap = ifoldMapDefault - {-# INLINE ifoldMap #-} -#endif - - -- | A variant of 'ifoldMap' that is strict in the accumulator. - -- - -- When you don't need access to the index then 'Data.Foldable.foldMap'' is more flexible in what it accepts. - -- - -- @ - -- 'foldMap'' ≡ 'ifoldMap'' '.' 'const' - -- @ - ifoldMap' :: Monoid m => (i -> a -> m) -> f a -> m - ifoldMap' f = ifoldl' (\i acc a -> mappend acc (f i a)) mempty - {-# INLINE ifoldMap' #-} - - -- | Right-associative fold of an indexed container with access to the index @i at . - -- - -- When you don't need access to the index then 'Data.Foldable.foldr' is more flexible in what it accepts. - -- - -- @ - -- 'Data.Foldable.foldr' ≡ 'ifoldr' '.' 'const' - -- @ - ifoldr :: (i -> a -> b -> b) -> b -> f a -> b - ifoldr f z t = appEndo (ifoldMap (Endo #.. f) t) z - {-# INLINE ifoldr #-} - - -- | Left-associative fold of an indexed container with access to the index @i at . - -- - -- When you don't need access to the index then 'Data.Foldable.foldl' is more flexible in what it accepts. - -- - -- @ - -- 'Data.Foldable.foldl' ≡ 'ifoldl' '.' 'const' - -- @ ifoldl :: (i -> b -> a -> b) -> b -> f a -> b ifoldl f z t = appEndo (getDual (ifoldMap (\ i -> Dual #. Endo #. flip (f i)) t)) z {-# INLINE ifoldl #-} - -- | /Strictly/ fold right over the elements of a structure with access to the index @i at . - -- - -- When you don't need access to the index then 'foldr'' is more flexible in what it accepts. - -- - -- @ - -- 'foldr'' ≡ 'ifoldr'' '.' 'const' - -- @ - ifoldr' :: (i -> a -> b -> b) -> b -> f a -> b - ifoldr' f z0 xs = ifoldl f' id xs z0 - where f' i k x z = k $! f i x z - {-# INLINE ifoldr' #-} - - -- | Fold over the elements of a structure with an index, associating to the left, but /strictly/. - -- - -- When you don't need access to the index then 'Control.Lens.Fold.foldlOf'' is more flexible in what it accepts. - -- - -- @ - -- 'Data.Foldable.foldl'' l ≡ 'ifoldl'' l '.' 'const' - -- @ - ifoldl' :: (i -> b -> a -> b) -> b -> f a -> b - ifoldl' f z0 xs = ifoldr f' id xs z0 - where f' i x k z = k $! f i z x - {-# INLINE ifoldl' #-} - ifoldMapDefault :: (TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m ifoldMapDefault f = getConst #. itraverse (Const #.. f) {-# INLINE ifoldMapDefault #-} -------------------------------------------------------------------------------- --- TraversableWithIndex -------------------------------------------------------------------------------- - --- | A 'Traversable' with an additional index. --- --- An instance must satisfy a (modified) form of the 'Traversable' laws: --- --- @ --- 'itraverse' ('const' 'Identity') ≡ 'Identity' --- 'fmap' ('itraverse' f) '.' 'itraverse' g ≡ 'Data.Functor.Compose.getCompose' '.' 'itraverse' (\\i -> 'Data.Functor.Compose.Compose' '.' 'fmap' (f i) '.' g i) --- @ class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i t | t -> i where - -- | Traverse an indexed container. - -- - -- @ - -- 'itraverse' ≡ 'itraverseOf' 'itraversed' - -- @ itraverse :: Applicative f => (i -> a -> f b) -> t a -> f (t b) -#if __GLASGOW_HASKELL__ >= 704 - default itraverse :: (i ~ Int, Applicative f) => (i -> a -> f b) -> t a -> f (t b) - itraverse f s = snd $ runIndexing (traverse (\a -> Indexing (\i -> i `seq` (i + 1, f i a))) s) 0 - {-# INLINE itraverse #-} -#endif - -------------------------------------------------------------------------------- --- base -------------------------------------------------------------------------------- - -instance FunctorWithIndex r ((->) r) where - imap f g x = f x (g x) - {-# INLINE imap #-} - -instance FunctorWithIndex () Maybe where - imap f = fmap (f ()) - {-# INLINE imap #-} -instance FoldableWithIndex () Maybe where - ifoldMap f = foldMap (f ()) - {-# INLINE ifoldMap #-} -instance TraversableWithIndex () Maybe where - itraverse f = traverse (f ()) - {-# INLINE itraverse #-} - -instance FunctorWithIndex Void Proxy where - imap _ Proxy = Proxy - {-# INLINE imap #-} - -instance FoldableWithIndex Void Proxy where - ifoldMap _ _ = mempty - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex Void Proxy where - itraverse _ _ = pure Proxy - {-# INLINE itraverse #-} - -instance FunctorWithIndex k ((,) k) where - imap f (k,a) = (k, f k a) - {-# INLINE imap #-} - -instance FoldableWithIndex k ((,) k) where - ifoldMap = uncurry' - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex k ((,) k) where - itraverse f (k, a) = (,) k <$> f k a - {-# INLINE itraverse #-} - --- | The position in the list is available as the index. instance FunctorWithIndex Int [] where imap f = go 0 where go !_ [] = [] @@ -259,469 +39,23 @@ instance FunctorWithIndex Int [] where instance FoldableWithIndex Int [] where ifoldMap = ifoldMapDefault {-# INLINE ifoldMap #-} - ifoldr f z = go 0 where - go !_ [] = z - go !n (x:xs) = f n x (go (n + 1) xs) - {-# INLINE ifoldr #-} instance TraversableWithIndex Int [] where itraverse f = traverse (uncurry' f) . zip [0..] {-# INLINE itraverse #-} --- TODO: we could experiment with streaming framework --- imapListFB f xs = build (\c n -> ifoldr (\i a -> c (f i a)) n xs) - --- | Same instance as for @[]@. -instance FunctorWithIndex Int ZipList where - imap f (ZipList xs) = ZipList (imap f xs) - {-# INLINE imap #-} -instance FoldableWithIndex Int ZipList where - ifoldMap f (ZipList xs) = ifoldMap f xs - {-# INLINE ifoldMap #-} -instance TraversableWithIndex Int ZipList where - itraverse f (ZipList xs) = ZipList <$> itraverse f xs - {-# INLINE itraverse #-} - -------------------------------------------------------------------------------- --- (former) semigroups -------------------------------------------------------------------------------- - -instance FunctorWithIndex Int NonEmpty where - imap = imapDefault - {-# INLINE imap #-} -instance FoldableWithIndex Int NonEmpty where - ifoldMap = ifoldMapDefault - {-# INLINE ifoldMap #-} -instance TraversableWithIndex Int NonEmpty where - itraverse f ~(a :| as) = - liftA2 (:|) (f 0 a) (traverse (uncurry' f) (zip [1..] as)) - {-# INLINE itraverse #-} - -------------------------------------------------------------------------------- --- Functors (formely) from transformers -------------------------------------------------------------------------------- - -instance FunctorWithIndex () Identity where - imap f (Identity a) = Identity (f () a) - {-# INLINE imap #-} - -instance FoldableWithIndex () Identity where - ifoldMap f (Identity a) = f () a - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex () Identity where - itraverse f (Identity a) = Identity <$> f () a - {-# INLINE itraverse #-} - -instance FunctorWithIndex Void (Const e) where - imap _ (Const a) = Const a - {-# INLINE imap #-} - -instance FoldableWithIndex Void (Const e) where - ifoldMap _ _ = mempty - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex Void (Const e) where - itraverse _ (Const a) = pure (Const a) - {-# INLINE itraverse #-} - -instance FunctorWithIndex Void (Constant e) where - imap _ (Constant a) = Constant a - {-# INLINE imap #-} - -instance FoldableWithIndex Void (Constant e) where - ifoldMap _ _ = mempty - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex Void (Constant e) where - itraverse _ (Constant a) = pure (Constant a) - {-# INLINE itraverse #-} - -instance (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (i, j) (Compose f g) where - imap f (Compose fg) = Compose $ imap (\k -> imap (f . (,) k)) fg - {-# INLINE imap #-} - -instance (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (Compose f g) where - ifoldMap f (Compose fg) = ifoldMap (\k -> ifoldMap (f . (,) k)) fg - {-# INLINE ifoldMap #-} - -instance (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (i, j) (Compose f g) where - itraverse f (Compose fg) = Compose <$> itraverse (\k -> itraverse (f . (,) k)) fg - {-# INLINE itraverse #-} - -instance (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Sum f g) where - imap q (InL fa) = InL (imap (q . Left) fa) - imap q (InR ga) = InR (imap (q . Right) ga) - {-# INLINE imap #-} - -instance (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Sum f g) where - ifoldMap q (InL fa) = ifoldMap (q . Left) fa - ifoldMap q (InR ga) = ifoldMap (q . Right) ga - {-# INLINE ifoldMap #-} - -instance (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (Sum f g) where - itraverse q (InL fa) = InL <$> itraverse (q . Left) fa - itraverse q (InR ga) = InR <$> itraverse (q . Right) ga - {-# INLINE itraverse #-} - -instance (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (Product f g) where - imap f (Pair a b) = Pair (imap (f . Left) a) (imap (f . Right) b) - {-# INLINE imap #-} - -instance (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (Product f g) where - ifoldMap f (Pair a b) = ifoldMap (f . Left) a `mappend` ifoldMap (f . Right) b - {-# INLINE ifoldMap #-} - -instance (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (Product f g) where - itraverse f (Pair a b) = liftA2 Pair (itraverse (f . Left) a) (itraverse (f . Right) b) - {-# INLINE itraverse #-} - -------------------------------------------------------------------------------- --- transformers -------------------------------------------------------------------------------- - -instance FunctorWithIndex i m => FunctorWithIndex i (IdentityT m) where - imap f (IdentityT m) = IdentityT $ imap f m - {-# INLINE imap #-} - -instance FoldableWithIndex i m => FoldableWithIndex i (IdentityT m) where - ifoldMap f (IdentityT m) = ifoldMap f m - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex i m => TraversableWithIndex i (IdentityT m) where - itraverse f (IdentityT m) = IdentityT <$> itraverse f m - {-# INLINE itraverse #-} - -instance FunctorWithIndex i m => FunctorWithIndex (e, i) (ReaderT e m) where - imap f (ReaderT m) = ReaderT $ \k -> imap (f . (,) k) (m k) - {-# INLINE imap #-} - -instance FunctorWithIndex i f => FunctorWithIndex i (Backwards f) where - imap f = Backwards . imap f . forwards - {-# INLINE imap #-} - -instance FoldableWithIndex i f => FoldableWithIndex i (Backwards f) where - ifoldMap f = ifoldMap f . forwards - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex i f => TraversableWithIndex i (Backwards f) where - itraverse f = fmap Backwards . itraverse f . forwards - {-# INLINE itraverse #-} - -instance FunctorWithIndex i f => FunctorWithIndex i (Reverse f) where - imap f = Reverse . imap f . getReverse - {-# INLINE imap #-} - -instance FoldableWithIndex i f => FoldableWithIndex i (Reverse f) where - ifoldMap f = getDual #. ifoldMap (Dual #.. f) . getReverse - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex i f => TraversableWithIndex i (Reverse f) where - itraverse f = fmap Reverse . forwards . itraverse (Backwards #.. f) . getReverse - {-# INLINE itraverse #-} - -------------------------------------------------------------------------------- --- array -------------------------------------------------------------------------------- - -instance Ix i => FunctorWithIndex i (Array i) where - imap f arr = Array.listArray (Array.bounds arr) . fmap (uncurry' f) $ Array.assocs arr - {-# INLINE imap #-} - -instance Ix i => FoldableWithIndex i (Array i) where - ifoldMap f = foldMap (uncurry' f) . Array.assocs - {-# INLINE ifoldMap #-} - -instance Ix i => TraversableWithIndex i (Array i) where - itraverse f arr = Array.listArray (Array.bounds arr) <$> traverse (uncurry' f) (Array.assocs arr) - {-# INLINE itraverse #-} - -------------------------------------------------------------------------------- --- containers -------------------------------------------------------------------------------- - -instance FunctorWithIndex [Int] Tree where - imap f (Node a as) = Node (f [] a) $ imap (\i -> imap (f . (:) i)) as - {-# INLINE imap #-} - instance FoldableWithIndex [Int] Tree where ifoldMap f (Node a as) = f [] a `mappend` ifoldMap (\i -> ifoldMap (f . (:) i)) as {-# INLINE ifoldMap #-} -instance TraversableWithIndex [Int] Tree where - itraverse f (Node a as) = liftA2 Node (f [] a) (itraverse (\i -> itraverse (f . (:) i)) as) - {-# INLINE itraverse #-} --- --- | The position in the 'Seq' is available as the index. -instance FunctorWithIndex Int Seq where - imap = Seq.mapWithIndex - {-# INLINE imap #-} -instance FoldableWithIndex Int Seq where -#if MIN_VERSION_containers(0,5,8) - ifoldMap = Seq.foldMapWithIndex -#else - ifoldMap f = Data.Foldable.fold . Seq.mapWithIndex f -#endif - {-# INLINE ifoldMap #-} - ifoldr = Seq.foldrWithIndex - {-# INLINE ifoldr #-} - ifoldl f = Seq.foldlWithIndex (flip f) - {-# INLINE ifoldl #-} -instance TraversableWithIndex Int Seq where -#if MIN_VERSION_containers(0,6,0) - itraverse = Seq.traverseWithIndex -#else - -- Much faster than Seq.traverseWithIndex for containers < 0.6.0, see - -- https://github.com/haskell/containers/issues/603. - itraverse f = sequenceA . Seq.mapWithIndex f -#endif - {-# INLINE itraverse #-} - -instance FunctorWithIndex Int IntMap where - imap = IntMap.mapWithKey - {-# INLINE imap #-} - -instance FoldableWithIndex Int IntMap where -#if MIN_VERSION_containers(0,5,4) - ifoldMap = IntMap.foldMapWithKey -#else - ifoldMap = ifoldMapDefault -#endif - {-# INLINE ifoldMap #-} -#if MIN_VERSION_containers(0,5,0) - ifoldr = IntMap.foldrWithKey - ifoldl' = IntMap.foldlWithKey' . flip - {-# INLINE ifoldr #-} - {-# INLINE ifoldl' #-} -#endif - -instance TraversableWithIndex Int IntMap where -#if MIN_VERSION_containers(0,5,0) - itraverse = IntMap.traverseWithKey -#else - itraverse f = sequenceA . IntMap.mapWithKey f -#endif - {-# INLINE itraverse #-} - -instance FunctorWithIndex k (Map k) where - imap = Map.mapWithKey - {-# INLINE imap #-} - -instance FoldableWithIndex k (Map k) where -#if MIN_VERSION_containers(0,5,4) - ifoldMap = Map.foldMapWithKey -#else - ifoldMap = ifoldMapDefault -#endif - {-# INLINE ifoldMap #-} -#if MIN_VERSION_containers(0,5,0) - ifoldr = Map.foldrWithKey - ifoldl' = Map.foldlWithKey' . flip - {-# INLINE ifoldr #-} - {-# INLINE ifoldl' #-} -#endif - -instance TraversableWithIndex k (Map k) where -#if MIN_VERSION_containers(0,5,0) - itraverse = Map.traverseWithKey -#else - itraverse f = sequenceA . Map.mapWithKey f -#endif - {-# INLINE itraverse #-} - -------------------------------------------------------------------------------- --- GHC.Generics -------------------------------------------------------------------------------- - -instance FunctorWithIndex Void V1 where - imap _ v = v `seq` error "imap @V1" - {-# INLINE imap #-} - -instance FoldableWithIndex Void V1 where - ifoldMap _ v = v `seq` error "ifoldMap @V1" - -instance TraversableWithIndex Void V1 where - itraverse _ v = v `seq` error "itraverse @V1" - -instance FunctorWithIndex Void U1 where - imap _ U1 = U1 - {-# INLINE imap #-} - -instance FoldableWithIndex Void U1 where - ifoldMap _ _ = mempty - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex Void U1 where - itraverse _ U1 = pure U1 - {-# INLINE itraverse #-} - -instance FunctorWithIndex () Par1 where - imap f = fmap (f ()) - {-# INLINE imap #-} - -instance FoldableWithIndex () Par1 where - ifoldMap f (Par1 a) = f () a - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex () Par1 where - itraverse f (Par1 a) = Par1 <$> f () a - {-# INLINE itraverse #-} - -instance (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (i, j) (f :.: g) where - imap q (Comp1 fga) = Comp1 (imap (\k -> imap (q . (,) k)) fga) - {-# INLINE imap #-} - -instance (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (i, j) (f :.: g) where - ifoldMap q (Comp1 fga) = ifoldMap (\k -> ifoldMap (q . (,) k)) fga - {-# INLINE ifoldMap #-} - -instance (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (i, j) (f :.: g) where - itraverse q (Comp1 fga) = Comp1 <$> itraverse (\k -> itraverse (q . (,) k)) fga - {-# INLINE itraverse #-} - -instance (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :*: g) where - imap q (fa :*: ga) = imap (q . Left) fa :*: imap (q . Right) ga - {-# INLINE imap #-} - -instance (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :*: g) where - ifoldMap q (fa :*: ga) = ifoldMap (q . Left) fa `mappend` ifoldMap (q . Right) ga - {-# INLINE ifoldMap #-} - -instance (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (f :*: g) where - itraverse q (fa :*: ga) = liftA2 (:*:) (itraverse (q . Left) fa) (itraverse (q . Right) ga) - {-# INLINE itraverse #-} - -instance (FunctorWithIndex i f, FunctorWithIndex j g) => FunctorWithIndex (Either i j) (f :+: g) where - imap q (L1 fa) = L1 (imap (q . Left) fa) - imap q (R1 ga) = R1 (imap (q . Right) ga) - {-# INLINE imap #-} - -instance (FoldableWithIndex i f, FoldableWithIndex j g) => FoldableWithIndex (Either i j) (f :+: g) where - ifoldMap q (L1 fa) = ifoldMap (q . Left) fa - ifoldMap q (R1 ga) = ifoldMap (q . Right) ga - {-# INLINE ifoldMap #-} - -instance (TraversableWithIndex i f, TraversableWithIndex j g) => TraversableWithIndex (Either i j) (f :+: g) where - itraverse q (L1 fa) = L1 <$> itraverse (q . Left) fa - itraverse q (R1 ga) = R1 <$> itraverse (q . Right) ga - {-# INLINE itraverse #-} - -instance FunctorWithIndex i f => FunctorWithIndex i (Rec1 f) where - imap q (Rec1 f) = Rec1 (imap q f) - {-# INLINE imap #-} - -instance FoldableWithIndex i f => FoldableWithIndex i (Rec1 f) where - ifoldMap q (Rec1 f) = ifoldMap q f - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex i f => TraversableWithIndex i (Rec1 f) where - itraverse q (Rec1 f) = Rec1 <$> itraverse q f - {-# INLINE itraverse #-} - -instance FunctorWithIndex Void (K1 i c) where - imap _ (K1 c) = K1 c - {-# INLINE imap #-} - -instance FoldableWithIndex Void (K1 i c) where - ifoldMap _ _ = mempty - {-# INLINE ifoldMap #-} - -instance TraversableWithIndex Void (K1 i c) where - itraverse _ (K1 a) = pure (K1 a) - {-# INLINE itraverse #-} - -------------------------------------------------------------------------------- --- Misc. -------------------------------------------------------------------------------- - -#if __GLASGOW_HASKELL__ >=708 (#.) :: Coercible b c => (b -> c) -> (a -> b) -> (a -> c) _ #. x = coerce x (#..) :: Coercible b c => (b -> c) -> (i -> a -> b) -> (i -> a -> c) _ #.. x = coerce x -#else -(#.) :: (b -> c) -> (a -> b) -> (a -> c) -_ #. x = unsafeCoerce x - -(#..) :: (b -> c) -> (i -> a -> b) -> (i -> a -> c) -_ #.. x = unsafeCoerce x -#endif infixr 9 #., #.. {-# INLINE (#.) #-} {-# INLINE (#..)#-} -skip :: a -> () -skip _ = () -{-# INLINE skip #-} - ------------------------------------------------------------------------------- --- Traversed ------------------------------------------------------------------------------- - --- | Used internally by 'Control.Lens.Traversal.traverseOf_' and the like. --- --- The argument 'a' of the result should not be used! -newtype Traversed a f = Traversed { getTraversed :: f a } - --- See 4.16 Changelog entry for the explanation of "why not Apply f =>"? -instance Applicative f => Semigroup (Traversed a f) where - Traversed ma <> Traversed mb = Traversed (ma *> mb) - {-# INLINE (<>) #-} - -instance Applicative f => Monoid (Traversed a f) where - mempty = Traversed (pure (error "Traversed: value used")) - {-# INLINE mempty #-} - ------------------------------------------------------------------------------- --- Sequenced ------------------------------------------------------------------------------- - --- | Used internally by 'Control.Lens.Traversal.mapM_' and the like. --- --- The argument 'a' of the result should not be used! --- --- See 4.16 Changelog entry for the explanation of "why not Apply f =>"? -newtype Sequenced a m = Sequenced { getSequenced :: m a } - -instance Monad m => Semigroup (Sequenced a m) where - Sequenced ma <> Sequenced mb = Sequenced (ma >> mb) - {-# INLINE (<>) #-} - -instance Monad m => Monoid (Sequenced a m) where - mempty = Sequenced (return (error "Sequenced: value used")) - {-# INLINE mempty #-} - ------------------------------------------------------------------------------- --- Indexing ------------------------------------------------------------------------------- - --- | 'Applicative' composition of @'Control.Monad.Trans.State.Lazy.State' 'Int'@ with a 'Functor', used --- by 'Control.Lens.Indexed.indexed'. -newtype Indexing f a = Indexing { runIndexing :: Int -> (Int, f a) } - -instance Functor f => Functor (Indexing f) where - fmap f (Indexing m) = Indexing $ \i -> case m i of - (j, x) -> (j, fmap f x) - {-# INLINE fmap #-} - -instance Applicative f => Applicative (Indexing f) where - pure x = Indexing $ \i -> (i, pure x) - {-# INLINE pure #-} - Indexing mf <*> Indexing ma = Indexing $ \i -> case mf i of - (j, ff) -> case ma j of - ~(k, fa) -> (k, ff <*> fa) - {-# INLINE (<*>) #-} -#if __GLASGOW_HASKELL__ >=821 - liftA2 f (Indexing ma) (Indexing mb) = Indexing $ \ i -> case ma i of - (j, ja) -> case mb j of - ~(k, kb) -> (k, liftA2 f ja kb) - {-# INLINE liftA2 #-} -#endif - -------------------------------------------------------------------------------- --- Strict curry -------------------------------------------------------------------------------- - uncurry' :: (a -> b -> c) -> (a, b) -> c uncurry' f (a, b) = f a b {-# INLINE uncurry' #-} ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -438,3 +438,7 @@ test('T22097', [grep_errmsg(r'case.*wgoEven') ], multimod_compile, ['T22097', '- test('T13873', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-rules']) test('T22357', normal, compile, ['-O']) +# T17366: expecting to see a rule +# Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) +test('T17366', normal, multimod_compile, ['T17366', '-O -v0 -ddump-rule-firings']) +test('T17366_AR', [grep_errmsg(r'SPEC')], multimod_compile, ['T17366_AR', '-O -v0 -ddump-rule-firings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/38d19668aa60edee495008be84072c15a038dc05...4521f6498d09f48a775a028efdd763c874da3451 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/38d19668aa60edee495008be84072c15a038dc05...4521f6498d09f48a775a028efdd763c874da3451 You're receiving 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 Nov 1 17:13:24 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Tue, 01 Nov 2022 13:13:24 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/docs-core-prog Message-ID: <636153b4ae08d_815bc514144260f5@gitlab.mail> Matthew Pickering pushed new branch wip/docs-core-prog at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/docs-core-prog You're receiving 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 Nov 1 17:51:49 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 01 Nov 2022 13:51:49 -0400 Subject: [Git][ghc/ghc][wip/T21623] 28 commits: CI: Don't run lint-submods on nightly Message-ID: <63615cb5a694c_815bc515a44475d8@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - e65f485b by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Start work Not ready for review More progress Wibbles Stage1 compiles More wibbles More wibbles More -- almost working Comments Wibbles Wibbles Wibble inlineId Wibbles Infinite loop somewhere More wibbles. Maybe can build stage2 Make FuNCo a thing by itself Wibble Wibble Wibbles Fix OptCoercion Wibble Wibble to optCoercion Replace SORT with TYPE and CONSTRAINT Wibble Delete unused import Delete TypeOrConstraint from ghc-prim:GHC.Types Move from NthCo to SelCo Wibbles Wibbles in RepType Wibble Add mkWpEta Really add mkWpEta Wibble Typeable binds etc Improve error messages More wibbles, mainly to error messages Wibbles Wibbles to errors Wibbles But especially: treat Constraint as Typeable More wibbles More changes * Move role into SelTyCon * Get rid of mkTcSymCo and friends Unused variable Wibbles Wibble Accept error message changes Refactoring... Remove tc functions like tcKind, tcGetTyVar. Move tyConsOfType, occCheckExpand to TyCo.FVs. Introduce GHC.Core.TyCo.Compare Lots of import changes! Update haddock submodule (I hope) Wibbles (notably: actually add GHC.Core.TyCo.Compare) Wibbles Wibble output of T16575 Wibbles More wibbles Remove infinite loop in T1946 See Note [ForAllTy and type equality] Deal with rejigConRes Needs a Note to be written by Richard Some renaming AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag Update haddock submodule Rename TyCoBinder to ForAllTyBinder Wibbles Update haddock Wibble Update unix submodule I think I accidentally got it out of sync with HEAD; this puts it back. Rename TyCoBinder to PiTyBinder Update Haddock submodule Wrap dictionaries in tuples This fixes the kind bugs in arrow desugaring. Needs some Notes, but I want to try CI. More on boxing data cons Rebase and update GHC.Tc.Errors/GHC.Tc.Errors.Ppr Revert accidental changes in SameOccInfo fixes mod180, tcfail182 Wibbles in error messages ..plus eqType comes from GHC.Core.TyCo.Compare Wibbles More wibbles Reaedy for RAE review Fix fragile rule setup in GHC.Float See Note [realToFrac natural-to-float] Wibbles More wibbles Remove unused import Remove another unused import Wibbles Update haddock submodule Respond to Sam's suggestions Wibbles Wibbles - - - - - 969a1c3c by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibbles - - - - - a32e511a by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Unused import - - - - - 00b6c735 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Better boxingCon_maybe - - - - - 6f75abb4 by Richard Eisenberg at 2022-10-31T11:00:12+00:00 Improvements to comments, etc., from Richard - - - - - b7d5a10a by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Respond to Richard - - - - - e448c0c4 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Improve boxing-data-con API - - - - - eb403524 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Update error messages - - - - - 69c2dbcd by Richard Eisenberg at 2022-10-31T11:00:12+00:00 Fix the equality constraint problem - - - - - 9e91edb0 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibbles - - - - - e1655631 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Add isCovertGadtDataCon, fixing build - - - - - b4c93200 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibbles - - - - - efa20639 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibbles - - - - - 9720fd73 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Move RoughMatch code out of Unify into RoughMatch - - - - - 581d19e6 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibble - - - - - 6042ba51 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibbles - - - - - 6cc3d190 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Update haddock submodule again - - - - - 292d17f4 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibbles, esp in RoughMap - - - - - dcd365da by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Upate haddock submodule - - - - - 2443bb15 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Define eqType using tcEqType A one-line change - - - - - 11b9e897 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Revert "Define eqType using tcEqType" This reverts commit eaf04c17c6a159ddb70eedd6fb8ab0b4fc180b7a. Performance got worse! T18223 was 60% worse T8095 75% T12227 9% T13386 6% T15703 7% T5030 8% - - - - - 4a721ce0 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Refactor FunTyFlag Mostly just renaming stuff - - - - - 07aa8471 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibbles - - - - - f6f673c0 by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Wibble - - - - - 82d33bfd by Simon Peyton Jones at 2022-10-31T11:00:12+00:00 Add FunTyFlags to FunCo - - - - - 073a65f4 by Simon Peyton Jones at 2022-11-01T17:52:00+00:00 More improvements Hopefully perf improves a bit Plus rep-poly/T13105 and rep-poly/T17536b are fixed. - - - - - 13 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fb07079deea7679aa683bd961f96c1fa5c1165b...073a65f42bb286dd46eab29a0287ea0bfd4d47cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8fb07079deea7679aa683bd961f96c1fa5c1165b...073a65f42bb286dd46eab29a0287ea0bfd4d47cc You're receiving 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 Nov 1 18:28:52 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 01 Nov 2022 14:28:52 -0400 Subject: [Git][ghc/ghc][wip/backports-9.4] Fix arityType: -fpedantic-bottoms, join points, etc Message-ID: <63616564a0524_815bc51590448582@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.4 at Glasgow Haskell Compiler / GHC Commits: 6fdb0dd2 by Simon Peyton Jones at 2022-11-01T14:28:41-04:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694 and #21755 * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * I realised that, now we have ae_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. And finally, it was the strange treatment of join-point Ids (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring * Rewrote Note [Combining case branches: optimistic one-shot-ness] Compile time improves slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- CoOpt_Read(normal) ghc/alloc 803,788,056 747,832,680 -7.1% GOOD T18223(normal) ghc/alloc 928,207,320 959,424,016 +3.1% BAD geo. mean -0.3% minimum -7.1% maximum +3.1% On Windows it's a bit better: geo mean is -0.6%, and three more benchmarks trip their compile-time bytes-allocated threshold (they were all close on the other build): T18698b(normal) ghc/alloc 235,619,776 233,219,008 -1.0% GOOD T6048(optasm) ghc/alloc 112,208,192 109,704,936 -2.2% GOOD T18140(normal) ghc/alloc 85,064,192 83,168,360 -2.2% GOOD I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3.4% increase in exchange for goodness elsewhere. Metric Decrease: CoOpt_Read T18140 T18698b T6048 Metric Increase: T18223 (cherry picked from commit 5e282da37e19a1ab24ae167daf32276a64ed2842) - - - - - 13 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/arityanal/should_compile/Arity17.hs - + testsuite/tests/arityanal/should_compile/T21755.hs - + testsuite/tests/arityanal/should_compile/T21755.stderr - testsuite/tests/arityanal/should_compile/all.T - + testsuite/tests/callarity/should_compile/T21694a.hs - + testsuite/tests/callarity/should_compile/T21694a.stderr - testsuite/tests/linters/notes.stdout - + testsuite/tests/simplCore/should_compile/T21694b.hs - + testsuite/tests/simplCore/should_compile/T21694b.stderr Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -739,6 +739,7 @@ Join points must follow these invariants: The arity of a join point isn't very important; but short of setting it to zero, it is helpful to have an invariant. E.g. #17294. + See also Note [Do not eta-expand join points] in GHC.Core.Opt.Simplify.Utils. 3. If the binding is recursive, then all other bindings in the recursive group must also be join points. ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -17,7 +17,7 @@ module GHC.Core.Opt.Arity , exprBotStrictness_maybe -- ** ArityType - , ArityType(..), mkBotArityType, mkTopArityType, expandableArityType + , ArityType(..), mkBotArityType, mkManifestArityType, expandableArityType , arityTypeArity, maxWithArity, idArityType -- ** Join points @@ -53,7 +53,6 @@ import GHC.Types.Demand import GHC.Types.Var import GHC.Types.Var.Env import GHC.Types.Id -import GHC.Types.Var.Set import GHC.Types.Basic import GHC.Types.Tickish @@ -594,7 +593,8 @@ same fix. -- where the @at@ fields of @ALam@ are inductively subject to the same order. -- That is, @ALam os at1 < ALam os at2@ iff @at1 < at2 at . -- --- Why the strange Top element? See Note [Combining case branches]. +-- Why the strange Top element? +-- See Note [Combining case branches: optimistic one-shot-ness] -- -- We rely on this lattice structure for fixed-point iteration in -- 'findRhsArity'. For the semantics of 'ArityType', see Note [ArityType]. @@ -641,11 +641,16 @@ mkBotArityType oss = AT oss botDiv botArityType :: ArityType botArityType = mkBotArityType [] -mkTopArityType :: [OneShotInfo] -> ArityType -mkTopArityType oss = AT oss topDiv +mkManifestArityType :: [Var] -> CoreExpr -> ArityType +mkManifestArityType bndrs body + = AT oss div + where + oss = [idOneShotInfo bndr | bndr <- bndrs, isId bndr] + div | exprIsDeadEnd body = botDiv + | otherwise = topDiv topArityType :: ArityType -topArityType = mkTopArityType [] +topArityType = AT [] topDiv -- | The number of value args for the arity type arityTypeArity :: ArityType -> Arity @@ -685,7 +690,7 @@ takeWhileOneShot (AT oss div) exprEtaExpandArity :: DynFlags -> CoreExpr -> ArityType -- exprEtaExpandArity is used when eta expanding -- e ==> \xy -> e x y -exprEtaExpandArity dflags e = arityType (etaExpandArityEnv dflags) e +exprEtaExpandArity dflags e = arityType (findRhsArityEnv dflags) e getBotArity :: ArityType -> Maybe Arity -- Arity of a divergent function @@ -825,6 +830,7 @@ floatIn cheap at | otherwise = takeWhileOneShot at arityApp :: ArityType -> Bool -> ArityType + -- Processing (fun arg) where at is the ArityType of fun, -- Knock off an argument and behave like 'let' arityApp (AT (_:oss) div) cheap = floatIn cheap (AT oss div) @@ -834,16 +840,30 @@ arityApp at _ = at -- See the haddocks on 'ArityType' for the lattice. -- -- Used for branches of a @case at . -andArityType :: ArityType -> ArityType -> ArityType -andArityType (AT (os1:oss1) div1) (AT (os2:oss2) div2) - | AT oss' div' <- andArityType (AT oss1 div1) (AT oss2 div2) - = AT ((os1 `bestOneShot` os2) : oss') div' -- See Note [Combining case branches] -andArityType at1@(AT [] div1) at2 - | isDeadEndDiv div1 = at2 -- Note [ABot branches: max arity wins] - | otherwise = at1 -- See Note [Combining case branches] -andArityType at1 at2@(AT [] div2) - | isDeadEndDiv div2 = at1 -- Note [ABot branches: max arity wins] - | otherwise = at2 -- See Note [Combining case branches] +andArityType :: ArityEnv -> ArityType -> ArityType -> ArityType +andArityType env (AT (lam1:lams1) div1) (AT (lam2:lams2) div2) + | AT lams' div' <- andArityType env (AT lams1 div1) (AT lams2 div2) + = AT ((lam1 `and_lam` lam2) : lams') div' + where + (os1) `and_lam` (os2) + = ( os1 `bestOneShot` os2) + -- bestOneShot: see Note [Combining case branches: optimistic one-shot-ness] + +andArityType env (AT [] div1) at2 = andWithTail env div1 at2 +andArityType env at1 (AT [] div2) = andWithTail env div2 at1 + +andWithTail :: ArityEnv -> Divergence -> ArityType -> ArityType +andWithTail env div1 at2@(AT lams2 _) + | isDeadEndDiv div1 -- case x of { T -> error; F -> \y.e } + = at2 -- Note [ABot branches: max arity wins] + + | pedanticBottoms env -- Note [Combining case branches: andWithTail] + = AT [] topDiv + + | otherwise -- case x of { T -> plusInt ; F -> \y.e } + = AT lams2 topDiv -- We know div1 = topDiv + -- See Note [Combining case branches: andWithTail] + {- Note [ABot branches: max arity wins] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -854,8 +874,60 @@ Consider case x of Remember: \o1..on.⊥ means "if you apply to n args, it'll definitely diverge". So we need \??.⊥ for the whole thing, the /max/ of both arities. -Note [Combining case branches] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Combining case branches: optimistic one-shot-ness] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When combining the ArityTypes for two case branches (with andArityType) +and both ArityTypes have ATLamInfo, then we just combine their +expensive-ness and one-shot info. The tricky point is when we have + case x of True -> \x{one-shot). blah1 + Fale -> \y. blah2 + +Since one-shot-ness is about the /consumer/ not the /producer/, we +optimistically assume that if either branch is one-shot, we combine +the best of the two branches, on the (slightly dodgy) basis that if we +know one branch is one-shot, then they all must be. Surprisingly, +this means that the one-shot arity type is effectively the top element +of the lattice. + +Hence the call to `bestOneShot` in `andArityType`. + +Note [Combining case branches: andWithTail] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When combining the ArityTypes for two case branches (with andArityType) +and one side or the other has run out of ATLamInfo; then we get +into `andWithTail`. + +* If one branch is guaranteed bottom (isDeadEndDiv), we just take + the other; see Note [ABot branches: max arity wins] + +* Otherwise, if pedantic-bottoms is on, we just have to return + AT [] topDiv. E.g. if we have + f x z = case x of True -> \y. blah + False -> z + then we can't eta-expand, because that would change the behaviour + of (f False bottom(). + +* But if pedantic-bottoms is not on, we allow ourselves to push + `z` under a lambda (much as we allow ourselves to put the `case x` + under a lambda). However we know nothing about the expensiveness + or one-shot-ness of `z`, so we'd better assume it looks like + (Expensive, NoOneShotInfo) all the way. Remembering + Note [Combining case branches: optimistic one-shot-ness], + we just add work to ever ATLamInfo, keeping the one-shot-ness. + +Here's an example: + go = \x. let z = go e0 + go2 = \x. case x of + True -> z + False -> \s(one-shot). e1 + in go2 x +We *really* want to respect the one-shot annotation provided by the +user and eta-expand go and go2. +When combining the branches of the case we have + T `andAT` \1.T +and we want to get \1.T. +But if the inner lambda wasn't one-shot (\?.T) we don't want to do this. +(We need a usage analysis to justify that.) Unless we can conclude that **all** branches are safe to eta-expand then we must pessimisticaly conclude that we can't eta-expand. See #21694 for where this @@ -934,22 +1006,21 @@ data ArityEnv = AE { ae_mode :: !AnalysisMode -- ^ The analysis mode. See 'AnalysisMode'. - , ae_joins :: !IdSet - -- ^ In-scope join points. See Note [Eta-expansion and join points] - -- INVARIANT: Disjoint with the domain of 'am_sigs' (if present). } -- | The @ArityEnv@ used by 'exprBotStrictness_maybe'. Pedantic about bottoms -- and no application is ever considered cheap. botStrictnessArityEnv :: ArityEnv -botStrictnessArityEnv = AE { ae_mode = BotStrictness, ae_joins = emptyVarSet } +botStrictnessArityEnv = AE { ae_mode = BotStrictness } +{- -- | The @ArityEnv@ used by 'exprEtaExpandArity'. etaExpandArityEnv :: DynFlags -> ArityEnv etaExpandArityEnv dflags = AE { ae_mode = EtaExpandArity { am_ped_bot = gopt Opt_PedanticBottoms dflags , am_dicts_cheap = gopt Opt_DictsCheap dflags } , ae_joins = emptyVarSet } +-} -- | The @ArityEnv@ used by 'findRhsArity'. findRhsArityEnv :: DynFlags -> ArityEnv @@ -957,7 +1028,11 @@ findRhsArityEnv dflags = AE { ae_mode = FindRhsArity { am_ped_bot = gopt Opt_PedanticBottoms dflags , am_dicts_cheap = gopt Opt_DictsCheap dflags , am_sigs = emptyVarEnv } - , ae_joins = emptyVarSet } + } + +isFindRhsArity :: ArityEnv -> Bool +isFindRhsArity (AE { ae_mode = FindRhsArity {} }) = True +isFindRhsArity _ = False -- First some internal functions in snake_case for deleting in certain VarEnvs -- of the ArityType. Don't call these; call delInScope* instead! @@ -976,32 +1051,17 @@ del_sig_env_list :: [Id] -> ArityEnv -> ArityEnv -- internal! del_sig_env_list ids = modifySigEnv (\sigs -> delVarEnvList sigs ids) {-# INLINE del_sig_env_list #-} -del_join_env :: JoinId -> ArityEnv -> ArityEnv -- internal! -del_join_env id env@(AE { ae_joins = joins }) - = env { ae_joins = delVarSet joins id } -{-# INLINE del_join_env #-} - -del_join_env_list :: [JoinId] -> ArityEnv -> ArityEnv -- internal! -del_join_env_list ids env@(AE { ae_joins = joins }) - = env { ae_joins = delVarSetList joins ids } -{-# INLINE del_join_env_list #-} - -- end of internal deletion functions -extendJoinEnv :: ArityEnv -> [JoinId] -> ArityEnv -extendJoinEnv env@(AE { ae_joins = joins }) join_ids - = del_sig_env_list join_ids - $ env { ae_joins = joins `extendVarSetList` join_ids } - extendSigEnv :: ArityEnv -> Id -> ArityType -> ArityEnv extendSigEnv env id ar_ty - = del_join_env id (modifySigEnv (\sigs -> extendVarEnv sigs id ar_ty) env) + = modifySigEnv (\sigs -> extendVarEnv sigs id ar_ty) env delInScope :: ArityEnv -> Id -> ArityEnv -delInScope env id = del_join_env id $ del_sig_env id env +delInScope env id = del_sig_env id env delInScopeList :: ArityEnv -> [Id] -> ArityEnv -delInScopeList env ids = del_join_env_list ids $ del_sig_env_list ids env +delInScopeList env ids = del_sig_env_list ids env lookupSigEnv :: ArityEnv -> Id -> Maybe ArityType lookupSigEnv AE{ ae_mode = mode } id = case mode of @@ -1046,8 +1106,11 @@ myIsCheapApp :: IdEnv ArityType -> CheapAppFun myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of -- Nothing means not a local function, fall back to regular -- 'GHC.Core.Utils.isCheapApp' - Nothing -> isCheapApp fn n_val_args - -- @Just at@ means local function with @at@ as current ArityType. + Nothing -> isCheapApp fn n_val_args + + -- `Just at` means local function with `at` as current SafeArityType. + -- NB the SafeArityType bit: that means we can ignore the cost flags + -- in 'lams', and just consider the length -- Roughly approximate what 'isCheapApp' is doing. Just (AT oss div) | isDeadEndDiv div -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils @@ -1055,7 +1118,10 @@ myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of | otherwise -> False ---------------- -arityType :: ArityEnv -> CoreExpr -> ArityType +arityType :: HasDebugCallStack => ArityEnv -> CoreExpr -> ArityType +-- Precondition: all the free join points of the expression +-- are bound by the ArityEnv +-- See Note [No free join points in arityType] arityType env (Cast e co) = minWithArity (arityType env e) co_arity -- See Note [Arity trimming] @@ -1067,12 +1133,13 @@ arityType env (Cast e co) -- #5441 is a nice demo arityType env (Var v) - | v `elemVarSet` ae_joins env - = botArityType -- See Note [Eta-expansion and join points] | Just at <- lookupSigEnv env v -- Local binding = at | otherwise - = idArityType v + = assertPpr (not (isFindRhsArity env && isJoinId v)) (ppr v) $ + -- All join-point should be in the ae_sigs + -- See Note [No free join points in arityType] + idArityType v -- Lambdas; increase arity arityType env (Lam x e) @@ -1109,32 +1176,11 @@ arityType env (Case scrut bndr _ alts) where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs - alts_type = foldr1 andArityType (map arity_type_alt 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) + alts_type = foldr1 (andArityType env) (map arity_type_alt alts) arityType env (Let (NonRec b r) e) - = floatIn cheap_rhs (arityType env' e) + = -- See Note [arityType for let-bindings] + floatIn cheap_rhs (arityType env' e) where cheap_rhs = myExprIsCheap env r (Just (idType b)) env' = extendSigEnv env b (arityType env r) @@ -1142,17 +1188,76 @@ arityType env (Let (NonRec b r) e) arityType env (Let (Rec prs) e) = floatIn (all is_cheap prs) (arityType env' e) where - env' = delInScopeList env (map fst prs) is_cheap (b,e) = myExprIsCheap env' e (Just (idType b)) + env' = foldl extend_rec env prs + extend_rec :: ArityEnv -> (Id,CoreExpr) -> ArityEnv + extend_rec env (b,e) = extendSigEnv env b $ + mkManifestArityType bndrs body + where + (bndrs, body) = collectBinders e + -- We can't call arityType on the RHS, because it might mention + -- join points bound in this very letrec, and we don't want to + -- do a fixpoint calculation here. So we make do with the + -- manifest arity arityType env (Tick t e) | not (tickishIsCode t) = arityType env e arityType _ _ = topArityType -{- Note [Eta-expansion and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider this (#18328) + +{- Note [No free join points in arityType] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we call arityType on this expression (EX1) + \x . case x of True -> \y. e + False -> $j 3 +where $j is a join point. It really makes no sense to talk of the arity +of this expression, because it has a free join point. In particular, we +can't eta-expand the expression because we'd have do the same thing to the +binding of $j, and we can't see that binding. + +If we had (EX2) + \x. join $j y = blah + case x of True -> \y. e + False -> $j 3 +then it would make perfect sense: we can determine $j's ArityType, and +propagate it to the usage site as usual. + +But how can we get (EX1)? It doesn't make much sense, because $j can't +be a join point under the \x anyway. So we make it a precondition of +arityType that the argument has no free join-point Ids. (This is checked +with an assesrt in the Var case of arityType.) + +BUT the invariant risks being invalidated by one very narrow special case: runRW# + join $j y = blah + runRW# (\s. case x of True -> \y. e + False -> $j x) + +We have special magic in OccurAnal, and Simplify to allow continuations to +move into the body of a runRW# call. + +So we are careful never to attempt to eta-expand the (\s.blah) in the +argument to runRW#, at least not when there is a literal lambda there, +so that OccurAnal has seen it and allowed join points bound outside. +See Note [No eta-expansion in runRW#] in GHC.Core.Opt.Simplify.Iteration. + +Note [arityType for let-bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For non-recursive let-bindings, we just get the arityType of the RHS, +and extend the environment. That works nicely for things like this +(#18793): + go = \ ds. case ds_a2CF of { + [] -> id + : y ys -> case y of { GHC.Types.I# x -> + let acc = go ys in + case x ># 42# of { + __DEFAULT -> acc + 1# -> \x1. acc (negate x2) + +Here we want to get a good arity for `acc`, based on the ArityType +of `go`. + +All this is particularly important for join points. Consider this (#18328) f x = join j y = case y of True -> \a. blah @@ -1165,42 +1270,64 @@ Consider this (#18328) 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. +lambda. It's important that we extend the envt with j's ArityType, +so that we can use that information in the A/C branch of the case. + +For /recursive/ bindings it's more difficult, to call arityType, +because we don't have an ArityType to put in the envt for the +recursively bound Ids. So for non-join-point bindings we satisfy +ourselves with mkManifestArityType. Typically we'll have eta-expanded +the binding (based on an earlier fixpoint calculation in +findRhsArity), so the manifest arity is good. + +But for /recursive join points/ things are not so good. +See Note [Arity type for recursive join bindings] + +See Note [Arity type for recursive join bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = joinrec j 0 = \ a b c -> (a,x,b) + j n = j (n-1) + in j 20 -Why don't we eta-expand j? Because of -Note [Do not eta-expand join points] in GHC.Core.Opt.Simplify.Utils +Obviously `f` should get arity 4. But the manifest arity of `j` +is 1. Remember, we don't eta-expand join points; see +GHC.Core.Opt.Simplify.Utils Note [Do not eta-expand join points]. +And the ArityInfo on `j` will be just 1 too; see GHC.Core +Note [Invariants on join points], item (2b). So using +Note [ArityType for let-bindings] won't work well. -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. +We could do a fixpoint iteration, but that's a heavy hammer +to use in arityType. So we take advantage of it being a join +point: -So we do this: +* Extend the ArityEnv to bind each of the recursive binders + (all join points) to `botArityType`. This means that any + jump to the join point will return botArityType, which is + unit for `andArityType`: + botAritType `andArityType` at = at + So it's almost as if those "jump" branches didn't exist. -* 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. +* In this extended env, find the ArityType of each of the RHS, after + stripping off the join-point binders. -* Dually, when we come to a /call/ of a join point, just no-op - by returning ABot, the bottom element of ArityType, - which so that: bot `andArityType` x = x +* Use andArityType to combine all these RHS ArityTypes. -* 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. - Bad things happen. So we keep track of the in-scope join-point Ids - in ae_join. +* Find the ArityType of the body, also in this strange extended + environment -This will make f, above, have arity 2. Then, we'll eta-expand it thus: +* And combine that into the result with andArityType. - f x eta = (join j y = ... in case x of ...) eta +In our example, the jump (j 20) will yield Bot, as will the jump +(j (n-1)). We'll 'and' those the ArityType of (\abc. blah). Good! -and the Simplify will automatically push that application of eta into -the join points. +In effect we are treating the RHSs as alternative bodies (like +in a case), and ignoring all jumps. In this way we don't need +to take a fixpoint. Tricky! -An alternative (roughly equivalent) idea would be to carry an -environment mapping let-bound Ids to their ArityType. +NB: we treat /non-recursive/ join points in the same way, but +actually it works fine to treat them uniformly with normal +let-bindings, and that takes less code. -} idArityType :: Id -> ArityType ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -2144,19 +2144,32 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) (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 (m,_,_) = splitFunTy fun_ty - env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + -- Do this even if (contIsStop cont) + -- See Note [No eta-expansion in runRW#] + = do { let arg_env = arg_se `setInScopeFromE` env 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' } - -- cont' applies to s, then K - ; body' <- simplExprC env' arg cont' - ; let arg' = Lam s body' - rr' = getRuntimeRep ty' + + -- If the argument is a literal lambda already, take a short cut + -- This isn't just efficiency; if we don't do this we get a beta-redex + -- every time, so the simplifier keeps doing more iterations. + ; arg' <- case arg of + Lam s body -> do { (env', s') <- simplBinder arg_env s + ; body' <- simplExprC env' body cont + ; return (Lam s' body') } + -- Important: do not try to eta-expand this lambda + -- See Note [No eta-expansion in runRW#] + _ -> do { s' <- newId (fsLit "s") Many realWorldStatePrimTy + ; let (m,_,_) = splitFunTy fun_ty + env' = arg_env `addNewInScopeIds` [s'] + cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s' + , sc_env = env', sc_cont = cont + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } + -- cont' applies to s', then K + ; body' <- simplExprC env' arg cont' + ; return (Lam s' body') } + + ; let rr' = getRuntimeRep ty' call' = mkApps (Var fun_id) [mkTyArg rr', mkTyArg ty', arg'] ; return (emptyFloats env, call') } @@ -2263,6 +2276,19 @@ to get the effect that finding (error "foo") in a strict arg position will discard the entire application and replace it with (error "foo"). Getting all this at once is TOO HARD! +Note [No eta-expansion in runRW#] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we see `runRW# (\s. blah)` we must not attempt to eta-expand that +lambda. Why not? Because +* `blah` can mention join points bound outside the runRW# +* eta-expansion uses arityType, and +* `arityType` cannot cope with free join Ids: + +So the simplifier spots the literal lambda, and simplifies inside it. +It's a very special lambda, because it is the one the OccAnal spots and +allows join points bound /outside/ to be called /inside/. + +See Note [No free join points in arityType] in GHC.Core.Opt.Arity ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1732,9 +1732,7 @@ tryEtaExpandRhs :: SimplEnv -> OutId -> OutExpr tryEtaExpandRhs env bndr rhs | Just join_arity <- isJoinId_maybe bndr = do { let (join_bndrs, join_body) = collectNBinders join_arity rhs - oss = [idOneShotInfo id | id <- join_bndrs, isId id] - arity_type | exprIsDeadEnd join_body = mkBotArityType oss - | otherwise = mkTopArityType oss + arity_type = mkManifestArityType join_bndrs join_body ; return (arity_type, rhs) } -- Note [Do not eta-expand join points] -- But do return the correct arity and bottom-ness, because ===================================== testsuite/tests/arityanal/should_compile/Arity17.hs ===================================== @@ -0,0 +1,27 @@ +module Bug (downsweep) where + +import GHC.Utils.Misc ( filterOut ) +import qualified Data.Map.Strict as M ( Map, elems ) +import qualified Data.Map as Map ( fromListWith ) + +type DownsweepCache = M.Map Int Int + +downsweep :: [Int] -> IO DownsweepCache +downsweep rootSummariesOk = do + let root_map = mkRootMap rootSummariesOk + checkDuplicates root_map + return root_map + where + checkDuplicates :: DownsweepCache -> IO () + checkDuplicates root_map = multiRootsErr dup_roots + where + dup_roots = filterOut (>2) (M.elems root_map) + +mkRootMap + :: [Int] + -> DownsweepCache +mkRootMap summaries = Map.fromListWith const + [ (s, s) | s <- summaries ] + +multiRootsErr :: [a] -> IO () +multiRootsErr [] = pure () ===================================== testsuite/tests/arityanal/should_compile/T21755.hs ===================================== @@ -0,0 +1,11 @@ +module T21755 where + +mySum :: [Int] -> Int +mySum [] = 0 +mySum (x:xs) = x + mySum xs + +f :: Int -> (Int -> Int) -> Int -> Int +f k z = + if even (mySum [0..k]) + then \n -> n + 1 + else \n -> z n ===================================== testsuite/tests/arityanal/should_compile/T21755.stderr ===================================== @@ -0,0 +1 @@ + \ No newline at end of file ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -16,8 +16,10 @@ test('Arity13', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn test('Arity14', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity15', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('Arity17', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-package ghc -dcore-lint -O2']) # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('T18870', [ only_ways(['optasm']) ], compile, ['-ddebug-output']) test('T18937', [ only_ways(['optasm']) ], compile, ['-ddebug-output']) +test('T21755', [ grep_errmsg(r'Arity=') ], compile, ['-O -dno-typeable-binds -fno-worker-wrapper']) ===================================== testsuite/tests/callarity/should_compile/T21694a.hs ===================================== @@ -0,0 +1,27 @@ +module Main (main) where + +import GHC.Exts +import Control.DeepSeq +import System.Exit + +-- If we eta expand the `False` branch will return +-- a lambda \eta -> z instead of z. +-- This behaves differently if the z argument is a bottom. +-- We used to assume that a oneshot annotation would mean +-- we could eta-expand on *all* branches. But this is clearly +-- not sound in this case. So we test for this here. +{-# NOINLINE f #-} +f :: Bool -> (Int -> Int) -> Int -> Int +f b z = + case b of + True -> oneShot $ \n -> n + 1 + False -> z + + + +main :: IO Int +main = do + return $! force $! f False (error "Urkh! But expected!") + return 0 + + ===================================== testsuite/tests/callarity/should_compile/T21694a.stderr ===================================== @@ -0,0 +1,3 @@ +T21694a: Urkh! But expected! +CallStack (from HasCallStack): + error, called at T21694a.hs:23:33 in main:Main ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -1,4 +1,6 @@ ref compiler/GHC/Core/Coercion/Axiom.hs:458:2: Note [RoughMap and rm_empty] +ref compiler/GHC/Core/Opt/Arity.hs:: Note [Combining case branches] +ref compiler/GHC/Core/Opt/Arity.hs:: Note [ArityType for let-bindings] ref compiler/GHC/Core/Opt/OccurAnal.hs:851:15: Note [Loop breaking] ref compiler/GHC/Core/Opt/SetLevels.hs:1598:30: Note [Top level scope] ref compiler/GHC/Core/Opt/Simplify.hs:2618:13: Note [Case binder next] ===================================== testsuite/tests/simplCore/should_compile/T21694b.hs ===================================== @@ -0,0 +1,6 @@ +module T21694 where + +-- f should get arity 4 +f x = let j 0 = \ a b c -> (a,x,b) + j n = j (n-1 :: Int) + in j 20 ===================================== testsuite/tests/simplCore/should_compile/T21694b.stderr ===================================== @@ -0,0 +1,115 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 44, types: 40, coercions: 0, joins: 2/2} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T21694.f1 :: Int +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T21694.f1 = GHC.Types.I# 20# + +-- RHS size: {terms: 26, types: 22, coercions: 0, joins: 2/2} +f :: forall {p1} {a} {c} {p2}. p1 -> a -> c -> p2 -> (a, p1, c) +[GblId, + Arity=4, + Str=, + Cpr=1, + 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= \ (@p_ax8) + (@a_aL5) + (@c_aL6) + (@p1_aL7) + (x_agu [Occ=OnceL1] :: p_ax8) + (eta_B0 [Occ=OnceL1] :: a_aL5) + (eta1_B1 [Occ=OnceL1] :: c_aL6) + _ [Occ=Dead] -> + joinrec { + j_sLX [InlPrag=[2], Occ=T[1]] :: Int -> (a_aL5, p_ax8, c_aL6) + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=, + Unf=Unf{Src=InlineStable, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (ds_sM1 [Occ=Once1!] :: Int) -> + case ds_sM1 of { GHC.Types.I# ww_sM3 [Occ=Once1] -> + jump $wj_sM6 ww_sM3 + }}] + j_sLX (ds_sM1 [Occ=Once1!] :: Int) + = case ds_sM1 of { GHC.Types.I# ww_sM3 [Occ=Once1] -> + jump $wj_sM6 ww_sM3 + }; + $wj_sM6 [InlPrag=[2], Occ=LoopBreakerT[1]] + :: GHC.Prim.Int# -> (a_aL5, p_ax8, c_aL6) + [LclId[JoinId(1)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $wj_sM6 (ww_sM3 [Occ=Once1!] :: GHC.Prim.Int#) + = case ww_sM3 of ds_X2 [Occ=Once1] { + __DEFAULT -> jump j_sLX (GHC.Types.I# (GHC.Prim.-# ds_X2 1#)); + 0# -> (eta_B0, x_agu, eta1_B1) + }; } in + jump j_sLX T21694.f1}] +f = \ (@p_ax8) + (@a_aL5) + (@c_aL6) + (@p1_aL7) + (x_agu :: p_ax8) + (eta_B0 :: a_aL5) + (eta1_B1 :: c_aL6) + _ [Occ=Dead] -> + join { + exit_X3 [Dmd=S!P(L,L,L)] :: (a_aL5, p_ax8, c_aL6) + [LclId[JoinId(0)(Nothing)]] + exit_X3 = (eta_B0, x_agu, eta1_B1) } in + joinrec { + $wj_sM6 [InlPrag=[2], Occ=LoopBreaker, Dmd=SCS(!P(L,L,L))] + :: GHC.Prim.Int# -> (a_aL5, p_ax8, c_aL6) + [LclId[JoinId(1)(Nothing)], Arity=1, Str=<1L>, Unf=OtherCon []] + $wj_sM6 (ww_sM3 :: GHC.Prim.Int#) + = case ww_sM3 of ds_X2 { + __DEFAULT -> jump $wj_sM6 (GHC.Prim.-# ds_X2 1#); + 0# -> jump exit_X3 + }; } in + jump $wj_sM6 20# + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T21694.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T21694.$trModule3 = GHC.Types.TrNameS T21694.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T21694.$trModule2 = "T21694"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T21694.$trModule1 = GHC.Types.TrNameS T21694.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T21694.$trModule + = GHC.Types.Module T21694.$trModule3 T21694.$trModule1 + + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6fdb0dd21bb8632a427044e2df94e6409c45d363 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6fdb0dd21bb8632a427044e2df94e6409c45d363 You're receiving 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 Nov 1 18:29:29 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 01 Nov 2022 14:29:29 -0400 Subject: [Git][ghc/ghc][wip/backports-9.4] Fix arityType: -fpedantic-bottoms, join points, etc Message-ID: <63616589e1e04_815bc515a4449077@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.4 at Glasgow Haskell Compiler / GHC Commits: aeefb36f by Simon Peyton Jones at 2022-11-01T14:29:08-04:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694 and #21755 * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * I realised that, now we have ae_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. And finally, it was the strange treatment of join-point Ids (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring * Rewrote Note [Combining case branches: optimistic one-shot-ness] Compile time improves slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- CoOpt_Read(normal) ghc/alloc 803,788,056 747,832,680 -7.1% GOOD T18223(normal) ghc/alloc 928,207,320 959,424,016 +3.1% BAD geo. mean -0.3% minimum -7.1% maximum +3.1% On Windows it's a bit better: geo mean is -0.6%, and three more benchmarks trip their compile-time bytes-allocated threshold (they were all close on the other build): T18698b(normal) ghc/alloc 235,619,776 233,219,008 -1.0% GOOD T6048(optasm) ghc/alloc 112,208,192 109,704,936 -2.2% GOOD T18140(normal) ghc/alloc 85,064,192 83,168,360 -2.2% GOOD I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3.4% increase in exchange for goodness elsewhere. Metric Decrease: CoOpt_Read LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp T10421 T12425 T12707 T13035 T13253 T13379 T14683 T15703 T18698a T1969 T3064 T3294 T4801 T5321FD T5321Fun T5631 T783 T9020 T9198 T9233 T9872b T9872c T9961 parsing001 Metric Increase: T18223 (cherry picked from commit 5e282da37e19a1ab24ae167daf32276a64ed2842) - - - - - 13 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/arityanal/should_compile/Arity17.hs - + testsuite/tests/arityanal/should_compile/T21755.hs - + testsuite/tests/arityanal/should_compile/T21755.stderr - testsuite/tests/arityanal/should_compile/all.T - + testsuite/tests/callarity/should_compile/T21694a.hs - + testsuite/tests/callarity/should_compile/T21694a.stderr - testsuite/tests/linters/notes.stdout - + testsuite/tests/simplCore/should_compile/T21694b.hs - + testsuite/tests/simplCore/should_compile/T21694b.stderr Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -739,6 +739,7 @@ Join points must follow these invariants: The arity of a join point isn't very important; but short of setting it to zero, it is helpful to have an invariant. E.g. #17294. + See also Note [Do not eta-expand join points] in GHC.Core.Opt.Simplify.Utils. 3. If the binding is recursive, then all other bindings in the recursive group must also be join points. ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -17,7 +17,7 @@ module GHC.Core.Opt.Arity , exprBotStrictness_maybe -- ** ArityType - , ArityType(..), mkBotArityType, mkTopArityType, expandableArityType + , ArityType(..), mkBotArityType, mkManifestArityType, expandableArityType , arityTypeArity, maxWithArity, idArityType -- ** Join points @@ -53,7 +53,6 @@ import GHC.Types.Demand import GHC.Types.Var import GHC.Types.Var.Env import GHC.Types.Id -import GHC.Types.Var.Set import GHC.Types.Basic import GHC.Types.Tickish @@ -594,7 +593,8 @@ same fix. -- where the @at@ fields of @ALam@ are inductively subject to the same order. -- That is, @ALam os at1 < ALam os at2@ iff @at1 < at2 at . -- --- Why the strange Top element? See Note [Combining case branches]. +-- Why the strange Top element? +-- See Note [Combining case branches: optimistic one-shot-ness] -- -- We rely on this lattice structure for fixed-point iteration in -- 'findRhsArity'. For the semantics of 'ArityType', see Note [ArityType]. @@ -641,11 +641,16 @@ mkBotArityType oss = AT oss botDiv botArityType :: ArityType botArityType = mkBotArityType [] -mkTopArityType :: [OneShotInfo] -> ArityType -mkTopArityType oss = AT oss topDiv +mkManifestArityType :: [Var] -> CoreExpr -> ArityType +mkManifestArityType bndrs body + = AT oss div + where + oss = [idOneShotInfo bndr | bndr <- bndrs, isId bndr] + div | exprIsDeadEnd body = botDiv + | otherwise = topDiv topArityType :: ArityType -topArityType = mkTopArityType [] +topArityType = AT [] topDiv -- | The number of value args for the arity type arityTypeArity :: ArityType -> Arity @@ -685,7 +690,7 @@ takeWhileOneShot (AT oss div) exprEtaExpandArity :: DynFlags -> CoreExpr -> ArityType -- exprEtaExpandArity is used when eta expanding -- e ==> \xy -> e x y -exprEtaExpandArity dflags e = arityType (etaExpandArityEnv dflags) e +exprEtaExpandArity dflags e = arityType (findRhsArityEnv dflags) e getBotArity :: ArityType -> Maybe Arity -- Arity of a divergent function @@ -825,6 +830,7 @@ floatIn cheap at | otherwise = takeWhileOneShot at arityApp :: ArityType -> Bool -> ArityType + -- Processing (fun arg) where at is the ArityType of fun, -- Knock off an argument and behave like 'let' arityApp (AT (_:oss) div) cheap = floatIn cheap (AT oss div) @@ -834,16 +840,30 @@ arityApp at _ = at -- See the haddocks on 'ArityType' for the lattice. -- -- Used for branches of a @case at . -andArityType :: ArityType -> ArityType -> ArityType -andArityType (AT (os1:oss1) div1) (AT (os2:oss2) div2) - | AT oss' div' <- andArityType (AT oss1 div1) (AT oss2 div2) - = AT ((os1 `bestOneShot` os2) : oss') div' -- See Note [Combining case branches] -andArityType at1@(AT [] div1) at2 - | isDeadEndDiv div1 = at2 -- Note [ABot branches: max arity wins] - | otherwise = at1 -- See Note [Combining case branches] -andArityType at1 at2@(AT [] div2) - | isDeadEndDiv div2 = at1 -- Note [ABot branches: max arity wins] - | otherwise = at2 -- See Note [Combining case branches] +andArityType :: ArityEnv -> ArityType -> ArityType -> ArityType +andArityType env (AT (lam1:lams1) div1) (AT (lam2:lams2) div2) + | AT lams' div' <- andArityType env (AT lams1 div1) (AT lams2 div2) + = AT ((lam1 `and_lam` lam2) : lams') div' + where + (os1) `and_lam` (os2) + = ( os1 `bestOneShot` os2) + -- bestOneShot: see Note [Combining case branches: optimistic one-shot-ness] + +andArityType env (AT [] div1) at2 = andWithTail env div1 at2 +andArityType env at1 (AT [] div2) = andWithTail env div2 at1 + +andWithTail :: ArityEnv -> Divergence -> ArityType -> ArityType +andWithTail env div1 at2@(AT lams2 _) + | isDeadEndDiv div1 -- case x of { T -> error; F -> \y.e } + = at2 -- Note [ABot branches: max arity wins] + + | pedanticBottoms env -- Note [Combining case branches: andWithTail] + = AT [] topDiv + + | otherwise -- case x of { T -> plusInt ; F -> \y.e } + = AT lams2 topDiv -- We know div1 = topDiv + -- See Note [Combining case branches: andWithTail] + {- Note [ABot branches: max arity wins] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -854,8 +874,60 @@ Consider case x of Remember: \o1..on.⊥ means "if you apply to n args, it'll definitely diverge". So we need \??.⊥ for the whole thing, the /max/ of both arities. -Note [Combining case branches] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Note [Combining case branches: optimistic one-shot-ness] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When combining the ArityTypes for two case branches (with andArityType) +and both ArityTypes have ATLamInfo, then we just combine their +expensive-ness and one-shot info. The tricky point is when we have + case x of True -> \x{one-shot). blah1 + Fale -> \y. blah2 + +Since one-shot-ness is about the /consumer/ not the /producer/, we +optimistically assume that if either branch is one-shot, we combine +the best of the two branches, on the (slightly dodgy) basis that if we +know one branch is one-shot, then they all must be. Surprisingly, +this means that the one-shot arity type is effectively the top element +of the lattice. + +Hence the call to `bestOneShot` in `andArityType`. + +Note [Combining case branches: andWithTail] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When combining the ArityTypes for two case branches (with andArityType) +and one side or the other has run out of ATLamInfo; then we get +into `andWithTail`. + +* If one branch is guaranteed bottom (isDeadEndDiv), we just take + the other; see Note [ABot branches: max arity wins] + +* Otherwise, if pedantic-bottoms is on, we just have to return + AT [] topDiv. E.g. if we have + f x z = case x of True -> \y. blah + False -> z + then we can't eta-expand, because that would change the behaviour + of (f False bottom(). + +* But if pedantic-bottoms is not on, we allow ourselves to push + `z` under a lambda (much as we allow ourselves to put the `case x` + under a lambda). However we know nothing about the expensiveness + or one-shot-ness of `z`, so we'd better assume it looks like + (Expensive, NoOneShotInfo) all the way. Remembering + Note [Combining case branches: optimistic one-shot-ness], + we just add work to ever ATLamInfo, keeping the one-shot-ness. + +Here's an example: + go = \x. let z = go e0 + go2 = \x. case x of + True -> z + False -> \s(one-shot). e1 + in go2 x +We *really* want to respect the one-shot annotation provided by the +user and eta-expand go and go2. +When combining the branches of the case we have + T `andAT` \1.T +and we want to get \1.T. +But if the inner lambda wasn't one-shot (\?.T) we don't want to do this. +(We need a usage analysis to justify that.) Unless we can conclude that **all** branches are safe to eta-expand then we must pessimisticaly conclude that we can't eta-expand. See #21694 for where this @@ -934,22 +1006,21 @@ data ArityEnv = AE { ae_mode :: !AnalysisMode -- ^ The analysis mode. See 'AnalysisMode'. - , ae_joins :: !IdSet - -- ^ In-scope join points. See Note [Eta-expansion and join points] - -- INVARIANT: Disjoint with the domain of 'am_sigs' (if present). } -- | The @ArityEnv@ used by 'exprBotStrictness_maybe'. Pedantic about bottoms -- and no application is ever considered cheap. botStrictnessArityEnv :: ArityEnv -botStrictnessArityEnv = AE { ae_mode = BotStrictness, ae_joins = emptyVarSet } +botStrictnessArityEnv = AE { ae_mode = BotStrictness } +{- -- | The @ArityEnv@ used by 'exprEtaExpandArity'. etaExpandArityEnv :: DynFlags -> ArityEnv etaExpandArityEnv dflags = AE { ae_mode = EtaExpandArity { am_ped_bot = gopt Opt_PedanticBottoms dflags , am_dicts_cheap = gopt Opt_DictsCheap dflags } , ae_joins = emptyVarSet } +-} -- | The @ArityEnv@ used by 'findRhsArity'. findRhsArityEnv :: DynFlags -> ArityEnv @@ -957,7 +1028,11 @@ findRhsArityEnv dflags = AE { ae_mode = FindRhsArity { am_ped_bot = gopt Opt_PedanticBottoms dflags , am_dicts_cheap = gopt Opt_DictsCheap dflags , am_sigs = emptyVarEnv } - , ae_joins = emptyVarSet } + } + +isFindRhsArity :: ArityEnv -> Bool +isFindRhsArity (AE { ae_mode = FindRhsArity {} }) = True +isFindRhsArity _ = False -- First some internal functions in snake_case for deleting in certain VarEnvs -- of the ArityType. Don't call these; call delInScope* instead! @@ -976,32 +1051,17 @@ del_sig_env_list :: [Id] -> ArityEnv -> ArityEnv -- internal! del_sig_env_list ids = modifySigEnv (\sigs -> delVarEnvList sigs ids) {-# INLINE del_sig_env_list #-} -del_join_env :: JoinId -> ArityEnv -> ArityEnv -- internal! -del_join_env id env@(AE { ae_joins = joins }) - = env { ae_joins = delVarSet joins id } -{-# INLINE del_join_env #-} - -del_join_env_list :: [JoinId] -> ArityEnv -> ArityEnv -- internal! -del_join_env_list ids env@(AE { ae_joins = joins }) - = env { ae_joins = delVarSetList joins ids } -{-# INLINE del_join_env_list #-} - -- end of internal deletion functions -extendJoinEnv :: ArityEnv -> [JoinId] -> ArityEnv -extendJoinEnv env@(AE { ae_joins = joins }) join_ids - = del_sig_env_list join_ids - $ env { ae_joins = joins `extendVarSetList` join_ids } - extendSigEnv :: ArityEnv -> Id -> ArityType -> ArityEnv extendSigEnv env id ar_ty - = del_join_env id (modifySigEnv (\sigs -> extendVarEnv sigs id ar_ty) env) + = modifySigEnv (\sigs -> extendVarEnv sigs id ar_ty) env delInScope :: ArityEnv -> Id -> ArityEnv -delInScope env id = del_join_env id $ del_sig_env id env +delInScope env id = del_sig_env id env delInScopeList :: ArityEnv -> [Id] -> ArityEnv -delInScopeList env ids = del_join_env_list ids $ del_sig_env_list ids env +delInScopeList env ids = del_sig_env_list ids env lookupSigEnv :: ArityEnv -> Id -> Maybe ArityType lookupSigEnv AE{ ae_mode = mode } id = case mode of @@ -1046,8 +1106,11 @@ myIsCheapApp :: IdEnv ArityType -> CheapAppFun myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of -- Nothing means not a local function, fall back to regular -- 'GHC.Core.Utils.isCheapApp' - Nothing -> isCheapApp fn n_val_args - -- @Just at@ means local function with @at@ as current ArityType. + Nothing -> isCheapApp fn n_val_args + + -- `Just at` means local function with `at` as current SafeArityType. + -- NB the SafeArityType bit: that means we can ignore the cost flags + -- in 'lams', and just consider the length -- Roughly approximate what 'isCheapApp' is doing. Just (AT oss div) | isDeadEndDiv div -> True -- See Note [isCheapApp: bottoming functions] in GHC.Core.Utils @@ -1055,7 +1118,10 @@ myIsCheapApp sigs fn n_val_args = case lookupVarEnv sigs fn of | otherwise -> False ---------------- -arityType :: ArityEnv -> CoreExpr -> ArityType +arityType :: HasDebugCallStack => ArityEnv -> CoreExpr -> ArityType +-- Precondition: all the free join points of the expression +-- are bound by the ArityEnv +-- See Note [No free join points in arityType] arityType env (Cast e co) = minWithArity (arityType env e) co_arity -- See Note [Arity trimming] @@ -1067,12 +1133,13 @@ arityType env (Cast e co) -- #5441 is a nice demo arityType env (Var v) - | v `elemVarSet` ae_joins env - = botArityType -- See Note [Eta-expansion and join points] | Just at <- lookupSigEnv env v -- Local binding = at | otherwise - = idArityType v + = assertPpr (not (isFindRhsArity env && isJoinId v)) (ppr v) $ + -- All join-point should be in the ae_sigs + -- See Note [No free join points in arityType] + idArityType v -- Lambdas; increase arity arityType env (Lam x e) @@ -1109,32 +1176,11 @@ arityType env (Case scrut bndr _ alts) where env' = delInScope env bndr arity_type_alt (Alt _con bndrs rhs) = arityType (delInScopeList env' bndrs) rhs - alts_type = foldr1 andArityType (map arity_type_alt 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) + alts_type = foldr1 (andArityType env) (map arity_type_alt alts) arityType env (Let (NonRec b r) e) - = floatIn cheap_rhs (arityType env' e) + = -- See Note [arityType for let-bindings] + floatIn cheap_rhs (arityType env' e) where cheap_rhs = myExprIsCheap env r (Just (idType b)) env' = extendSigEnv env b (arityType env r) @@ -1142,17 +1188,76 @@ arityType env (Let (NonRec b r) e) arityType env (Let (Rec prs) e) = floatIn (all is_cheap prs) (arityType env' e) where - env' = delInScopeList env (map fst prs) is_cheap (b,e) = myExprIsCheap env' e (Just (idType b)) + env' = foldl extend_rec env prs + extend_rec :: ArityEnv -> (Id,CoreExpr) -> ArityEnv + extend_rec env (b,e) = extendSigEnv env b $ + mkManifestArityType bndrs body + where + (bndrs, body) = collectBinders e + -- We can't call arityType on the RHS, because it might mention + -- join points bound in this very letrec, and we don't want to + -- do a fixpoint calculation here. So we make do with the + -- manifest arity arityType env (Tick t e) | not (tickishIsCode t) = arityType env e arityType _ _ = topArityType -{- Note [Eta-expansion and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Consider this (#18328) + +{- Note [No free join points in arityType] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we call arityType on this expression (EX1) + \x . case x of True -> \y. e + False -> $j 3 +where $j is a join point. It really makes no sense to talk of the arity +of this expression, because it has a free join point. In particular, we +can't eta-expand the expression because we'd have do the same thing to the +binding of $j, and we can't see that binding. + +If we had (EX2) + \x. join $j y = blah + case x of True -> \y. e + False -> $j 3 +then it would make perfect sense: we can determine $j's ArityType, and +propagate it to the usage site as usual. + +But how can we get (EX1)? It doesn't make much sense, because $j can't +be a join point under the \x anyway. So we make it a precondition of +arityType that the argument has no free join-point Ids. (This is checked +with an assesrt in the Var case of arityType.) + +BUT the invariant risks being invalidated by one very narrow special case: runRW# + join $j y = blah + runRW# (\s. case x of True -> \y. e + False -> $j x) + +We have special magic in OccurAnal, and Simplify to allow continuations to +move into the body of a runRW# call. + +So we are careful never to attempt to eta-expand the (\s.blah) in the +argument to runRW#, at least not when there is a literal lambda there, +so that OccurAnal has seen it and allowed join points bound outside. +See Note [No eta-expansion in runRW#] in GHC.Core.Opt.Simplify.Iteration. + +Note [arityType for let-bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For non-recursive let-bindings, we just get the arityType of the RHS, +and extend the environment. That works nicely for things like this +(#18793): + go = \ ds. case ds_a2CF of { + [] -> id + : y ys -> case y of { GHC.Types.I# x -> + let acc = go ys in + case x ># 42# of { + __DEFAULT -> acc + 1# -> \x1. acc (negate x2) + +Here we want to get a good arity for `acc`, based on the ArityType +of `go`. + +All this is particularly important for join points. Consider this (#18328) f x = join j y = case y of True -> \a. blah @@ -1165,42 +1270,64 @@ Consider this (#18328) 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. +lambda. It's important that we extend the envt with j's ArityType, +so that we can use that information in the A/C branch of the case. + +For /recursive/ bindings it's more difficult, to call arityType, +because we don't have an ArityType to put in the envt for the +recursively bound Ids. So for non-join-point bindings we satisfy +ourselves with mkManifestArityType. Typically we'll have eta-expanded +the binding (based on an earlier fixpoint calculation in +findRhsArity), so the manifest arity is good. + +But for /recursive join points/ things are not so good. +See Note [Arity type for recursive join bindings] + +See Note [Arity type for recursive join bindings] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider + f x = joinrec j 0 = \ a b c -> (a,x,b) + j n = j (n-1) + in j 20 -Why don't we eta-expand j? Because of -Note [Do not eta-expand join points] in GHC.Core.Opt.Simplify.Utils +Obviously `f` should get arity 4. But the manifest arity of `j` +is 1. Remember, we don't eta-expand join points; see +GHC.Core.Opt.Simplify.Utils Note [Do not eta-expand join points]. +And the ArityInfo on `j` will be just 1 too; see GHC.Core +Note [Invariants on join points], item (2b). So using +Note [ArityType for let-bindings] won't work well. -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. +We could do a fixpoint iteration, but that's a heavy hammer +to use in arityType. So we take advantage of it being a join +point: -So we do this: +* Extend the ArityEnv to bind each of the recursive binders + (all join points) to `botArityType`. This means that any + jump to the join point will return botArityType, which is + unit for `andArityType`: + botAritType `andArityType` at = at + So it's almost as if those "jump" branches didn't exist. -* 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. +* In this extended env, find the ArityType of each of the RHS, after + stripping off the join-point binders. -* Dually, when we come to a /call/ of a join point, just no-op - by returning ABot, the bottom element of ArityType, - which so that: bot `andArityType` x = x +* Use andArityType to combine all these RHS ArityTypes. -* 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. - Bad things happen. So we keep track of the in-scope join-point Ids - in ae_join. +* Find the ArityType of the body, also in this strange extended + environment -This will make f, above, have arity 2. Then, we'll eta-expand it thus: +* And combine that into the result with andArityType. - f x eta = (join j y = ... in case x of ...) eta +In our example, the jump (j 20) will yield Bot, as will the jump +(j (n-1)). We'll 'and' those the ArityType of (\abc. blah). Good! -and the Simplify will automatically push that application of eta into -the join points. +In effect we are treating the RHSs as alternative bodies (like +in a case), and ignoring all jumps. In this way we don't need +to take a fixpoint. Tricky! -An alternative (roughly equivalent) idea would be to carry an -environment mapping let-bound Ids to their ArityType. +NB: we treat /non-recursive/ join points in the same way, but +actually it works fine to treat them uniformly with normal +let-bindings, and that takes less code. -} idArityType :: Id -> ArityType ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -2144,19 +2144,32 @@ rebuildCall env (ArgInfo { ai_fun = fun_id, ai_args = rev_args }) (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 (m,_,_) = splitFunTy fun_ty - env' = (arg_se `setInScopeFromE` env) `addNewInScopeIds` [s] + -- Do this even if (contIsStop cont) + -- See Note [No eta-expansion in runRW#] + = do { let arg_env = arg_se `setInScopeFromE` env 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' } - -- cont' applies to s, then K - ; body' <- simplExprC env' arg cont' - ; let arg' = Lam s body' - rr' = getRuntimeRep ty' + + -- If the argument is a literal lambda already, take a short cut + -- This isn't just efficiency; if we don't do this we get a beta-redex + -- every time, so the simplifier keeps doing more iterations. + ; arg' <- case arg of + Lam s body -> do { (env', s') <- simplBinder arg_env s + ; body' <- simplExprC env' body cont + ; return (Lam s' body') } + -- Important: do not try to eta-expand this lambda + -- See Note [No eta-expansion in runRW#] + _ -> do { s' <- newId (fsLit "s") Many realWorldStatePrimTy + ; let (m,_,_) = splitFunTy fun_ty + env' = arg_env `addNewInScopeIds` [s'] + cont' = ApplyToVal { sc_dup = Simplified, sc_arg = Var s' + , sc_env = env', sc_cont = cont + , sc_hole_ty = mkVisFunTy m realWorldStatePrimTy ty' } + -- cont' applies to s', then K + ; body' <- simplExprC env' arg cont' + ; return (Lam s' body') } + + ; let rr' = getRuntimeRep ty' call' = mkApps (Var fun_id) [mkTyArg rr', mkTyArg ty', arg'] ; return (emptyFloats env, call') } @@ -2263,6 +2276,19 @@ to get the effect that finding (error "foo") in a strict arg position will discard the entire application and replace it with (error "foo"). Getting all this at once is TOO HARD! +Note [No eta-expansion in runRW#] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When we see `runRW# (\s. blah)` we must not attempt to eta-expand that +lambda. Why not? Because +* `blah` can mention join points bound outside the runRW# +* eta-expansion uses arityType, and +* `arityType` cannot cope with free join Ids: + +So the simplifier spots the literal lambda, and simplifies inside it. +It's a very special lambda, because it is the one the OccAnal spots and +allows join points bound /outside/ to be called /inside/. + +See Note [No free join points in arityType] in GHC.Core.Opt.Arity ************************************************************************ * * ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -1732,9 +1732,7 @@ tryEtaExpandRhs :: SimplEnv -> OutId -> OutExpr tryEtaExpandRhs env bndr rhs | Just join_arity <- isJoinId_maybe bndr = do { let (join_bndrs, join_body) = collectNBinders join_arity rhs - oss = [idOneShotInfo id | id <- join_bndrs, isId id] - arity_type | exprIsDeadEnd join_body = mkBotArityType oss - | otherwise = mkTopArityType oss + arity_type = mkManifestArityType join_bndrs join_body ; return (arity_type, rhs) } -- Note [Do not eta-expand join points] -- But do return the correct arity and bottom-ness, because ===================================== testsuite/tests/arityanal/should_compile/Arity17.hs ===================================== @@ -0,0 +1,27 @@ +module Bug (downsweep) where + +import GHC.Utils.Misc ( filterOut ) +import qualified Data.Map.Strict as M ( Map, elems ) +import qualified Data.Map as Map ( fromListWith ) + +type DownsweepCache = M.Map Int Int + +downsweep :: [Int] -> IO DownsweepCache +downsweep rootSummariesOk = do + let root_map = mkRootMap rootSummariesOk + checkDuplicates root_map + return root_map + where + checkDuplicates :: DownsweepCache -> IO () + checkDuplicates root_map = multiRootsErr dup_roots + where + dup_roots = filterOut (>2) (M.elems root_map) + +mkRootMap + :: [Int] + -> DownsweepCache +mkRootMap summaries = Map.fromListWith const + [ (s, s) | s <- summaries ] + +multiRootsErr :: [a] -> IO () +multiRootsErr [] = pure () ===================================== testsuite/tests/arityanal/should_compile/T21755.hs ===================================== @@ -0,0 +1,11 @@ +module T21755 where + +mySum :: [Int] -> Int +mySum [] = 0 +mySum (x:xs) = x + mySum xs + +f :: Int -> (Int -> Int) -> Int -> Int +f k z = + if even (mySum [0..k]) + then \n -> n + 1 + else \n -> z n ===================================== testsuite/tests/arityanal/should_compile/T21755.stderr ===================================== @@ -0,0 +1 @@ + \ No newline at end of file ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -16,8 +16,10 @@ test('Arity13', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn test('Arity14', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity15', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('Arity17', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-package ghc -dcore-lint -O2']) # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('T18870', [ only_ways(['optasm']) ], compile, ['-ddebug-output']) test('T18937', [ only_ways(['optasm']) ], compile, ['-ddebug-output']) +test('T21755', [ grep_errmsg(r'Arity=') ], compile, ['-O -dno-typeable-binds -fno-worker-wrapper']) ===================================== testsuite/tests/callarity/should_compile/T21694a.hs ===================================== @@ -0,0 +1,27 @@ +module Main (main) where + +import GHC.Exts +import Control.DeepSeq +import System.Exit + +-- If we eta expand the `False` branch will return +-- a lambda \eta -> z instead of z. +-- This behaves differently if the z argument is a bottom. +-- We used to assume that a oneshot annotation would mean +-- we could eta-expand on *all* branches. But this is clearly +-- not sound in this case. So we test for this here. +{-# NOINLINE f #-} +f :: Bool -> (Int -> Int) -> Int -> Int +f b z = + case b of + True -> oneShot $ \n -> n + 1 + False -> z + + + +main :: IO Int +main = do + return $! force $! f False (error "Urkh! But expected!") + return 0 + + ===================================== testsuite/tests/callarity/should_compile/T21694a.stderr ===================================== @@ -0,0 +1,3 @@ +T21694a: Urkh! But expected! +CallStack (from HasCallStack): + error, called at T21694a.hs:23:33 in main:Main ===================================== testsuite/tests/linters/notes.stdout ===================================== @@ -1,4 +1,6 @@ ref compiler/GHC/Core/Coercion/Axiom.hs:458:2: Note [RoughMap and rm_empty] +ref compiler/GHC/Core/Opt/Arity.hs:: Note [Combining case branches] +ref compiler/GHC/Core/Opt/Arity.hs:: Note [ArityType for let-bindings] ref compiler/GHC/Core/Opt/OccurAnal.hs:851:15: Note [Loop breaking] ref compiler/GHC/Core/Opt/SetLevels.hs:1598:30: Note [Top level scope] ref compiler/GHC/Core/Opt/Simplify.hs:2618:13: Note [Case binder next] ===================================== testsuite/tests/simplCore/should_compile/T21694b.hs ===================================== @@ -0,0 +1,6 @@ +module T21694 where + +-- f should get arity 4 +f x = let j 0 = \ a b c -> (a,x,b) + j n = j (n-1 :: Int) + in j 20 ===================================== testsuite/tests/simplCore/should_compile/T21694b.stderr ===================================== @@ -0,0 +1,115 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 44, types: 40, coercions: 0, joins: 2/2} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T21694.f1 :: Int +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T21694.f1 = GHC.Types.I# 20# + +-- RHS size: {terms: 26, types: 22, coercions: 0, joins: 2/2} +f :: forall {p1} {a} {c} {p2}. p1 -> a -> c -> p2 -> (a, p1, c) +[GblId, + Arity=4, + Str=, + Cpr=1, + 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= \ (@p_ax8) + (@a_aL5) + (@c_aL6) + (@p1_aL7) + (x_agu [Occ=OnceL1] :: p_ax8) + (eta_B0 [Occ=OnceL1] :: a_aL5) + (eta1_B1 [Occ=OnceL1] :: c_aL6) + _ [Occ=Dead] -> + joinrec { + j_sLX [InlPrag=[2], Occ=T[1]] :: Int -> (a_aL5, p_ax8, c_aL6) + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=, + Unf=Unf{Src=InlineStable, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (ds_sM1 [Occ=Once1!] :: Int) -> + case ds_sM1 of { GHC.Types.I# ww_sM3 [Occ=Once1] -> + jump $wj_sM6 ww_sM3 + }}] + j_sLX (ds_sM1 [Occ=Once1!] :: Int) + = case ds_sM1 of { GHC.Types.I# ww_sM3 [Occ=Once1] -> + jump $wj_sM6 ww_sM3 + }; + $wj_sM6 [InlPrag=[2], Occ=LoopBreakerT[1]] + :: GHC.Prim.Int# -> (a_aL5, p_ax8, c_aL6) + [LclId[JoinId(1)(Nothing)], Arity=1, Str=, Unf=OtherCon []] + $wj_sM6 (ww_sM3 [Occ=Once1!] :: GHC.Prim.Int#) + = case ww_sM3 of ds_X2 [Occ=Once1] { + __DEFAULT -> jump j_sLX (GHC.Types.I# (GHC.Prim.-# ds_X2 1#)); + 0# -> (eta_B0, x_agu, eta1_B1) + }; } in + jump j_sLX T21694.f1}] +f = \ (@p_ax8) + (@a_aL5) + (@c_aL6) + (@p1_aL7) + (x_agu :: p_ax8) + (eta_B0 :: a_aL5) + (eta1_B1 :: c_aL6) + _ [Occ=Dead] -> + join { + exit_X3 [Dmd=S!P(L,L,L)] :: (a_aL5, p_ax8, c_aL6) + [LclId[JoinId(0)(Nothing)]] + exit_X3 = (eta_B0, x_agu, eta1_B1) } in + joinrec { + $wj_sM6 [InlPrag=[2], Occ=LoopBreaker, Dmd=SCS(!P(L,L,L))] + :: GHC.Prim.Int# -> (a_aL5, p_ax8, c_aL6) + [LclId[JoinId(1)(Nothing)], Arity=1, Str=<1L>, Unf=OtherCon []] + $wj_sM6 (ww_sM3 :: GHC.Prim.Int#) + = case ww_sM3 of ds_X2 { + __DEFAULT -> jump $wj_sM6 (GHC.Prim.-# ds_X2 1#); + 0# -> jump exit_X3 + }; } in + jump $wj_sM6 20# + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T21694.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T21694.$trModule3 = GHC.Types.TrNameS T21694.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T21694.$trModule2 = "T21694"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T21694.$trModule1 = GHC.Types.TrNameS T21694.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T21694.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T21694.$trModule + = GHC.Types.Module T21694.$trModule3 T21694.$trModule1 + + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aeefb36f940566aeee8d47a67cf11c2bb4cb2961 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/aeefb36f940566aeee8d47a67cf11c2bb4cb2961 You're receiving 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 Nov 1 19:54:06 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Tue, 01 Nov 2022 15:54:06 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 3 commits: Hadrian: add no_dynamic_libs transformer Message-ID: <6361795e88d16_815bc515cc451786@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 13ac3f69 by doyougnu at 2022-11-01T15:53:44-04:00 Hadrian: add no_dynamic_libs transformer - - - - - a274e077 by doyougnu at 2022-11-01T15:53:44-04:00 Hadrian: Add releaseJsFlavour - - - - - 8f1832fb by doyougnu at 2022-11-01T15:53:44-04:00 Hadrian: Add enableO2Stage0 transformer And update release-js build flavour - - - - - 2 changed files: - hadrian/src/Flavour.hs - hadrian/src/Settings/Flavours/Release.hs Changes: ===================================== hadrian/src/Flavour.hs ===================================== @@ -10,7 +10,9 @@ module Flavour , enableDebugInfo, enableTickyGhc , viaLlvmBackend , enableProfiledGhc + , enableO2Stage0 , disableDynamicGhcPrograms + , disableDynamicLibs , disableProfiledLibs , enableLinting , enableHaddock @@ -38,26 +40,28 @@ import Oracles.Setting flavourTransformers :: Map String (Flavour -> Flavour) flavourTransformers = M.fromList - [ "werror" =: werror - , "debug_info" =: enableDebugInfo - , "ticky_ghc" =: enableTickyGhc - , "ticky_ghc0" =: enableTickyGhc0 - , "split_sections" =: splitSections + [ "werror" =: werror + , "debug_info" =: enableDebugInfo + , "ticky_ghc" =: enableTickyGhc + , "ticky_ghc0" =: enableTickyGhc0 + , "optimize_stage0" =: enableO2Stage0 + , "split_sections" =: splitSections , "thread_sanitizer" =: enableThreadSanitizer - , "llvm" =: viaLlvmBackend - , "profiled_ghc" =: enableProfiledGhc - , "no_dynamic_ghc" =: disableDynamicGhcPrograms + , "llvm" =: viaLlvmBackend + , "profiled_ghc" =: enableProfiledGhc + , "no_dynamic_ghc" =: disableDynamicGhcPrograms + , "no_dynamic_libs" =: disableDynamicLibs , "no_profiled_libs" =: disableProfiledLibs - , "omit_pragmas" =: omitPragmas - , "ipe" =: enableIPE - , "fully_static" =: fullyStatic - , "collect_timings" =: collectTimings - , "assertions" =: enableAssertions - , "debug_ghc" =: debugGhc Stage1 + , "omit_pragmas" =: omitPragmas + , "ipe" =: enableIPE + , "fully_static" =: fullyStatic + , "collect_timings" =: collectTimings + , "assertions" =: enableAssertions + , "debug_ghc" =: debugGhc Stage1 , "debug_stage1_ghc" =: debugGhc stage0InTree - , "lint" =: enableLinting - , "haddock" =: enableHaddock - , "late_ccs" =: enableLateCCS + , "lint" =: enableLinting + , "haddock" =: enableHaddock + , "late_ccs" =: enableLateCCS ] where (=:) = (,) @@ -70,7 +74,7 @@ parseFlavour :: [Flavour] -- ^ base flavours parseFlavour baseFlavours transformers str = case P.runParser parser () "" str of Left perr -> Left $ unlines $ - [ "error parsing flavour specifier: " ++ show perr + [ "error parsing flavour specifier: " ++ show perr , "" , "known flavours:" ] ++ @@ -106,6 +110,9 @@ parseFlavour baseFlavours transformers str = addArgs :: Args -> Flavour -> Flavour addArgs args' fl = fl { args = args fl <> args' } +onArgs :: (Args -> Args) -> Flavour -> Flavour +onArgs f fl = fl { args = f $ args fl} + -- | Turn on -Werror for packages built with the stage1 compiler. -- It mimics the CI settings so is useful to turn on when developing. werror :: Flavour -> Flavour @@ -128,6 +135,11 @@ enableTickyGhc = , builder (Ghc LinkHs) ? tickyArgs ] +-- | Enable the ticky-ticky profiler in stage1 GHC +enableO2Stage0 :: Flavour -> Flavour +enableO2Stage0 fl = onArgs ensureO2 fl + where ensureO2 as = (builder Ghc ? stage0 ? arg "-O2") <> remove ["-O"] as + -- | Enable the ticky-ticky profiler in stage1 GHC enableTickyGhc0 :: Flavour -> Flavour enableTickyGhc0 = @@ -222,6 +234,16 @@ enableProfiledGhc flavour = disableDynamicGhcPrograms :: Flavour -> Flavour disableDynamicGhcPrograms flavour = flavour { dynamicGhcPrograms = pure False } +-- | Don't build libraries in profiled 'Way's. +disableDynamicLibs :: Flavour -> Flavour +disableDynamicLibs flavour = + flavour { libraryWays = prune $ libraryWays flavour + } + where + prune :: Ways -> Ways + prune = fmap $ Set.filter (not . wayUnit Dynamic) + + -- | Don't build libraries in profiled 'Way's. disableProfiledLibs :: Flavour -> Flavour disableProfiledLibs flavour = ===================================== hadrian/src/Settings/Flavours/Release.hs ===================================== @@ -5,3 +5,10 @@ import Flavour releaseFlavour :: Flavour releaseFlavour = enableHaddock performanceFlavour { name = "release" } + +releaseJsFlavour :: Flavour +releaseJsFlavour = disableDynamicLibs + . disableDynamicGhcPrograms + . disableProfiledLibs + . enableO2Stage0 + $ performanceFlavour { name = "release-js" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/74f184ebc16c2bace9baeb5e3d8a4f90150ffec3...8f1832fb8ed32e66a83fb9604b28220874dfec5c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/74f184ebc16c2bace9baeb5e3d8a4f90150ffec3...8f1832fb8ed32e66a83fb9604b28220874dfec5c You're receiving 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 Nov 1 21:47:03 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 01 Nov 2022 17:47:03 -0400 Subject: [Git][ghc/ghc][wip/backports-9.4] 4 commits: Fix nested type splices in hie files Message-ID: <636193d7b7e32_815bc51428472289@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.4 at Glasgow Haskell Compiler / GHC Commits: edfa9f46 by Matthew Pickering at 2022-11-01T17:46:56-04:00 Fix nested type splices in hie files The issue is that when we compile a typed bracket we replace the splice with HsSpliced (unTypeCode ...). Then when computing types for > [|| T $$(...) ||] GHC is asked to compute the type of `T $$(..)`, which panics because of the bogus type of T applied to `HsSpliced`, which is not type correct. The fix is to not attempt to compute the type for `HsSpliceE` constructors if we come across them as they should have either been already evaluated or lifted into a splice environment. As part of the patch I made hie files traverse into the splice environments so now we also get type information for things used inside nested splices. Fixes #21619 - - - - - 27f5c67e by Alan Zimmerman at 2022-11-01T17:46:56-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 (cherry picked from commit 792ef44d455c6e987f342fb61515464322a9fa77) - - - - - 0633665f by Simon Peyton Jones at 2022-11-01T17:46:56-04:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694 and #21755 * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * I realised that, now we have ae_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. And finally, it was the strange treatment of join-point Ids (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring * Rewrote Note [Combining case branches: optimistic one-shot-ness] Compile time improves slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- CoOpt_Read(normal) ghc/alloc 803,788,056 747,832,680 -7.1% GOOD T18223(normal) ghc/alloc 928,207,320 959,424,016 +3.1% BAD geo. mean -0.3% minimum -7.1% maximum +3.1% On Windows it's a bit better: geo mean is -0.6%, and three more benchmarks trip their compile-time bytes-allocated threshold (they were all close on the other build): T18698b(normal) ghc/alloc 235,619,776 233,219,008 -1.0% GOOD T6048(optasm) ghc/alloc 112,208,192 109,704,936 -2.2% GOOD T18140(normal) ghc/alloc 85,064,192 83,168,360 -2.2% GOOD I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3.4% increase in exchange for goodness elsewhere. Metric Decrease: CoOpt_Read LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp T10421 T12425 T12707 T13035 T13253 T13379 T14683 T15703 T18698a T1969 T3064 T3294 T4801 T5321FD T5321Fun T5631 T783 T9020 T9198 T9233 T9872b T9872c T9961 parsing001 Metric Increase: T18223 (cherry picked from commit 5e282da37e19a1ab24ae167daf32276a64ed2842) - - - - - 3bdfa13c by Ben Gamari at 2022-11-01T17:46:56-04:00 Bump process submodule to v1.6.16.0 - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/PostProcess.hs - compiler/Language/Haskell/Syntax/Expr.hs - libraries/process - + testsuite/tests/arityanal/should_compile/Arity17.hs - + testsuite/tests/arityanal/should_compile/T21755.hs - + testsuite/tests/arityanal/should_compile/T21755.stderr - testsuite/tests/arityanal/should_compile/all.T - + testsuite/tests/callarity/should_compile/T21694a.hs - + testsuite/tests/callarity/should_compile/T21694a.stderr - testsuite/tests/hiefile/should_compile/all.T - + testsuite/tests/hiefile/should_compile/hie011.hs - + testsuite/tests/hiefile/should_compile/hie011.stderr - + testsuite/tests/hiefile/should_run/SpliceTypes.hs - + testsuite/tests/hiefile/should_run/SpliceTypes.stdout - testsuite/tests/hiefile/should_run/all.T - testsuite/tests/linters/notes.stdout - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test21805.hs - testsuite/tests/printer/all.T - + testsuite/tests/simplCore/should_compile/T21694b.hs - + testsuite/tests/simplCore/should_compile/T21694b.stderr - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aeefb36f940566aeee8d47a67cf11c2bb4cb2961...3bdfa13c9e5b2cbf2da5d27c3ff4bdd390e8d361 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/aeefb36f940566aeee8d47a67cf11c2bb4cb2961...3bdfa13c9e5b2cbf2da5d27c3ff4bdd390e8d361 You're receiving 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 Nov 1 21:49:17 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 01 Nov 2022 17:49:17 -0400 Subject: [Git][ghc/ghc][wip/backports-9.4] Bump process submodule to v1.6.16.0 Message-ID: <6361945dda612_815bc515a44727e1@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.4 at Glasgow Haskell Compiler / GHC Commits: f4200e22 by Ben Gamari at 2022-11-01T17:49:13-04:00 Bump process submodule to v1.6.16.0 - - - - - 1 changed file: - libraries/process Changes: ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit 2ac3ff366631a36d84101000045abbefa4415b15 +Subproject commit a4d1a80ec065bb52e39273faf395e515174efa3f View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f4200e2219606e73d051f0e2de98cf75d72bd683 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f4200e2219606e73d051f0e2de98cf75d72bd683 You're receiving 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 Nov 1 23:01:50 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 01 Nov 2022 19:01:50 -0400 Subject: [Git][ghc/ghc][wip/per-capability] 52 commits: CoreToStg: purge `DynFlags`. Message-ID: <6361a55ed13cd_815bc515684929fa@gitlab.mail> Ben Gamari pushed to branch wip/per-capability at Glasgow Haskell Compiler / GHC Commits: ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - dc7492c3 by Ben Gamari at 2022-11-01T19:01:33-04:00 GHC.IOArray: Introduce unsafeFreezeIOArray - - - - - 1e80dad6 by Ben Gamari at 2022-11-01T19:01:34-04:00 Add GHC.PerCapability - - - - - 3b1dc401 by Ben Gamari at 2022-11-01T19:01:34-04:00 Port MIO to use PerCapability - - - - - 606d7da9 by Ben Gamari at 2022-11-01T19:01:34-04:00 testsuite: Clarify comment in T4850 - - - - - 1dae7c8c by Ben Gamari at 2022-11-01T19:01:34-04:00 testsuite: Accept new output from T4850 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/CSE.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/Stats.hs - compiler/GHC/Core/Subst.hs - compiler/GHC/Core/TyCo/Subst.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d7240f38ad9f283a0128dcb2f82a7f3a3d1a9bdd...1dae7c8c4dca8eda1bc693c266845149fbd2306a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d7240f38ad9f283a0128dcb2f82a7f3a3d1a9bdd...1dae7c8c4dca8eda1bc693c266845149fbd2306a You're receiving 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 Nov 2 10:30:04 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 02 Nov 2022 06:30:04 -0400 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] 142 commits: Update filepath to filepath-1.4.100.0 Message-ID: <636246acd5a7f_815bc515045800cb@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 4c27146d by Andreas Klebinger at 2022-11-02T11:27:37+01:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 30 changed files: - .editorconfig - .gitlab-ci.yml - .gitlab/ci.sh - README.md - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Switch.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/Reg/Liveness.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/63b63a8544b19ceba7a8af41f4eea0f90d6b846f...4c27146d9485b3b6c4a4630afd3bd8fd2e148ed9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/63b63a8544b19ceba7a8af41f4eea0f90d6b846f...4c27146d9485b3b6c4a4630afd3bd8fd2e148ed9 You're receiving 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 Nov 2 11:00:52 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 02 Nov 2022 07:00:52 -0400 Subject: [Git][ghc/ghc][wip/driver-fix-defer] driver: Fix -fdefer-diagnostics flag Message-ID: <63624de4c5e57_815bc515cc5890d0@gitlab.mail> Matthew Pickering pushed to branch wip/driver-fix-defer at Glasgow Haskell Compiler / GHC Commits: daf7bcbf by Matthew Pickering at 2022-11-02T11:00:43+00:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - 9 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/t22391/Makefile - + testsuite/tests/driver/t22391/all.T - + testsuite/tests/driver/t22391/src/Lib.hs - + testsuite/tests/driver/t22391/src/Lib/A.hs - + testsuite/tests/driver/t22391/src/Lib/B.hs - + testsuite/tests/driver/t22391/t22391.stderr - + testsuite/tests/driver/t22391/t22391j.stderr - testsuite/tests/ghci/prog018/prog018.stdout Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -741,8 +741,8 @@ load' mhmi_cache how_much mHscMessage mod_graph = do Just n -> return n setSession $ hscUpdateHUG (unitEnv_map pruneHomeUnitEnv) hsc_env - hsc_env <- getSession - (upsweep_ok, hsc_env1) <- withDeferredDiagnostics $ + (upsweep_ok, hsc_env1) <- withDeferredDiagnostics $ do + hsc_env <- getSession liftIO $ upsweep n_jobs hsc_env mhmi_cache mHscMessage (toCache pruned_cache) build_plan setSession hsc_env1 case upsweep_ok of ===================================== testsuite/tests/driver/t22391/Makefile ===================================== @@ -0,0 +1,19 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +warnings-ghc-deferred: clean + "$GHC" --make -Wall -fdefer-diagnostics src/Lib.hs src/Lib/A.hs src/Lib/B.hs" + ghc --version + +warnings-ghc-regular: clean + bash -c "ghc --make -Wall src/Lib.hs src/Lib/A.hs src/Lib/B.hs" + ghc --version + +.PHONY: warnings-ghc + +clean: + rm -rf src/**/*.{hi,o} + rm -rf **/*.{hi,o} + +.PHONY: clean ===================================== testsuite/tests/driver/t22391/all.T ===================================== @@ -0,0 +1,5 @@ +test('t22391', [extra_files(['src'])], + multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics']) + +test('t22391j', [req_smp, extra_files(['src'])], + multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics -j2']) ===================================== testsuite/tests/driver/t22391/src/Lib.hs ===================================== @@ -0,0 +1,11 @@ +module Lib + ( someFunc + ) where + +import Lib.A +import Lib.B + +blah = 3 + +someFunc :: IO () +someFunc = putStrLn "someFunc" ===================================== testsuite/tests/driver/t22391/src/Lib/A.hs ===================================== @@ -0,0 +1,3 @@ +module Lib.A where + +blast = 1 ===================================== testsuite/tests/driver/t22391/src/Lib/B.hs ===================================== @@ -0,0 +1,3 @@ +module Lib.B where + +warnmeup = 4 ===================================== testsuite/tests/driver/t22391/t22391.stderr ===================================== @@ -0,0 +1,43 @@ +[1 of 3] Compiling Lib.A +[2 of 3] Compiling Lib.B +[3 of 3] Compiling Lib + +src/Lib/A.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blast :: Integer + +src/Lib/A.hs:3:9: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘1’ + • In the expression: 1 + In an equation for ‘blast’: blast = 1 + +src/Lib/B.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: warnmeup :: Integer + +src/Lib/B.hs:3:12: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘4’ + • In the expression: 4 + In an equation for ‘warnmeup’: warnmeup = 4 + +src/Lib.hs:5:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.A’ is redundant + except perhaps to import instances from ‘Lib.A’ + To import instances alone, use: import Lib.A() + +src/Lib.hs:6:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.B’ is redundant + except perhaps to import instances from ‘Lib.B’ + To import instances alone, use: import Lib.B() + +src/Lib.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blah :: Integer + +src/Lib.hs:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: ‘blah’ + +src/Lib.hs:8:8: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘3’ + • In the expression: 3 + In an equation for ‘blah’: blah = 3 ===================================== testsuite/tests/driver/t22391/t22391j.stderr ===================================== @@ -0,0 +1,43 @@ +[1 of 3] Compiling Lib.A +[2 of 3] Compiling Lib.B +[3 of 3] Compiling Lib + +src/Lib/A.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blast :: Integer + +src/Lib/A.hs:3:9: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘1’ + • In the expression: 1 + In an equation for ‘blast’: blast = 1 + +src/Lib/B.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: warnmeup :: Integer + +src/Lib/B.hs:3:12: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘4’ + • In the expression: 4 + In an equation for ‘warnmeup’: warnmeup = 4 + +src/Lib.hs:5:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.A’ is redundant + except perhaps to import instances from ‘Lib.A’ + To import instances alone, use: import Lib.A() + +src/Lib.hs:6:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.B’ is redundant + except perhaps to import instances from ‘Lib.B’ + To import instances alone, use: import Lib.B() + +src/Lib.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blah :: Integer + +src/Lib.hs:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: ‘blah’ + +src/Lib.hs:8:8: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘3’ + • In the expression: 3 + In an equation for ‘blah’: blah = 3 ===================================== testsuite/tests/ghci/prog018/prog018.stdout ===================================== @@ -1,4 +1,6 @@ [1 of 3] Compiling A ( A.hs, interpreted ) +[2 of 3] Compiling B ( B.hs, interpreted ) +[3 of 3] Compiling C ( C.hs, interpreted ) A.hs:5:1: warning: [GHC-62161] [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive @@ -7,19 +9,14 @@ A.hs:5:1: warning: [GHC-62161] [-Wincomplete-patterns (in -Wextra)] A.hs:8:15: warning: [-Wunused-matches (in -Wextra)] Defined but not used: ‘x’ -[2 of 3] Compiling B ( B.hs, interpreted ) B.hs:7:1: warning: [-Wunused-imports (in -Wextra)] The import of ‘Data.Tuple’ is redundant except perhaps to import instances from ‘Data.Tuple’ To import instances alone, use: import Data.Tuple() -[3 of 3] Compiling C ( C.hs, interpreted ) C.hs:6:7: error: [GHC-88464] Variable not in scope: variableNotInScope :: () Failed, two modules loaded. [3 of 3] Compiling C ( C.hs, interpreted ) - -C.hs:6:7: error: [GHC-88464] - Variable not in scope: variableNotInScope :: () Failed, two modules loaded. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/daf7bcbf0f5dfaf019b295738a63d50972bb4ee4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/daf7bcbf0f5dfaf019b295738a63d50972bb4ee4 You're receiving 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 Nov 2 11:08:44 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 02 Nov 2022 07:08:44 -0400 Subject: [Git][ghc/ghc][wip/t22347] 20 commits: Testsuite: more precise test options Message-ID: <63624fbc44f08_815bc51504591834@gitlab.mail> Matthew Pickering pushed to branch wip/t22347 at Glasgow Haskell Compiler / GHC Commits: 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - d3e00ea7 by Matthew Pickering at 2022-11-02T11:08:09+00:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - compiler/GHC/Linker/ExtraObj.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Lift/Monad.hs - compiler/GHC/StgToCmm/InfoTableProv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/71a31dad257fa97eb14a1985c9db0e66235d4e57...d3e00ea7265e2c27d6098a64e399c1f100d4439a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/71a31dad257fa97eb14a1985c9db0e66235d4e57...d3e00ea7265e2c27d6098a64e399c1f100d4439a You're receiving 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 Nov 2 11:09:16 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 02 Nov 2022 07:09:16 -0400 Subject: [Git][ghc/ghc][wip/foundation-tests] 75 commits: Add `Enum (Down a)` instance that swaps `succ` and `pred` Message-ID: <63624fdc3aff6_815bc515cc592081@gitlab.mail> Matthew Pickering pushed to branch wip/foundation-tests at Glasgow Haskell Compiler / GHC Commits: 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 70da9e98 by Matthew Pickering at 2022-11-02T11:09:13+00:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Map/Expr.hs - compiler/GHC/Core/Map/Type.hs - compiler/GHC/Core/Opt/CSE.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f2c17bf4a38967c1b9582ba1aa94db578e89d40...70da9e9871448b22f9614e3933bff5d9aba3f3d4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f2c17bf4a38967c1b9582ba1aa94db578e89d40...70da9e9871448b22f9614e3933bff5d9aba3f3d4 You're receiving 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 Nov 2 11:20:55 2022 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Wed, 02 Nov 2022 07:20:55 -0400 Subject: [Git][ghc/ghc][wip/bump-boot-libraries] 22 commits: Testsuite: more precise test options Message-ID: <636252974c009_815bc514285946e5@gitlab.mail> Cheng Shao pushed to branch wip/bump-boot-libraries at Glasgow Haskell Compiler / GHC Commits: 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - d37df376 by Matthew Pickering at 2022-11-02T09:55:38+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. - - - - - 2a58964b by Matthew Pickering at 2022-11-02T09:55:38+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - 7a41ceaa by Cheng Shao at 2022-11-02T11:20:16+00:00 base: fix T7773 re unix-2.8 changes - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/Parser.y - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Unfold/Make.hs - compiler/GHC/Data/BooleanFormula.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Hs/Doc.hs - compiler/GHC/Hs/DocString.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - compiler/GHC/Linker/ExtraObj.hs - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Stg/Lift/Monad.hs - compiler/GHC/StgToCmm/InfoTableProv.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f9ff9fe6efc1bf1825a759f34a5f66406c02bf6d...7a41ceaaf80d3a452d63aadfc3ef9c430f163dee -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f9ff9fe6efc1bf1825a759f34a5f66406c02bf6d...7a41ceaaf80d3a452d63aadfc3ef9c430f163dee You're receiving 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 Nov 2 11:46:56 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 02 Nov 2022 07:46:56 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 20 commits: Drop a kludge for binutils<2.17, which is now over 10 years old. Message-ID: <636258b04e957_2d3c504fbc8845d1@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - cb526568 by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - 635d10c3 by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: consistently use `STG_UNUSED` - - - - - bd624f51 by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - b252de9e by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - f887c5bc by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: use `STG_UNUSED` - - - - - 6bcaa7c2 by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 1b4ddc11 by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - fdda099b by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 3cbeacec by Nicolas Trangez at 2022-11-02T07:46:35-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - e437f7a1 by Oleg Grenrus at 2022-11-02T07:46:40-04:00 Move Symbol implementation note out of public haddock - - - - - 30 changed files: - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Env.hs - compiler/GHC/Unit/Module/WholeCoreBindings.hs - docs/users_guide/phases.rst - libraries/ghc-prim/GHC/Types.hs - rts/CloneStack.c - rts/Heap.c - rts/Hpc.c - rts/Linker.c - rts/RtsAPI.c - rts/RtsFlags.c - rts/RtsMessages.c - rts/RtsStartup.c - rts/RtsUtils.h - rts/StgCRun.c - rts/include/Rts.h - rts/include/RtsAPI.h - rts/include/Stg.h - rts/include/rts/Main.h - rts/include/rts/Messages.h - rts/include/rts/OSThreads.h - rts/include/rts/Threads.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/963c17b77bd89c026e937405582e6b669f2ec414...e437f7a106655837139bca37e2a1824fd5178ec0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/963c17b77bd89c026e937405582e6b669f2ec414...e437f7a106655837139bca37e2a1824fd5178ec0 You're receiving 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 Nov 2 12:01:36 2022 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Wed, 02 Nov 2022 08:01:36 -0400 Subject: [Git][ghc/ghc][wip/bump-boot-libraries] 2 commits: Bump unix submodule to 2.8.0.0 Message-ID: <63625c201d6ec_2d3c504ff609511e@gitlab.mail> Cheng Shao pushed to branch wip/bump-boot-libraries at Glasgow Haskell Compiler / GHC Commits: 75eeb64c by Matthew Pickering at 2022-11-02T12:01:14+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. - - - - - 76c14a18 by Matthew Pickering at 2022-11-02T12:01:22+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - 7 changed files: - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - libraries/Win32 - libraries/base/tests/T7773.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/process - libraries/unix Changes: ===================================== compiler/ghc.cabal.in ===================================== @@ -96,7 +96,7 @@ Library ghci == @ProjectVersionMunged@ if os(windows) - Build-Depends: Win32 >= 2.3 && < 2.13 + Build-Depends: Win32 >= 2.3 && < 2.14 else if flag(terminfo) Build-Depends: terminfo == 0.4.* ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -43,7 +43,7 @@ Executable ghc ghc == @ProjectVersionMunged@ if os(windows) - Build-Depends: Win32 >= 2.3 && < 2.13 + Build-Depends: Win32 >= 2.3 && < 2.14 else Build-Depends: unix >= 2.7 && < 2.9 ===================================== libraries/Win32 ===================================== @@ -1 +1 @@ -Subproject commit e6c0c0f44f6dfc2f8255fc4a5017f4ab67cd0242 +Subproject commit 931497f7052f63cb5cfd4494a94e572c5c570642 ===================================== libraries/base/tests/T7773.hs ===================================== @@ -3,7 +3,6 @@ import System.Posix.IO main = do putStrLn "hello" - fd <- openFd "/dev/random" ReadOnly Nothing defaultFileFlags + fd <- openFd "/dev/random" ReadOnly defaultFileFlags threadWaitRead fd putStrLn "goodbye" - ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -80,4 +80,4 @@ Library ghc-boot-th == @ProjectVersionMunged@ if !os(windows) build-depends: - unix >= 2.7 && < 2.8 + unix >= 2.7 && < 2.9 ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit 2ac3ff366631a36d84101000045abbefa4415b15 +Subproject commit 25613c7d01f6fe5ee2f75fd39db898942cbfb404 ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 2a6079a2b76adf29d3e3ff213dffe66cabcb76c3 +Subproject commit 3be0223cee7395410915a127eba3acae5ff0b2f2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a41ceaaf80d3a452d63aadfc3ef9c430f163dee...76c14a18f3638c4894af759583e5da9b1e962425 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a41ceaaf80d3a452d63aadfc3ef9c430f163dee...76c14a18f3638c4894af759583e5da9b1e962425 You're receiving 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 Nov 2 12:23:41 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Wed, 02 Nov 2022 08:23:41 -0400 Subject: [Git][ghc/ghc][wip/mp-9.2.5-backports] 2 commits: Attemp fix for core lint failures Message-ID: <6362614da14dc_2d3c504b7bc1006f5@gitlab.mail> Zubin pushed to branch wip/mp-9.2.5-backports at Glasgow Haskell Compiler / GHC Commits: 7c46d2ab by Zubin Duggal at 2022-11-01T15:04:48+05:30 Attemp fix for core lint failures For an expression: joinrec foo = ... in expr we compute the arityType as `foldr andArityType (arityType expr) [arityType foo]` which is the same as `andArityType (arityType expr) (arityType foo)`. However, this is incorrect: joinrec go x = ... in go 0 then the arity of go is 1 (\?. T), but the arity of the overall expression is 0 (_|_). `andArityType` however returns (\?. T) for these, which is wrong. (cherry picked from commit 53235edd478bd4c5e29e4f254ce02559af259dd5) - - - - - 040b8072 by Zubin Duggal at 2022-11-02T17:53:29+05:30 Bump base to 4.16.4.0 and add release notes - - - - - 19 changed files: - compiler/GHC/Core/Opt/Arity.hs - configure.ac - docs/users_guide/release-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md - + testsuite/tests/arityanal/should_compile/Arity17.hs - testsuite/tests/arityanal/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/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/printer/T18052a.stderr - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1104,22 +1104,6 @@ arityType env (Let (NonRec b r) e) cheap_rhs = myExprIsCheap env r (Just (idType b)) env' = extendSigEnv env b (arityType env r) -arityType env (Let (Rec pairs) body) - | ((j,_):_) <- pairs - , isJoinId j - = -- See Note [arityType for join bindings] - foldr (andArityType env . do_one) (arityType rec_env body) pairs - where - rec_env = foldl add_bot env pairs - add_bot env (j,_) = extendSigEnv env j botArityType - - do_one :: (JoinId, CoreExpr) -> ArityType - do_one (j,rhs) - | Just arity <- isJoinId_maybe j - = arityType rec_env $ snd $ collectNBinders arity rhs - | otherwise - = pprPanic "arityType:joinrec" (ppr pairs) - arityType env (Let (Rec prs) e) = floatIn (all is_cheap prs) (arityType env' e) where ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.2.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.2.5], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on HEAD must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058) ===================================== docs/users_guide/release-notes.rst ===================================== @@ -8,3 +8,4 @@ Release notes 9.2.2-notes 9.2.3-notes 9.2.4-notes + 9.2.5-notes ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.16.3.0 +version: 4.16.4.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.16.4.0 *Nov 2022* + + * Shipped with GHC 9.2.5 + + * Fix races in IOManager (setNumCapabilities,closeFdWith) (#21651) + + * winio: do not re-translate input when handle is uncooked + ## 4.16.3.0 *May 2022* * Shipped with GHC 9.2.4 ===================================== testsuite/tests/arityanal/should_compile/Arity17.hs ===================================== @@ -0,0 +1,27 @@ +module Bug (downsweep) where + +import GHC.Utils.Misc ( filterOut ) +import qualified Data.Map.Strict as M ( Map, elems ) +import qualified Data.Map as Map ( fromListWith ) + +type DownsweepCache = M.Map Int Int + +downsweep :: [Int] -> IO DownsweepCache +downsweep rootSummariesOk = do + let root_map = mkRootMap rootSummariesOk + checkDuplicates root_map + return root_map + where + checkDuplicates :: DownsweepCache -> IO () + checkDuplicates root_map = multiRootsErr dup_roots + where + dup_roots = filterOut (>2) (M.elems root_map) + +mkRootMap + :: [Int] + -> DownsweepCache +mkRootMap summaries = Map.fromListWith const + [ (s, s) | s <- summaries ] + +multiRootsErr :: [a] -> IO () +multiRootsErr [] = pure () ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -16,6 +16,7 @@ test('Arity13', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn test('Arity14', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity15', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('Arity17', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-package ghc -dcore-lint -O2']) # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,4 +11,4 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -54,4 +54,4 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,4 +9,4 @@ FAMILY INSTANCES data instance forall {k1} {j :: k1} {k2} {c :: k2}. DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,4 +5,4 @@ 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.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,4 +4,4 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/printer/T18052a.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS PATTERN SYNONYMS (:||:) :: forall {a} {b}. a -> b -> (a, b) Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ==================== Tidy Core ==================== Result size of Tidy Core ===================================== testsuite/tests/roles/should_compile/T8958.stderr ===================================== @@ -16,7 +16,7 @@ CLASS INSTANCES -- Defined at T8958.hs:11:10 instance [incoherent] Nominal a -- Defined at T8958.hs:8:10 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ==================== Typechecker ==================== T8958.$tcMap ===================================== testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout ===================================== @@ -4,17 +4,17 @@ pdb.safePkg01/local.db trusted: False M_SafePkg -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe require own pkg trusted: False M_SafePkg2 -package dependencies: base-4.16.3.0 ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0 ghc-bignum-1.2 ghc-prim-0.8.0 trusted: trustworthy require own pkg trusted: False M_SafePkg3 -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe require own pkg trusted: True @@ -24,7 +24,7 @@ trusted: safe require own pkg trusted: True M_SafePkg5 -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe-inferred require own pkg trusted: True ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,4 +8,4 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -8,10 +8,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.16.3.0:Data.OldList’)) + (and originally defined in ‘base-4.16.4.0:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.16.3.0:Data.OldList’)) + (and originally defined in ‘base-4.16.4.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/c29100e6442b7ddd3275d7f0e806860472d24cca...040b80725bbc18db49023a53a73808c5c59cbbd4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c29100e6442b7ddd3275d7f0e806860472d24cca...040b80725bbc18db49023a53a73808c5c59cbbd4 You're receiving 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 Nov 2 12:51:57 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 02 Nov 2022 08:51:57 -0400 Subject: [Git][ghc/ghc] Pushed new tag temp/bryan Message-ID: <636267edd052e_2d3c504b7bc103783@gitlab.mail> Bryan R pushed new tag temp/bryan at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/temp/bryan You're receiving 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 Nov 2 12:53:16 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 02 Nov 2022 08:53:16 -0400 Subject: [Git][ghc/ghc] Pushed new tag temp/bryan2 Message-ID: <6362683c9b430_2d3c504fbc81039bf@gitlab.mail> Bryan R pushed new tag temp/bryan2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/temp/bryan2 You're receiving 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 Nov 2 13:06:28 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 02 Nov 2022 09:06:28 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-nightly-22396 Message-ID: <63626b54e7171_2d3c504ff38108489@gitlab.mail> Bryan R pushed new branch wip/fix-nightly-22396 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-nightly-22396 You're receiving 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 Nov 2 13:08:24 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 02 Nov 2022 09:08:24 -0400 Subject: [Git][ghc/ghc] Deleted tag temp/bryan Message-ID: <63626bc896c1d_2d3c504fbb411417e@gitlab.mail> Bryan R deleted tag temp/bryan 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 Nov 2 13:08:29 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Wed, 02 Nov 2022 09:08:29 -0400 Subject: [Git][ghc/ghc] Deleted tag temp/bryan2 Message-ID: <63626bcd9934f_2d3c504b7bc1143e6@gitlab.mail> Bryan R deleted tag temp/bryan2 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 Nov 2 13:20:47 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 02 Nov 2022 09:20:47 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Remove redundant import Message-ID: <63626eaf54b9e_2d3c504ff4c11623d@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: b1ffed84 by Sylvain Henry at 2022-11-02T14:00:22+01:00 Remove redundant import - - - - - 1 changed file: - compiler/GHC/Driver/Pipeline/Execute.hs Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -78,7 +78,6 @@ import GHC.Unit.Module.Env import GHC.Driver.Env.KnotVars import GHC.Driver.Config.Finder import GHC.Rename.Names -import GHC.SysTools.Cpp import GHC.StgToJS.Linker.Linker (embedJsFile) import Language.Haskell.Syntax.Module.Name View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1ffed84065bfa48a59b357794e3e974d885c806 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1ffed84065bfa48a59b357794e3e974d885c806 You're receiving 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 Nov 2 13:21:04 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 02 Nov 2022 09:21:04 -0400 Subject: [Git][ghc/ghc][wip/javascript-backend] Remove redundant import Message-ID: <63626ec098a46_2d3c504ff60116486@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 1293c996 by Sylvain Henry at 2022-11-02T14:24:43+01:00 Remove redundant import - - - - - 1 changed file: - compiler/GHC/Driver/Pipeline/Execute.hs Changes: ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -78,7 +78,6 @@ import GHC.Unit.Module.Env import GHC.Driver.Env.KnotVars import GHC.Driver.Config.Finder import GHC.Rename.Names -import GHC.SysTools.Cpp import GHC.StgToJS.Linker.Linker (embedJsFile) import Language.Haskell.Syntax.Module.Name View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1293c9968f3295ce5124e335ac93f73d9ad2c05e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1293c9968f3295ce5124e335ac93f73d9ad2c05e You're receiving 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 Nov 2 13:51:08 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 02 Nov 2022 09:51:08 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Remove unused linker config options Message-ID: <636275ccbe7c_2d3c504b7bc1240df@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 2b8b98f8 by Sylvain Henry at 2022-11-02T14:54:38+01:00 Remove unused linker config options - - - - - 1 changed file: - compiler/GHC/StgToJS/Linker/Types.hs Changes: ===================================== compiler/GHC/StgToJS/Linker/Types.hs ===================================== @@ -33,8 +33,6 @@ import GHC.StgToJS.Object import GHC.Unit.Types import GHC.Utils.Outputable (hsep,Outputable(..),text,ppr) -import Control.Monad - import Data.Map.Strict (Map) import qualified Data.Map.Strict as M import Data.Set (Set) @@ -50,20 +48,11 @@ import Prelude -------------------------------------------------------------------------------- data JSLinkConfig = JSLinkConfig - { lcNativeExecutables :: Bool - , lcNativeToo :: Bool - , lcBuildRunner :: Bool - , lcNoJSExecutables :: Bool + { lcNoJSExecutables :: Bool , lcNoHsMain :: Bool - , lcStripProgram :: Maybe FilePath - , lcLogCommandLine :: Maybe FilePath - , lcGhc :: Maybe FilePath , lcOnlyOut :: Bool , lcNoRts :: Bool , lcNoStats :: Bool - , lcLinkJsLib :: Maybe String - , lcJsLibOutputDir :: Maybe FilePath - , lcJsLibSrcs :: [FilePath] } -- | we generate a runnable all.js only if we link a complete application, @@ -73,20 +62,11 @@ generateAllJs s = not (lcOnlyOut s) && not (lcNoRts s) instance Monoid JSLinkConfig where mempty = JSLinkConfig - { lcNativeExecutables = False - , lcNativeToo = False - , lcBuildRunner = False - , lcNoJSExecutables = False + { lcNoJSExecutables = False , lcNoHsMain = False - , lcStripProgram = Nothing - , lcLogCommandLine = Nothing - , lcGhc = Nothing , lcOnlyOut = False , lcNoRts = False , lcNoStats = False - , lcLinkJsLib = Nothing - , lcJsLibOutputDir = Nothing - , lcJsLibSrcs = mempty } instance Semigroup JSLinkConfig where @@ -94,20 +74,11 @@ instance Semigroup JSLinkConfig where let comb :: (a -> a -> a) -> (JSLinkConfig -> a) -> a comb f a = f (a c1) (a c2) in JSLinkConfig - { lcNativeExecutables = comb (||) lcNativeExecutables - , lcNativeToo = comb (||) lcNativeToo - , lcBuildRunner = comb (||) lcBuildRunner - , lcNoJSExecutables = comb (||) lcNoJSExecutables + { lcNoJSExecutables = comb (||) lcNoJSExecutables , lcNoHsMain = comb (||) lcNoHsMain - , lcStripProgram = comb mplus lcStripProgram - , lcLogCommandLine = comb mplus lcLogCommandLine - , lcGhc = comb mplus lcGhc , lcOnlyOut = comb (||) lcOnlyOut , lcNoRts = comb (||) lcNoRts , lcNoStats = comb (||) lcNoStats - , lcLinkJsLib = comb (<>) lcLinkJsLib - , lcJsLibOutputDir = comb (<>) lcJsLibOutputDir - , lcJsLibSrcs = comb (<>) lcJsLibSrcs } -------------------------------------------------------------------------------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b8b98f8d83b1a7668d83ba4692fc5b4846d037e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b8b98f8d83b1a7668d83ba4692fc5b4846d037e You're receiving 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 Nov 2 14:25:44 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 02 Nov 2022 10:25:44 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] Remove Trace.hs-boot Message-ID: <63627de865f6b_2d3c504b7bc124473@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: 963f857c by Andreas Klebinger at 2022-11-02T15:23:00+01:00 Remove Trace.hs-boot - - - - - 7 changed files: - compiler/GHC/Prelude.hs - compiler/GHC/StgToCmm/Ticky.hs - compiler/GHC/Types/Id.hs - compiler/GHC/Unit/Types.hs-boot - compiler/GHC/Utils/Panic.hs - compiler/GHC/Utils/Trace.hs - − compiler/GHC/Utils/Trace.hs-boot Changes: ===================================== compiler/GHC/Prelude.hs ===================================== @@ -48,14 +48,5 @@ NoImplicitPrelude. There are two motivations for this: import GHC.Prelude.Basic as GHC.Prelude -import {-# SOURCE #-} GHC.Utils.Trace - ( pprTrace - , pprTraceM - , pprTraceWith - -- , pprTraceDebug - -- Do *not* boot-export pprTraceDebug, it *must* be importet in a non-boot way - -- in order to guarantee it's optimized away in non-debug builds. - , pprSTrace - , warnPprTrace - , pprTraceUserWarning - ) +-- import {-# SOURCE #-} GHC.Utils.Trace +import GHC.Utils.Trace hiding ( trace ) ===================================== compiler/GHC/StgToCmm/Ticky.hs ===================================== @@ -154,7 +154,6 @@ import Data.Maybe import qualified Data.Char import Control.Monad ( when, unless ) import GHC.Types.Id.Info -import GHC.Utils.Trace ( pprTraceDebug ) import GHC.StgToCmm.Env (getCgInfo_maybe) import Data.Coerce (coerce) import GHC.Utils.Json ===================================== compiler/GHC/Types/Id.hs ===================================== @@ -163,7 +163,6 @@ import GHC.Utils.Misc import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Panic.Plain -import GHC.Utils.Trace import GHC.Stg.InferTags.TagSig -- infixl so you can say (id `set` a `set` b) ===================================== compiler/GHC/Unit/Types.hs-boot ===================================== @@ -2,7 +2,7 @@ module GHC.Unit.Types where -- No Prelude. See Note [Exporting pprTrace from GHC.Prelude] -import Language.Haskell.Syntax.Module.Name.Type (ModuleName) +import Language.Haskell.Syntax.Module.Name (ModuleName) import Data.Kind (Type) data UnitId ===================================== compiler/GHC/Utils/Panic.hs ===================================== @@ -52,7 +52,7 @@ module GHC.Utils.Panic ) where -import GHC.Prelude +import GHC.Prelude.Basic import GHC.Stack import GHC.Utils.Outputable ===================================== compiler/GHC/Utils/Trace.hs ===================================== @@ -20,27 +20,8 @@ Since calls to traces should never be performance sensitive it's okay for these to be source imports/exports. However we still need to make sure that all transitive imports from Trace.hs-boot do not import GHC.Prelude. -To get there we make these changes within the transitive dependencies -of Trace.hs-boot: -* Import the regular Prelude instead of GHC.Prelude -* Move data type definitions into their own modules so that we can eventually - import SDoc without pulling in half of GHC. - -The later has the annoying side effect of adding a few harmless orphan instances. -Since we end up with e.g. FastString in a different module than the module -defining the logic needed to define it's show instance. -But that still seems better than adding a ton of .hs-boot files which can -affect performance. The other alternative would be to use newtypes which carry -the actual instances. E.g. newtype ShowFastString = SF FastString and define -instances only on the newtype(s). But that also seems cumbersome. - -So I simply accepted the (few) new orphan instances for now. - -NB: It can still be beneficial to explicitly import this module when it's -important that unfoldings are available. This is particularly important for -pprTraceDebug which we want to optimize away completely in non-debug builds. -So we don't provide a boot-export for this function to avoid people using it -accidentally. +To get there we import the basic GHC.Prelude.Basic prelude instead of GHC.Prelude +within the transitive dependencies of Trace.hs -} import GHC.Prelude.Basic ===================================== compiler/GHC/Utils/Trace.hs-boot deleted ===================================== @@ -1,47 +0,0 @@ --- | Tracing utilities -module GHC.Utils.Trace - ( pprTrace - , pprTraceM - , pprTraceWith - -- , pprTraceDebug - -- Do *not* boot-export pprTraceDebug, it *must* be importet in a non-boot way - -- in order to guarantee it's optimized away in non-debug builds. - -- , pprTraceIt - Pulling in Outputable just for this seems not worth it. - , pprTraceException - , pprSTrace - , warnPprTrace - , pprTraceUserWarning - , trace - ) -where - -import GHC.Prelude.Basic - -import GHC.Utils.Outputable ( SDoc ) -import GHC.Utils.Exception ( ExceptionMonad ) - -import GHC.Stack -import Debug.Trace (trace) - --- | If debug output is on, show some 'SDoc' on the screen -pprTrace :: String -> SDoc -> a -> a - -pprTraceM :: Applicative f => String -> SDoc -> f () - --- | @pprTraceWith desc f x@ is equivalent to @pprTrace desc (f x) x at . --- This allows you to print details from the returned value as well as from --- ambient variables. -pprTraceWith :: String -> (a -> SDoc) -> a -> a - -pprTraceException :: ExceptionMonad m => String -> SDoc -> m a -> m a - --- | If debug output is on, show some 'SDoc' on the screen along --- with a call stack when available. -pprSTrace :: HasCallStack => SDoc -> a -> a - --- | Just warn about an assertion failure, recording the given file and line number. -warnPprTrace :: HasCallStack => Bool -> String -> SDoc -> a -> a - --- | For when we want to show the user a non-fatal WARNING so that they can --- report a GHC bug, but don't want to panic. -pprTraceUserWarning :: HasCallStack => SDoc -> a -> a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/963f857c676b364ef35fdbabc45a23ca0a5ee548 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/963f857c676b364ef35fdbabc45a23ca0a5ee548 You're receiving 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 Nov 2 14:52:26 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 02 Nov 2022 10:52:26 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] Remove Name.Type module Message-ID: <6362842a81357_17aaa50d20338cf@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: 52925e67 by Andreas Klebinger at 2022-11-02T15:50:06+01:00 Remove Name.Type module - - - - - 3 changed files: - compiler/Language/Haskell/Syntax/Module/Name.hs - − compiler/Language/Haskell/Syntax/Module/Name/Type.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/Language/Haskell/Syntax/Module/Name.hs ===================================== @@ -9,9 +9,6 @@ module Language.Haskell.Syntax.Module.Name import Prelude --- See Note [Exporting pprTrace from GHC.Prelude] -import Language.Haskell.Syntax.Module.Name.Type as Language.Haskell.Syntax.Module.Name - import Data.Data import Data.Char (isAlphaNum) import Control.DeepSeq @@ -21,6 +18,9 @@ import System.FilePath import GHC.Utils.Misc (abstractConstr) import GHC.Data.FastString +-- | A ModuleName is essentially a simple string, e.g. @Data.List at . +newtype ModuleName = ModuleName FastString deriving (Eq) + deriving instance Show ModuleName instance Ord ModuleName where ===================================== compiler/Language/Haskell/Syntax/Module/Name/Type.hs deleted ===================================== @@ -1,8 +0,0 @@ -module Language.Haskell.Syntax.Module.Name.Type where - -import Prelude - -import GHC.Data.FastString ( FastString ) - --- | A ModuleName is essentially a simple string, e.g. @Data.List at . -newtype ModuleName = ModuleName FastString deriving (Eq) \ No newline at end of file ===================================== compiler/ghc.cabal.in ===================================== @@ -819,7 +819,6 @@ Library Language.Haskell.Syntax.ImpExp Language.Haskell.Syntax.Lit Language.Haskell.Syntax.Module.Name - Language.Haskell.Syntax.Module.Name.Type Language.Haskell.Syntax.Pat Language.Haskell.Syntax.Type View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52925e6797853c1d84ed84476a7118d02a80be6f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52925e6797853c1d84ed84476a7118d02a80be6f You're receiving 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 Nov 2 15:13:43 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 02 Nov 2022 11:13:43 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] Remove Name.Type module Message-ID: <636289278dd71_17aaa4b7a839189@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: 0bfb7ba0 by Andreas Klebinger at 2022-11-02T16:11:21+01:00 Remove Name.Type module - - - - - 4 changed files: - compiler/GHC/Unit/Types.hs - compiler/Language/Haskell/Syntax/Module/Name.hs - − compiler/Language/Haskell/Syntax/Module/Name/Type.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Unit/Types.hs ===================================== @@ -89,7 +89,6 @@ module GHC.Unit.Types where import GHC.Prelude --- import Prelude hiding ((<>)) import GHC.Types.Unique import GHC.Types.Unique.DSet ===================================== compiler/Language/Haskell/Syntax/Module/Name.hs ===================================== @@ -1,17 +1,7 @@ -{-# LANGUAGE StandaloneDeriving #-} - --- See Note [Exporting pprTrace from GHC.Prelude] -{-# OPTIONS_GHC -Wno-orphans #-} - -module Language.Haskell.Syntax.Module.Name - ( module Language.Haskell.Syntax.Module.Name - ) where +module Language.Haskell.Syntax.Module.Name where import Prelude --- See Note [Exporting pprTrace from GHC.Prelude] -import Language.Haskell.Syntax.Module.Name.Type as Language.Haskell.Syntax.Module.Name - import Data.Data import Data.Char (isAlphaNum) import Control.DeepSeq @@ -21,7 +11,8 @@ import System.FilePath import GHC.Utils.Misc (abstractConstr) import GHC.Data.FastString -deriving instance Show ModuleName +-- | A ModuleName is essentially a simple string, e.g. @Data.List at . +newtype ModuleName = ModuleName FastString deriving (Show, Eq) instance Ord ModuleName where nm1 `compare` nm2 = stableModuleNameCmp nm1 nm2 ===================================== compiler/Language/Haskell/Syntax/Module/Name/Type.hs deleted ===================================== @@ -1,8 +0,0 @@ -module Language.Haskell.Syntax.Module.Name.Type where - -import Prelude - -import GHC.Data.FastString ( FastString ) - --- | A ModuleName is essentially a simple string, e.g. @Data.List at . -newtype ModuleName = ModuleName FastString deriving (Eq) \ No newline at end of file ===================================== compiler/ghc.cabal.in ===================================== @@ -819,7 +819,6 @@ Library Language.Haskell.Syntax.ImpExp Language.Haskell.Syntax.Lit Language.Haskell.Syntax.Module.Name - Language.Haskell.Syntax.Module.Name.Type Language.Haskell.Syntax.Pat Language.Haskell.Syntax.Type View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bfb7ba063c7d012a63c3449194f9866fc1375fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bfb7ba063c7d012a63c3449194f9866fc1375fe You're receiving 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 Nov 2 15:29:49 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 02 Nov 2022 11:29:49 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] Export pprTrace and friends from GHC.Prelude. Message-ID: <63628ceda9fc3_6587e4b938592b9@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: 3a59a414 by Andreas Klebinger at 2022-11-02T16:24:54+01:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 30 changed files: - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/List/SetOps.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Env.hs - compiler/GHC/HsToCore/Binds.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3a59a414ee2245f38e01d45f493b691816e2b9e3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3a59a414ee2245f38e01d45f493b691816e2b9e3 You're receiving 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 Nov 2 16:07:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 02 Nov 2022 12:07:13 -0400 Subject: [Git][ghc/ghc][master] 9 commits: rts: introduce (and use) `STG_NORETURN` Message-ID: <636295b172fd0_6587e6da2e065326@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 23 changed files: - rts/CloneStack.c - rts/Heap.c - rts/Hpc.c - rts/Linker.c - rts/RtsAPI.c - rts/RtsFlags.c - rts/RtsMessages.c - rts/RtsStartup.c - rts/RtsUtils.h - rts/StgCRun.c - rts/include/Rts.h - rts/include/RtsAPI.h - rts/include/Stg.h - rts/include/rts/Main.h - rts/include/rts/Messages.h - rts/include/rts/OSThreads.h - rts/include/rts/Threads.h - rts/linker/Elf.c - rts/linker/M32Alloc.h - rts/linker/elf_reloc_aarch64.c - rts/linker/elf_tlsgd.c - rts/posix/OSThreads.c - rts/posix/Select.c Changes: ===================================== rts/CloneStack.c ===================================== @@ -98,7 +98,7 @@ void handleCloneStackMessage(MessageCloneStack *msg){ #else // !defined(THREADED_RTS) -GNU_ATTRIBUTE(__noreturn__) +STG_NORETURN void sendCloneStackMessage(StgTSO *tso STG_UNUSED, HsStablePtr mvar STG_UNUSED) { barf("Sending CloneStackMessages is only available in threaded RTS!"); } ===================================== rts/Heap.c ===================================== @@ -278,7 +278,7 @@ StgMutArrPtrs *heap_view_closurePtrs(Capability *cap, StgClosure *closure) { for (StgWord i = 0; ipayload[i] = ptrs[i]; } - free(ptrs); + stgFree(ptrs); return arr; } ===================================== rts/Hpc.c ===================================== @@ -45,7 +45,7 @@ HpcModuleInfo *modules = 0; static char *tixFilename = NULL; -static void GNU_ATTRIBUTE(__noreturn__) +static void STG_NORETURN failure(char *msg) { debugTrace(DEBUG_hpc,"hpc failure: %s\n",msg); fprintf(stderr,"Hpc failure: %s\n",msg); ===================================== rts/Linker.c ===================================== @@ -1971,7 +1971,7 @@ void * loadNativeObj (pathchar *path, char **errmsg) return r; } #else -void * GNU_ATTRIBUTE(__noreturn__) +void * STG_NORETURN loadNativeObj (pathchar *path, char **errmsg) { UNUSED(path); ===================================== rts/RtsAPI.c ===================================== @@ -862,7 +862,7 @@ void rts_listMiscRoots (ListRootsCb cb, void *user) } #else -PauseToken GNU_ATTRIBUTE(__noreturn__) +PauseToken STG_NORETURN *rts_pause (void) { errorBelch("Warning: Pausing the RTS is only possible for " @@ -870,7 +870,7 @@ PauseToken GNU_ATTRIBUTE(__noreturn__) stg_exit(EXIT_FAILURE); } -void GNU_ATTRIBUTE(__noreturn__) +void STG_NORETURN rts_resume (PauseToken *pauseToken STG_UNUSED) { errorBelch("Warning: Resuming the RTS is only possible for " ===================================== rts/RtsFlags.c ===================================== @@ -119,7 +119,7 @@ static bool read_heap_profiling_flag(const char *arg); static void read_trace_flags(const char *arg); #endif -static void errorUsage (void) GNU_ATTRIBUTE(__noreturn__); +static void errorUsage (void) STG_NORETURN; #if defined(mingw32_HOST_OS) static char** win32_full_utf8_argv; @@ -2421,7 +2421,7 @@ static void read_trace_flags(const char *arg) } #endif -static void GNU_ATTRIBUTE(__noreturn__) +static void STG_NORETURN bad_option(const char *s) { errorBelch("bad RTS option: %s", s); ===================================== rts/RtsMessages.c ===================================== @@ -139,7 +139,7 @@ isGUIApp(void) } #endif -void GNU_ATTRIBUTE(__noreturn__) +void STG_NORETURN rtsFatalInternalErrorFn(const char *s, va_list ap) { #if defined(mingw32_HOST_OS) @@ -322,7 +322,7 @@ rtsDebugMsgFn(const char *s, va_list ap) // Used in stg_badAlignment_entry defined in StgStartup.cmm. -void rtsBadAlignmentBarf(void) GNUC3_ATTRIBUTE(__noreturn__); +void rtsBadAlignmentBarf(void) STG_NORETURN; void rtsBadAlignmentBarf() @@ -331,7 +331,7 @@ rtsBadAlignmentBarf() } // Used by code generator -void rtsOutOfBoundsAccess(void) GNUC3_ATTRIBUTE(__noreturn__); +void rtsOutOfBoundsAccess(void) STG_NORETURN; void rtsOutOfBoundsAccess() ===================================== rts/RtsStartup.c ===================================== @@ -660,7 +660,7 @@ shutdownHaskellAndExit(int n, int fastExit) } #if !defined(mingw32_HOST_OS) -static void exitBySignal(int sig) GNUC3_ATTRIBUTE(__noreturn__); +static void exitBySignal(int sig) STG_NORETURN; void shutdownHaskellAndSignal(int sig, int fastExit) ===================================== rts/RtsUtils.h ===================================== @@ -17,17 +17,36 @@ void initAllocator(void); void shutdownAllocator(void); -void *stgMallocBytes(size_t n, char *msg) - GNUC3_ATTRIBUTE(__malloc__); +void stgFree(void* p); -void *stgReallocBytes(void *p, size_t n, char *msg); +void *stgMallocBytes(size_t n, char *msg) + STG_MALLOC STG_MALLOC1(stgFree) + STG_ALLOC_SIZE1(1); +/* Note: unlike `stgReallocBytes` and `stgCallocBytes`, `stgMallocBytes` is + * *not* `STG_RETURNS_NONNULL`, since it will return `NULL` when the requested + * allocation size is zero. + * + * See: https://gitlab.haskell.org/ghc/ghc/-/issues/22380 + */ + +void *stgReallocBytes(void *p, size_t n, char *msg) + STG_MALLOC1(stgFree) + STG_ALLOC_SIZE1(2) + STG_RETURNS_NONNULL; +/* Note: `stgRallocBytes` can *not* be tagged as `STG_MALLOC` + * since its return value *can* alias an existing pointer (i.e., + * the given pointer `p`). + * See the documentation of the `malloc` attribute in the GCC manual + * for more information. + */ void *stgCallocBytes(size_t count, size_t size, char *msg) - GNUC3_ATTRIBUTE(__malloc__); - -char *stgStrndup(const char *s, size_t n); + STG_MALLOC STG_MALLOC1(stgFree) + STG_ALLOC_SIZE2(1, 2) + STG_RETURNS_NONNULL; -void stgFree(void* p); +char *stgStrndup(const char *s, size_t n) + STG_MALLOC STG_MALLOC1(stgFree); /* ----------------------------------------------------------------------------- * Misc other utilities ===================================== rts/StgCRun.c ===================================== @@ -163,7 +163,7 @@ StgFunPtr StgReturn(void) * */ -static void GNUC3_ATTRIBUTE(used) +static void STG_USED StgRunIsImplementedInAssembler(void) { __asm__ volatile ( @@ -372,7 +372,7 @@ stack unwinding. */ -static void GNUC3_ATTRIBUTE(used) +static void STG_USED StgRunIsImplementedInAssembler(void) { __asm__ volatile ( @@ -595,7 +595,7 @@ StgRunIsImplementedInAssembler(void) // This version is for PowerPC Linux. -static void GNUC3_ATTRIBUTE(used) +static void STG_USED StgRunIsImplementedInAssembler(void) { __asm__ volatile ( @@ -698,7 +698,7 @@ StgRunIsImplementedInAssembler(void) * the TOC pointer from the function descriptor upon a call to StgReturn. * That TOC pointer is the same as the TOC pointer in StgRun. */ -static void GNUC3_ATTRIBUTE(used) +static void STG_USED StgRunIsImplementedInAssembler(void) { __asm__ volatile ( ===================================== rts/include/Rts.h ===================================== @@ -121,7 +121,7 @@ extern "C" { -------------------------------------------------------------------------- */ void _assertFail(const char *filename, unsigned int linenum) - GNUC3_ATTRIBUTE(__noreturn__); + STG_NORETURN; void _warnFail(const char *filename, unsigned int linenum); @@ -290,7 +290,7 @@ DLL_IMPORT_RTS extern char *prog_name; void reportStackOverflow(StgTSO* tso); void reportHeapOverflow(void); -void stg_exit(int n) GNU_ATTRIBUTE(__noreturn__); +void stg_exit(int n) STG_NORETURN; #if !defined(mingw32_HOST_OS) int stg_sig_install (int, int, void *); ===================================== rts/include/RtsAPI.h ===================================== @@ -310,11 +310,11 @@ extern void hs_init_ghc (int *argc, char **argv[], // program arguments RtsConfig rts_config); // RTS configuration extern void shutdownHaskellAndExit (int exitCode, int fastExit) - GNUC3_ATTRIBUTE(__noreturn__); + STG_NORETURN; #if !defined(mingw32_HOST_OS) extern void shutdownHaskellAndSignal (int sig, int fastExit) - GNUC3_ATTRIBUTE(__noreturn__); + STG_NORETURN; #endif extern void getProgArgv ( int *argc, char **argv[] ); ===================================== rts/include/Stg.h ===================================== @@ -220,6 +220,7 @@ #endif #define STG_UNUSED GNUC3_ATTRIBUTE(__unused__) +#define STG_USED GNUC3_ATTRIBUTE(__used__) /* Prevent functions from being optimized. See Note [Windows Stack allocations] */ @@ -241,6 +242,67 @@ #define STG_PRINTF_ATTR(fmt_arg, rest) GNUC3_ATTRIBUTE(format(printf, fmt_arg, rest)) #endif +#define STG_NORETURN GNU_ATTRIBUTE(__noreturn__) + +#define STG_MALLOC GNUC3_ATTRIBUTE(__malloc__) + +/* Instead of relying on GCC version checks to expand attributes, + * use `__has_attribute` which is supported by GCC >= 5 and Clang. Hence, the + * following macros won't expand on older compiler versions, but since they're + * purely for optimization or static analysis purposes, there's no harm done. + * + * See: https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html + * See: https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute + */ +#ifdef __has_attribute +# define stg__has_attribute(attr) __has_attribute(attr) +#else +# define stg__has_attribute(attr) (0) +#endif + +#ifdef __GNUC__ +# define STG_GNUC_GUARD_VERSION(major, minor) \ + ((__GNUC__ > (major)) || \ + ((__GNUC__ == (major)) && (__GNUC_MINOR__ >= (minor)))) +#else +# define STG_GNUC_GUARD_VERSION(major, minor) (0) +#endif + +/* + * The versions of the `__malloc__` attribute which take arguments are only + * supported in GCC 11 and later. + * + * See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute + * See: https://developers.redhat.com/blog/2021/04/30/detecting-memory-management-bugs-with-gcc-11-part-1-understanding-dynamic-allocation#attribute_malloc + */ +#if stg__has_attribute(__malloc__) && STG_GNUC_GUARD_VERSION(11, 0) +# define STG_MALLOC1(deallocator) __attribute__((__malloc__(deallocator))) +# define STG_MALLOC2(deallocator, ptrIndex) __attribute__((__malloc__(deallocator, ptrIndex))) +#else +# define STG_MALLOC1(deallocator) +# define STG_MALLOC2(deallocator, ptrIndex) +#endif + +/* + * https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute + */ +#if stg__has_attribute(__alloc_size__) +# define STG_ALLOC_SIZE1(position) __attribute__((__alloc_size__(position))) +# define STG_ALLOC_SIZE2(position1, position2) __attribute__((__alloc_size__(position1, position2))) +#else +# define STG_ALLOC_SIZE1(position) +# define STG_ALLOC_SIZE2(position1, position2) +#endif + +/* + * https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute + */ +#if stg__has_attribute(__returns_nonnull__) +# define STG_RETURNS_NONNULL __attribute__((__returns_nonnull__)) +#else +# define STG_RETURNS_NONNULL +#endif + /* ----------------------------------------------------------------------------- Global type definitions -------------------------------------------------------------------------- */ ===================================== rts/include/rts/Main.h ===================================== @@ -15,4 +15,4 @@ int hs_main (int argc, char *argv[], // program args StgClosure *main_closure, // closure for Main.main RtsConfig rts_config) // RTS configuration - GNUC3_ATTRIBUTE(__noreturn__); + STG_NORETURN; ===================================== rts/include/rts/Messages.h ===================================== @@ -31,15 +31,15 @@ * expected to return. */ void barf(const char *s, ...) - GNUC3_ATTRIBUTE(__noreturn__) + STG_NORETURN STG_PRINTF_ATTR(1, 2); void vbarf(const char *s, va_list ap) - GNUC3_ATTRIBUTE(__noreturn__); + STG_NORETURN; // declared in Rts.h: // extern void _assertFail(const char *filename, unsigned int linenum) -// GNUC3_ATTRIBUTE(__noreturn__); +// STG_NORETURN; /* * An error condition which is caused by and/or can be corrected by ===================================== rts/include/rts/OSThreads.h ===================================== @@ -168,7 +168,7 @@ typedef SRWLOCK Mutex; // General thread operations // extern OSThreadId osThreadId ( void ); -extern void shutdownThread ( void ) GNUC3_ATTRIBUTE(__noreturn__); +extern void shutdownThread ( void ) STG_NORETURN; extern void yieldThread ( void ); typedef void* OSThreadProcAttr OSThreadProc(void *); ===================================== rts/include/rts/Threads.h ===================================== @@ -61,7 +61,7 @@ struct _StgMutArrPtrs *listThreads (Capability *cap); pid_t forkProcess (HsStablePtr *entry); #else pid_t forkProcess (HsStablePtr *entry) - GNU_ATTRIBUTE(__noreturn__); + STG_NORETURN; #endif HsBool rtsSupportsBoundThreads (void); ===================================== rts/linker/Elf.c ===================================== @@ -2054,7 +2054,7 @@ struct piterate_cb_info { }; static int loadNativeObjCb_(struct dl_phdr_info *info, - size_t _size GNUC3_ATTRIBUTE(__unused__), void *data) { + size_t _size STG_UNUSED, void *data) { struct piterate_cb_info *s = (struct piterate_cb_info *) data; // This logic mimicks _dl_addr_inside_object from glibc ===================================== rts/linker/M32Alloc.h ===================================== @@ -21,7 +21,7 @@ #if defined(NEED_M32) #define M32_NO_RETURN /* Nothing */ #else -#define M32_NO_RETURN GNUC3_ATTRIBUTE(__noreturn__) +#define M32_NO_RETURN STG_NORETURN #endif struct m32_allocator_t; ===================================== rts/linker/elf_reloc_aarch64.c ===================================== @@ -22,7 +22,7 @@ bool isAdrp(addr_t p); bool isLoadStore(addr_t p); bool isAddSub(addr_t p); bool isVectorOp(addr_t p); -int64_t decodeAddendAarch64(Section * section, Elf_Rel * rel) GNU_ATTRIBUTE(__noreturn__); +int64_t decodeAddendAarch64(Section * section, Elf_Rel * rel) STG_NORETURN; bool encodeAddendAarch64(Section * section, Elf_Rel * rel, int64_t addend); bool isBranch(addr_t p) { @@ -51,8 +51,8 @@ bool isVectorOp(addr_t p) { typedef uint32_t inst_t; int64_t -decodeAddendAarch64(Section * section __attribute__((unused)), - Elf_Rel * rel __attribute__((unused))) +decodeAddendAarch64(Section * section STG_UNUSED, + Elf_Rel * rel STG_UNUSED) { abort(/* we don't support Rel locations yet. */); } ===================================== rts/linker/elf_tlsgd.c ===================================== @@ -161,7 +161,7 @@ typedef struct tls_sym { typedef struct dl_phdr_info dlpi; static int -find_tls_sym(dlpi *info, size_t sz __attribute__((unused)), void *data) +find_tls_sym(dlpi *info, size_t sz STG_UNUSED, void *data) { tls_sym *wanted = (tls_sym *)data; const Elf_Addr base = info->dlpi_addr; ===================================== rts/posix/OSThreads.c ===================================== @@ -445,7 +445,7 @@ setThreadAffinity (uint32_t n, uint32_t m) #elif defined(darwin_HOST_OS) && defined(THREAD_AFFINITY_POLICY) // Schedules the current thread in the affinity set identified by tag n. void -setThreadAffinity (uint32_t n, uint32_t m GNUC3_ATTRIBUTE(__unused__)) +setThreadAffinity (uint32_t n, uint32_t m STG_UNUSED) { thread_affinity_policy_data_t policy; ===================================== rts/posix/Select.c ===================================== @@ -115,7 +115,7 @@ static bool wakeUpSleepingThreads (LowResTime now) return flag; } -static void GNUC3_ATTRIBUTE(__noreturn__) +static void STG_NORETURN fdOutOfRange (int fd) { errorBelch("file descriptor %d out of range for select (0--%d).\n" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4521f6498d09f48a775a028efdd763c874da3451...c235b399d094af3b706eb5a4bf15712fe5e4f795 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4521f6498d09f48a775a028efdd763c874da3451...c235b399d094af3b706eb5a4bf15712fe5e4f795 You're receiving 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 Nov 2 16:07:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 02 Nov 2022 12:07:40 -0400 Subject: [Git][ghc/ghc][master] Move Symbol implementation note out of public haddock Message-ID: <636295ccfc5e_6587e4b7d0688a3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 1 changed file: - libraries/ghc-prim/GHC/Types.hs Changes: ===================================== libraries/ghc-prim/GHC/Types.hs ===================================== @@ -132,9 +132,10 @@ type family MultMul (a :: Multiplicity) (b :: Multiplicity) :: Multiplicity wher ********************************************************************* -} -- | (Kind) This is the kind of type-level symbols. --- Declared here because class IP needs it data Symbol +-- Symbol is declared here because class IP needs it + {- ********************************************************************* * * Any View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed81b44858ef6527087d82c0114ed0b2bf42399d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed81b44858ef6527087d82c0114ed0b2bf42399d You're receiving 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 Nov 2 16:29:46 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 02 Nov 2022 12:29:46 -0400 Subject: [Git][ghc/ghc][wip/T22152] 212 commits: Export liftA2 from Prelude Message-ID: <63629afa6d312_6587e6d90208515d@gitlab.mail> Sylvain Henry pushed to branch wip/T22152 at Glasgow Haskell Compiler / GHC Commits: 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 42d43f11 by Sylvain Henry at 2022-11-02T16:29:40+00:00 Add quotRemInt rules (#22152) - - - - - 30 changed files: - − .appveyor.sh - .editorconfig - .gitlab-ci.yml - .gitlab/ci.sh - README.md - − appveyor.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/ByteCode/Instr.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/CommonBlockElim.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow.hs - compiler/GHC/Cmm/Dataflow/Label.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Liveness.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Node.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Reg.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a3d0eac85651e09f755839a6d4a219f6e14faba...42d43f11b9a86d07387670a4e95085b19fca8904 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6a3d0eac85651e09f755839a6d4a219f6e14faba...42d43f11b9a86d07387670a4e95085b19fca8904 You're receiving 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 Nov 2 16:34:15 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 02 Nov 2022 12:34:15 -0400 Subject: [Git][ghc/ghc][wip/sjakobi/21176-integer-bits] 881 commits: hadrian: Ensure that --extra-lib-dirs are used Message-ID: <63629c071b33e_6587e4b7bc8589d@gitlab.mail> Sylvain Henry pushed to branch wip/sjakobi/21176-integer-bits at Glasgow Haskell Compiler / GHC Commits: 0950e2c4 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Ensure that --extra-lib-dirs are used Previously we only took `extraLibDirs` and friends from the package description, ignoring any contribution from the `LocalBuildInfo`. Fix this. Fixes #20566. - - - - - 53cc93ae by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Drop redundant include directories The package-specific include directories in Settings.Builders.Common.cIncludeDirs are now redundant since they now come from Cabal. Closes #20566. - - - - - b2721819 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Clean up handling of libffi dependencies - - - - - 18e5103f by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: More robust library way detection Previously `test.mk` would try to determine whether the dynamic, profiling, and vanilla library ways are available by searching for `PrimOpWrappers.{,dyn_,p_}hi` in directory reported by `ghc-pkg field ghc-prim library-dirs`. However, this is extremely fragile as there is no guarantee that there is only one library directory. To handle the case of multiple `library-dirs` correct we would have to carry out the delicate task of tokenising the directory list (in shell, no less). Since this isn't a task that I am eager to solve, I have rather moved the detection logic into the testsuite driver and instead perform a test compilation in each of the ways. This should be more robust than the previous approach. I stumbled upon this while fixing #20579. - - - - - 6c7a4913 by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: Cabalify ghc-config To ensure that the build benefits from Hadrian's usual logic for building packages, avoiding #21409. Closes #21409. - - - - - 9af091f7 by Ben Gamari at 2022-04-25T10:18:53-04:00 rts: Factor out built-in GC roots - - - - - e7c4719d by Ben Gamari at 2022-04-25T10:18:54-04:00 Ensure that wired-in exception closures aren't GC'd As described in Note [Wired-in exceptions are not CAFfy], a small set of built-in exception closures get special treatment in the code generator, being declared as non-CAFfy despite potentially containing CAF references. The original intent of this treatment for the RTS to then add StablePtrs for each of the closures, ensuring that they are not GC'd. However, this logic was not applied consistently and eventually removed entirely in 951c1fb0. This lead to #21141. Here we fix this bug by reintroducing the StablePtrs and document the status quo. Closes #21141. - - - - - 9587726f by Ben Gamari at 2022-04-25T10:18:54-04:00 testsuite: Add testcase for #21141 - - - - - cb71226f by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop dead code in GHC.Linker.Static.linkBinary' Previously we supported building statically-linked executables using libtool. However, this was dropped in 91262e75dd1d80f8f28a3922934ec7e59290e28c in favor of using ar/ranlib directly. Consequently we can drop this logic. Fixes #18826. - - - - - 9420d26b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop libtool path from settings file GHC no longers uses libtool for linking and therefore this is no longer necessary. - - - - - 41cf758b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop remaining vestiges of libtool Drop libtool logic from gen-dll, allowing us to drop the remaining logic from the `configure` script. Strangely, this appears to reliably reduce compiler allocations of T16875 on Windows. Closes #18826. Metric Decrease: T16875 - - - - - e09afbf2 by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - e76705cf by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Improve documentation of closure types Also drops the unused TREC_COMMITTED transaction state. - - - - - f2c08124 by Bodigrim at 2022-04-25T10:20:44-04:00 Document behaviour of RULES with KnownNat - - - - - 360dc2bc by Li-yao Xia at 2022-04-25T19:13:06+00:00 Fix rendering of liftA haddock - - - - - 16df6058 by Ben Gamari at 2022-04-27T10:02:25-04:00 testsuite: Report minimum and maximum stat changes As suggested in #20733. - - - - - e39cab62 by Fabian Thorand at 2022-04-27T10:03:03-04:00 Defer freeing of mega block groups Solves the quadratic worst case performance of freeing megablocks that was described in issue #19897. During GC runs, we now keep a secondary free list for megablocks that is neither sorted, nor coalesced. That way, free becomes an O(1) operation at the expense of not being able to reuse memory for larger allocations. At the end of a GC run, the secondary free list is sorted and then merged into the actual free list in a single pass. That way, our worst case performance is O(n log(n)) rather than O(n^2). We postulate that temporarily losing coalescense during a single GC run won't have any adverse effects in practice because: - We would need to release enough memory during the GC, and then after that (but within the same GC run) allocate a megablock group of more than one megablock. This seems unlikely, as large objects are not copied during GC, and so we shouldn't need such large allocations during a GC run. - Allocations of megablock groups of more than one megablock are rare. They only happen when a single heap object is large enough to require that amount of space. Any allocation areas that are supposed to hold more than one heap object cannot use megablock groups, because only the first megablock of a megablock group has valid `bdescr`s. Thus, heap object can only start in the first megablock of a group, not in later ones. - - - - - 5de6be0c by Fabian Thorand at 2022-04-27T10:03:03-04:00 Add note about inefficiency in returnMemoryToOS - - - - - 8bef471a by sheaf at 2022-04-27T10:03:43-04:00 Ensure that Any is Boxed in FFI imports/exports We should only accept the type `Any` in foreign import/export declarations when it has type `Type` or `UnliftedType`. This patch adds a kind check, and a special error message triggered by occurrences of `Any` in foreign import/export declarations at other kinds. Fixes #21305 - - - - - ba3d4e1c by Ben Gamari at 2022-04-27T10:04:19-04:00 Basic response file support Here we introduce support into our command-line parsing infrastructure and driver for handling gnu-style response file arguments, typically used to work around platform command-line length limitations. Fixes #16476. - - - - - 3b6061be by Ben Gamari at 2022-04-27T10:04:19-04:00 testsuite: Add test for #16476 - - - - - 75bf1337 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix cabal-reinstall job It's quite nice we can do this by mostly deleting code Fixes #21373 - - - - - 2c00d904 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add test to check that release jobs have profiled libs - - - - - 50d78d3b by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Explicitly handle failures in test_hadrian We also disable the stage1 testing which is broken. Related to #21072 - - - - - 2dcdf091 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix shell command - - - - - 55c84123 by Matthew Pickering at 2022-04-27T10:04:55-04:00 bootstrap: Add bootstrapping files for ghc-9_2_2 Fixes #21373 - - - - - c7ee0be6 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add linting job which checks authors are not GHC CI - - - - - 23aad124 by Adam Sandberg Ericsson at 2022-04-27T10:05:31-04:00 rts: state explicitly what evacuate and scavange mean in the copying gc - - - - - 318e0005 by Ben Gamari at 2022-04-27T10:06:07-04:00 rts/eventlog: Don't attempt to flush if there is no writer If the user has not configured a writer then there is nothing to flush. - - - - - ee11d043 by Ben Gamari at 2022-04-27T10:06:07-04:00 Enable eventlog support in all ways by default Here we deprecate the eventlogging RTS ways and instead enable eventlog support in the remaining ways. This simplifies packaging and reduces GHC compilation times (as we can eliminate two whole compilations of the RTS) while simplifying the end-user story. The trade-off is a small increase in binary sizes in the case that the user does not want eventlogging support, but we think that this is a fine trade-off. This also revealed a latent RTS bug: some files which included `Cmm.h` also assumed that it defined various macros which were in fact defined by `Config.h`, which `Cmm.h` did not include. Fixing this in turn revealed that `StgMiscClosures.cmm` failed to import various spinlock statistics counters, as evidenced by the failed unregisterised build. Closes #18948. - - - - - a2e5ab70 by Andreas Klebinger at 2022-04-27T10:06:43-04:00 Change `-dsuppress-ticks` to only suppress non-code ticks. This means cost centres and coverage ticks will still be present in output. Makes using -dsuppress-all more convenient when looking at profiled builds. - - - - - ec9d7e04 by Ben Gamari at 2022-04-27T10:07:21-04:00 Bump text submodule. This should fix #21352 - - - - - c3105be4 by Bodigrim at 2022-04-27T10:08:01-04:00 Documentation for setLocaleEncoding - - - - - 7f618fd3 by sheaf at 2022-04-27T10:08:40-04:00 Update docs for change to type-checking plugins There was no mention of the changes to type-checking plugins in the 9.4.1 notes, and the extending_ghc documentation contained a reference to an outdated type. - - - - - 4419dd3a by Adam Sandberg Ericsson at 2022-04-27T10:09:18-04:00 rts: add some more documentation to StgWeak closure type - - - - - 5a7f0dee by Matthew Pickering at 2022-04-27T10:09:54-04:00 Give Cmm files fake ModuleNames which include full filepath This fixes the initialisation functions when using -prof or -finfo-table-map. Fixes #21370 - - - - - 81cf52bb by sheaf at 2022-04-27T10:10:33-04:00 Mark GHC.Prim.PtrEq as Unsafe This module exports unsafe pointer equality operations, so we accordingly mark it as Unsafe. Fixes #21433 - - - - - f6a8185d by Ben Gamari at 2022-04-28T09:10:31+00:00 testsuite: Add performance test for #14766 This distills the essence of the Sigs.hs program found in the ticket. - - - - - c7a3dc29 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Add Monoid instance to Way - - - - - 654bafea by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Enrich flavours to build profiled/debugged/threaded ghcs per stage - - - - - 4ad559c8 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: add debug_ghc and debug_stage1_ghc flavour transformers - - - - - f9728fdb by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Don't pass -rtsopts when building libraries - - - - - 769279e6 by Matthew Pickering at 2022-04-28T18:54:44-04:00 testsuite: Fix calculation about whether to pass -dynamic to compiler - - - - - da8ae7f2 by Ben Gamari at 2022-04-28T18:55:20-04:00 hadrian: Clean up flavour transformer definitions Previously the `ipe` and `omit_pragmas` transformers were hackily defined using the textual key-value syntax. Fix this. - - - - - 61305184 by Ben Gamari at 2022-04-28T18:55:56-04:00 Bump process submodule - - - - - a8c99391 by sheaf at 2022-04-28T18:56:37-04:00 Fix unification of ConcreteTvs, removing IsRefl# This patch fixes the unification of concrete type variables. The subtlety was that unifying concrete metavariables is more subtle than other metavariables, as decomposition is possible. See the Note [Unifying concrete metavariables], which explains how we unify a concrete type variable with a type 'ty' by concretising 'ty', using the function 'GHC.Tc.Utils.Concrete.concretise'. This can be used to perform an eager syntactic check for concreteness, allowing us to remove the IsRefl# special predicate. Instead of emitting two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we instead concretise 'rr'. If this succeeds we can fill 'concrete_tv', and otherwise we directly emit an error message to the typechecker environment instead of deferring. We still need the error message to be passed on (instead of directly thrown), as we might benefit from further unification in which case we will need to zonk the stored types. To achieve this, we change the 'wc_holes' field of 'WantedConstraints' to 'wc_errors', which stores general delayed errors. For the moement, a delayed error is either a hole, or a syntactic equality error. hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and hasFixedRuntimeRep has been refactored to directly return the most useful coercion for PHASE 2 of FixedRuntimeRep. This patch also adds a field ir_frr to the InferResult datatype, holding a value of type Maybe FRROrigin. When this value is not Nothing, this means that we must fill the ir_ref field with a type which has a fixed RuntimeRep. When it comes time to fill such an ExpType, we ensure that the type has a fixed RuntimeRep by performing a representation-polymorphism check with the given FRROrigin This is similar to what we already do to ensure we fill an Infer ExpType with a type of the correct TcLevel. This allows us to properly perform representation-polymorphism checks on 'Infer' 'ExpTypes'. The fillInferResult function had to be moved to GHC.Tc.Utils.Unify to avoid a cyclic import now that it calls hasFixedRuntimeRep. This patch also changes the code in matchExpectedFunTys to make use of the coercions, which is now possible thanks to the previous change. This implements PHASE 2 of FixedRuntimeRep in some situations. For example, the test cases T13105 and T17536b are now both accepted. Fixes #21239 and #21325 ------------------------- Metric Decrease: T18223 T5631 ------------------------- - - - - - 43bd897d by Simon Peyton Jones at 2022-04-28T18:57:13-04:00 Add INLINE pragmas for Enum helper methods As #21343 showed, we need to be super-certain that the "helper methods" for Enum instances are actually inlined or specialised. I also tripped over this when I discovered that numericEnumFromTo and friends had no pragmas at all, so their performance was very fragile. If they weren't inlined, all bets were off. So I've added INLINE pragmas for them too. See new Note [Inline Enum method helpers] in GHC.Enum. I also expanded Note [Checking for INLINE loop breakers] in GHC.Core.Lint to explain why an INLINE function might temporarily be a loop breaker -- this was the initial bug report in #21343. Strangely we get a 16% runtime allocation decrease in perf/should_run/T15185, but only on i386. Since it moves in the right direction I'm disinclined to investigate, so I'll accept it. Metric Decrease: T15185 - - - - - ca1434e3 by Ben Gamari at 2022-04-28T18:57:49-04:00 configure: Bump GHC version to 9.5 Bumps haddock submodule. - - - - - 292e3971 by Teo Camarasu at 2022-04-28T18:58:28-04:00 add since annotation for GHC.Stack.CCS.whereFrom - - - - - 905206d6 by Tamar Christina at 2022-04-28T22:19:34-04:00 winio: add support to iserv. - - - - - d182897e by Tamar Christina at 2022-04-28T22:19:34-04:00 Remove unused line - - - - - 22cf4698 by Matthew Pickering at 2022-04-28T22:20:10-04:00 Revert "rts: Refactor handling of dead threads' stacks" This reverts commit e09afbf2a998beea7783e3de5dce5dd3c6ff23db. - - - - - 8ed57135 by Matthew Pickering at 2022-04-29T04:11:29-04:00 Provide efficient unionMG function for combining two module graphs. This function is used by API clients (hls). This supercedes !6922 - - - - - 0235ff02 by Ben Gamari at 2022-04-29T04:12:05-04:00 Bump bytestring submodule Update to current `master`. - - - - - 01988418 by Matthew Pickering at 2022-04-29T04:12:05-04:00 testsuite: Normalise package versions in UnusedPackages test - - - - - 724d0dc0 by Matthew Pickering at 2022-04-29T08:59:42+00:00 testsuite: Deduplicate ways correctly This was leading to a bug where we would run a profasm test twice which led to invalid junit.xml which meant the test results database was not being populated for the fedora33-perf job. - - - - - 5630dde6 by Ben Gamari at 2022-04-29T13:06:20-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - 0cdef807 by parsonsmatt at 2022-04-30T16:51:12-04:00 Add a note about instance visibility across component boundaries In principle, the *visible* instances are * all instances defined in a prior top-level declaration group (see docs on `newDeclarationGroup`), or * all instances defined in any module transitively imported by the module being compiled However, actually searching all modules transitively below the one being compiled is unreasonably expensive, so `reifyInstances` will report only the instance for modules that GHC has had some cause to visit during this compilation. This is a shortcoming: `reifyInstances` might fail to report instances for a type that is otherwise unusued, or instances defined in a different component. You can work around this shortcoming by explicitly importing the modules whose instances you want to be visible. GHC issue #20529 has some discussion around this. Fixes #20529 - - - - - e2dd884a by Ryan Scott at 2022-04-30T16:51:47-04:00 Make mkFunCo take AnonArgFlags into account Previously, whenever `mkFunCo` would produce reflexive coercions, it would use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is also used to produce coercions between types of the form `ty1 => ty2` in certain places. This has the unfortunate side effect of causing the type of the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted in #21328. This patch address this by changing replacing the use of `mkVisFunTy` with `mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`, so this should always produce the correct `AnonArgFlag`. As a result, this patch fixes part (2) of #21328. This is not the only possible way to fix #21328, as the discussion on that issue lists some possible alternatives. Ultimately, it was concluded that the alternatives would be difficult to maintain, and since we already use `mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType` in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType` does not regress the performance of any test case we have in GHC's test suite. - - - - - 170da54f by Ben Gamari at 2022-04-30T16:52:27-04:00 Convert More Diagnostics (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors. - - - - - 39edc7b4 by Marius Ghita at 2022-04-30T16:53:06-04:00 Update user guide example rewrite rules formatting Change the rewrite rule examples to include a space between the composition of `f` and `g` in the map rewrite rule examples. Without this change, if the user has locally enabled the extension OverloadedRecordDot the copied example will result in a compile time error that `g` is not a field of `f`. ``` • Could not deduce (GHC.Records.HasField "g" (a -> b) (a1 -> b)) arising from selecting the field ‘g’ ``` - - - - - 2e951e48 by Adam Sandberg Ericsson at 2022-04-30T16:53:42-04:00 ghc-boot: export typesynonyms from GHC.Utils.Encoding This makes the Haddocks easier to understand. - - - - - d8cbc77e by Adam Sandberg Ericsson at 2022-04-30T16:54:18-04:00 users guide: add categories to some flags - - - - - d0f14fad by Chris Martin at 2022-04-30T16:54:57-04:00 hacking guide: mention the core libraries committee - - - - - 34b28200 by Matthew Pickering at 2022-04-30T16:55:32-04:00 Revert "Make the specialiser handle polymorphic specialisation" This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8. See ticket #21229 ------------------------- Metric Decrease: T15164 Metric Increase: T13056 ------------------------- - - - - - ee891c1e by Matthew Pickering at 2022-04-30T16:55:32-04:00 Add test for T21229 - - - - - ab677cc8 by Matthew Pickering at 2022-04-30T16:56:08-04:00 Hadrian: Update README about the flavour/testsuite contract There have been a number of tickets about non-tested flavours not passing the testsuite.. this is expected and now noted in the documentation. You use other flavours to run the testsuite at your own risk. Fixes #21418 - - - - - b57b5b92 by Ben Gamari at 2022-04-30T16:56:44-04:00 rts/m32: Fix assertion failure This fixes an assertion failure in the m32 allocator due to the imprecisely specified preconditions of `m32_allocator_push_filled_list`. Specifically, the caller must ensure that the page type is set to filled prior to calling `m32_allocator_push_filled_list`. While this issue did result in an assertion failure in the debug RTS, the issue is in fact benign. - - - - - a7053a6c by sheaf at 2022-04-30T16:57:23-04:00 Testsuite driver: don't crash on empty metrics The testsuite driver crashed when trying to display minimum/maximum performance changes when there are no metrics (i.e. there is no baseline available). This patch fixes that. - - - - - 636f7c62 by Andreas Klebinger at 2022-05-01T22:21:17-04:00 StgLint: Check that functions are applied to compatible runtime reps We use compatibleRep to compare reps, and avoid checking functions with levity polymorphic types because of #21399. - - - - - 60071076 by Hécate Moonlight at 2022-05-01T22:21:55-04:00 Add documentation to the ByteArray# primetype. close #21417 - - - - - 2b2e3020 by Andreas Klebinger at 2022-05-01T22:22:31-04:00 exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is bottoming. We used to check the divergence and that the number of arguments > arity. But arity zero represents unknown arity so this was subtly broken for a long time! We would check if the saturated function diverges, and if we applied >=arity arguments. But for unknown arity functions any number of arguments is >=idArity. This fixes #21440. - - - - - 4eaf0f33 by Eric Lindblad at 2022-05-01T22:23:11-04:00 typos - - - - - fc58df90 by Niklas Hambüchen at 2022-05-02T08:59:27+00:00 libraries/base: docs: Explain relationshipt between `finalizeForeignPtr` and `*Conc*` creation Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/21420 - - - - - 3e400f20 by Krzysztof Gogolewski at 2022-05-02T18:29:23-04:00 Remove obsolete code in CoreToStg Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4. This codepath is tested by T15696_3. - - - - - 4a780928 by Krzysztof Gogolewski at 2022-05-02T18:29:24-04:00 Fix several note references - - - - - 15ffe2b0 by Sebastian Graf at 2022-05-03T20:11:51+02:00 Assume at least one evaluation for nested SubDemands (#21081, #21133) See the new `Note [SubDemand denotes at least one evaluation]`. A demand `n :* sd` on a let binder `x=e` now means > "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is > evaluated deeply in sub-demand `sd`." The "any time it is evaluated" premise is what this patch adds. As a result, we get better nested strictness. For example (T21081) ```hs f :: (Bool, Bool) -> (Bool, Bool) f pr = (case pr of (a,b) -> a /= b, True) -- before: <MP(L,L)> -- after: <MP(SL,SL)> g :: Int -> (Bool, Bool) g x = let y = let z = odd x in (z,z) in f y ``` The change in demand signature "before" to "after" allows us to case-bind `z` here. Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`, albeit). We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand expansion. In an attempt to fix a regression caused by less inlining due to eta-reduction in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus fixing #21345 on the go. The main point of this patch is that it fixes #21081 and #21133. Annoyingly, I discovered that more precise demand signatures for join points can transform a program into a lazier program if that join point gets floated to the top-level, see #21392. There is no simple fix at the moment, but !5349 might. Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392 bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue. Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by 0.4% in the geometric mean and by 2% in T16875. Metric Increase: MultiLayerModulesTH_OneShot Metric Decrease: T16875 - - - - - 948c7e40 by Andreas Klebinger at 2022-05-04T09:57:34-04:00 CoreLint - When checking for levity polymorphism look through more ticks. For expressions like `(scc<cc_name> primOp#) arg1` we should also look at arg1 to determine if we call primOp# at a fixed runtime rep. This is what corePrep already does but CoreLint didn't yet. This patch will bring them in sync in this regard. It also uses tickishFloatable in CorePrep instead of CorePrep having it's own slightly differing definition of when a tick is floatable. - - - - - 85bc73bd by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Support Unicode properly - - - - - 063d485e by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Replace LaTeX documentation syntax with Haddock The LaTeX documentation generator does not seem to have been used for quite some time, so the LaTeX-to-Haddock preprocessing step has become a pointless complication that makes documenting the contents of GHC.Prim needlessly difficult. This commit replaces the LaTeX syntax with the Haddock it would have been converted into, anyway, though with an additional distinction: it uses single quotes in places to instruct Haddock to generate hyperlinks to bindings. This improves the quality of the generated output. - - - - - d61f7428 by Ben Gamari at 2022-05-04T09:58:50-04:00 rts/ghc.mk: Only build StgCRunAsm.S when it is needed Previously the make build system unconditionally included StgCRunAsm.S in the link, meaning that the RTS would require an execstack unnecessarily. Fixes #21478. - - - - - 934a90dd by Simon Peyton Jones at 2022-05-04T16:15:34-04:00 Improve error reporting in generated code Our error reporting in generated code (via desugaring before typechecking) only worked when the generated code was just a simple call. This commit makes it work in nested cases. - - - - - 445d3657 by sheaf at 2022-05-04T16:16:12-04:00 Ensure Any is not levity-polymorphic in FFI The previous patch forgot to account for a type such as Any @(TYPE (BoxedRep l)) for a quantified levity variable l. - - - - - ddd2591c by Ben Gamari at 2022-05-04T16:16:48-04:00 Update supported LLVM versions Pull forward minimum version to match 9.2. (cherry picked from commit c26faa54c5fbe902ccb74e79d87e3fa705e270d1) - - - - - f9698d79 by Ben Gamari at 2022-05-04T16:16:48-04:00 testsuite/T7275: Use sed -r Darwin requires the `-r` flag to be compatible with GNU sed. (cherry picked from commit 512338c8feec96c38ef0cf799f3a01b77c967c56) - - - - - 8635323b by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Use ld.lld on ARMv7/Linux Due to #16177. Also cleanup some code style issues. (cherry picked from commit cc1c3861e2372f464bf9e3c9c4d4bd83f275a1a6) - - - - - 4f6370c7 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Always preserve artifacts, even in failed jobs (cherry picked from commit fd08b0c91ea3cab39184f1b1b1aafcd63ce6973f) - - - - - 6f662754 by Ben Gamari at 2022-05-04T16:16:48-04:00 configure: Make sphinx version check more robust It appears that the version of sphinx shipped on CentOS 7 reports a version string of `Sphinx v1...`. Accept the `v`. (cherry picked from commit a9197a292fd4b13308dc6664c01351c7239357ed) - - - - - 0032dc38 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Don't run make job in release pipelines (cherry picked from commit 16d6a8ff011f2194485387dcca1c00f8ddcdbdeb) - - - - - 27f9aab3 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab/ci: Fix name of bootstrap compiler directory Windows binary distributions built with Hadrian have a target platform suffix in the name of their root directory. Teach `ci.sh` about this fact. (cherry picked from commit df5752f39671f6d04d8cd743003469ae5eb67235) - - - - - b528f0f6 by Krzysztof Gogolewski at 2022-05-05T09:05:43-04:00 Fix several note references, part 2 - - - - - 691aacf6 by Adam Sandberg Ericsson at 2022-05-05T09:06:19-04:00 adjustors: align comment about number of integer like arguments with implementation for Amd4+MinGW implementation - - - - - f050557e by Simon Jakobi at 2022-05-05T12:47:32-04:00 Remove two uses of IntMap.size IntMap.size is O(n). The new code should be slightly more efficient. The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be described formally as the transformation: (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n ==> (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk) - - - - - 7da90ae3 by Tom Ellis at 2022-05-05T12:48:09-04:00 Explain that 'fail s' should run in the monad itself - - - - - 610d0283 by Matthew Craven at 2022-05-05T12:48:47-04:00 Add a test for the bracketing in rules for (^) - - - - - 016f9ca6 by Matthew Craven at 2022-05-05T12:48:47-04:00 Fix broken rules for (^) with known small powers - - - - - 9372aaab by Matthew Craven at 2022-05-05T12:48:47-04:00 Give the two T19569 tests different names - - - - - 61901b32 by Andreas Klebinger at 2022-05-05T12:49:23-04:00 SpecConstr: Properly create rules for call patterns representing partial applications The main fix is that in addVoidWorkerArg we now add the argument to the front. This fixes #21448. ------------------------- Metric Decrease: T16875 ------------------------- - - - - - 71278dc7 by Teo Camarasu at 2022-05-05T12:50:03-04:00 add since annotations for instances of ByteArray - - - - - 962ff90b by sheaf at 2022-05-05T12:50:42-04:00 Start 9.6.1-notes Updates the documentation notes to start tracking changes for the 9.6.1 release (instead of 9.4). - - - - - aacb15a3 by Matthew Pickering at 2022-05-05T20:24:01-04:00 ci: Add job to check that jobs.yaml is up-to-date There have been quite a few situations where jobs.yaml has been out of date. It's better to add a CI job which checks that it's right. We don't want to use a staged pipeline because it obfuscates the structure of the pipeline. - - - - - be7102e5 by Ben Gamari at 2022-05-05T20:24:37-04:00 rts: Ensure that XMM registers are preserved on Win64 Previously we only preserved the bottom 64-bits of the callee-saved 128-bit XMM registers, in violation of the Win64 calling convention. Fix this. Fixes #21465. - - - - - 73b22ff1 by Ben Gamari at 2022-05-05T20:24:37-04:00 testsuite: Add test for #21465 - - - - - e2ae9518 by Ziyang Liu at 2022-05-06T19:22:22-04:00 Allow `let` just before pure/return in ApplicativeDo The following is currently rejected: ```haskell -- F is an Applicative but not a Monad x :: F (Int, Int) x = do a <- pure 0 let b = 1 pure (a, b) ``` This has bitten me multiple times. This MR contains a simple fix: only allow a "let only" segment to be merged with the next (and not the previous) segment. As a result, when the last one or more statements before pure/return are `LetStmt`s, there will be one more segment containing only those `LetStmt`s. Note that if the `let` statement mentions a name bound previously, then the program is still rejected, for example ```haskell x = do a <- pure 0 let b = a + 1 pure (a, b) ``` or the example in #18559. To support this would require a more complex approach, but this is IME much less common than the previous case. - - - - - 0415449a by Matthew Pickering at 2022-05-06T19:22:58-04:00 template-haskell: Fix representation of OPAQUE pragmas There is a mis-match between the TH representation of OPAQUE pragmas and GHC's internal representation due to how OPAQUE pragmas disallow phase annotations. It seemed most in keeping to just fix the wired in name issue by adding a special case to the desugaring of INLINE pragmas rather than making TH/GHC agree with how the representation should look. Fixes #21463 - - - - - 4de887e2 by Simon Peyton Jones at 2022-05-06T19:23:34-04:00 Comments only: Note [AppCtxt] - - - - - 6e69964d by Matthew Pickering at 2022-05-06T19:24:10-04:00 Fix name of windows release bindist in doc-tarball job - - - - - ced4689e by Matthew Pickering at 2022-05-06T19:24:46-04:00 ci: Generate source-tarball in release jobs We need to distribute the source tarball so we should generate it in the CI pipeline. - - - - - 3c91de21 by Rob at 2022-05-08T13:40:53+02:00 Change Specialise to use OrdList. Fixes #21362 Metric Decrease: T16875 - - - - - 67072c31 by Simon Jakobi at 2022-05-08T12:23:43-04:00 Tweak GHC.CmmToAsm.CFG.delEdge mapAdjust is more efficient than mapAlter. - - - - - 374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00 Respect -po when heap profiling (#21446) - - - - - 1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00 add test case for #21446 - - - - - c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00 avoid hadrian/bindist/Makefile install_docs error when --docs=none When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated. Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index to avoid the error: /usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory make: *** [Makefile:195: install_docs] Error 1 - - - - - 158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00 Correct base's changelog for 4.16.1.0 This commit reaffects the new Ix instances of the foreign integral types from base 4.17 to 4.16.1.0 closes #21529 - - - - - a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00 STG: only print cost-center if asked to - - - - - 50347ded by Gergo ERDI at 2022-05-10T11:43:33+00:00 Improve "Glomming" note Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order references, and thus needing to glom, is not a cause for concern when its root cause is rewrite rules. - - - - - df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00 update INSTALL - - - - - dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00 driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode It seems like it was just an oversight to use the incorrect DynFlags (global rather than local) when implementing these two options. Using the local flags allows users to request these intermediate files get cleaned up, which works fine in --make mode because 1. Interface files are stored in memory 2. Object files are only cleaned at the end of session (after link) Fixes #21349 - - - - - 35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00 configure: Check for ffi.h As noted in #21485, we checked for ffi.h yet then failed to throw an error if it is missing. Fixes #21485. - - - - - bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00 Check for uninferrable variables in tcInferPatSynDecl This fixes #21479 See Note [Unquantified tyvars in a pattern synonym] While doing this, I found that some error messages pointed at the pattern synonym /name/, rather than the /declaration/ so I widened the SrcSpan to encompass the declaration. - - - - - 142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00 hadrian: Fix split-sections transformer The splitSections transformer has been broken since -dynamic-too support was implemented in hadrian. This is because we actually build the dynamic way when building the dynamic way, so the predicate would always fail. The fix is to just always pass `split-sections` even if it doesn't do anything for a particular way. Fixes #21138 - - - - - 699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. Closes #21135 - - - - - 21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00 Use the wrapper for an unlifted binding We assumed the wrapper for an unlifted binding is the identity, but as #21516 showed, that is no always true. Solution is simple: use it. - - - - - 68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00 docs: Fix path to GHC API docs in index.html In the make bindists we generate documentation in docs/ghc-<VER> but the hadrian bindists generate docs/ghc/ so the path to the GHC API docs was wrong in the index.html file. Rather than make the hadrian and make bindists the same it was easier to assume that if you're using the mkDocs script that you're using hadrian bindists. Fixes #21509 - - - - - 9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00 hadrian: Don't pass -j to haddock This has high potential for oversubcribing as many haddock jobs can be spawned in parralel which will each request the given number of capabilities. Once -jsem is implemented (#19416, !5176) we can expose that haddock via haddock and use that to pass a semaphore. Ticket #21136 - - - - - fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00 hadrian: Only copy and install libffi headers when using in-tree libffi When passed `--use-system-libffi` then we shouldn't copy and install the headers from the system package. Instead the headers are expected to be available as a runtime dependency on the users system. Fixes #21485 #21487 - - - - - 5b791ed3 by mikael at 2022-05-11T08:22:13-04:00 FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10. - - - - - 8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00 Make floating-point abs IEEE 754 compliant The old code used by via-C backend didn't handle the sign bit of NaN. See #21043. - - - - - 4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00 EPA: do statement with leading semicolon has wrong anchor The code do; a <- doAsync; b Generated an incorrect Anchor for the statement list that starts after the first semicolon. This commit fixes it. Closes #20256 - - - - - e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00 Specialiser: saturate DFuns correctly Ticket #21489 showed that the saturation mechanism for DFuns (see Note Specialising DFuns) should use both UnspecType and UnspecArg. We weren't doing that; but this MR fixes that problem. No test case because it's hard to tickle, but it showed up in Gergo's work with GHC-as-a-library. - - - - - fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00 gitlab-ci: Check for dynamic msys2 dependencies Both #20878 and #21196 were caused by unwanted dynamic dependencies being introduced by boot libraries. Ensure that we catch this in CI by attempting to run GHC in an environment with a minimal PATH. - - - - - 3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00 Add back Debian9 CI jobs We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 not being at EOL until April 2023 and they still need tinfo5. Fixes #21469 - - - - - dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00 rts: Drop setExecutable Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been dead code. Drop it. - - - - - 32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00 Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat This missing guard gave rise to #21519. - - - - - 2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00 Add mention of -hi to RTS --help Fixes #21546 - - - - - a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00 Decouple dynflags in Cmm parser (related to #17957) - - - - - 3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00 Remove Module argument from initCmmParserConfig - - - - - 2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00 Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config - - - - - b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00 Decouple dynflags in GHC.Core.Opt.Arity (related to #17957) Metric Decrease: T16875 - - - - - 3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00 Update extending_ghc for TcPlugin changes The documentation still mentioned Derived constraints and an outdated datatype TcPluginResult. - - - - - 668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00 Fix printing of brackets in multiplicities (#20315) Change mulArrow to allow for printing of correct application precedence where necessary and update callers of mulArrow to reflect this. As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type. Fixes #20315 - - - - - 30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00 rts: Add debug output on ocResolve failure This makes it easier to see how resolution failures nest. - - - - - 53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00 rts/PEi386: Fix handling of weak symbols Previously we would flag the symbol as weak but failed to set its address, which must be computed from an "auxiliary" symbol entry the follows the weak symbol. Fixes #21556. - - - - - 5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00 testsuite: Add tests for #21556 - - - - - 49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00 Re-export augment and build from GHC.List Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127 - - - - - aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00 Comments only around HsWrapper - - - - - 27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00 hadrian: Introduce linting flavour transformer (+lint) The linting flavour enables -dlint uniformly across anything build by the stage1 compiler. -dcmm-lint is not currently enabled because it fails on i386 (see #21563) - - - - - 3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00 hadrian: Uniformly enable -dlint with enableLinting transformer This fixes some bugs where * -dcore-lint was being passed when building stage1 libraries with the boot compiler * -dcore-lint was not being passed when building executables. Fixes #20135 - - - - - 3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00 Make closure macros EXTERN_INLINE to make debugging easier Implements #21424. The RTS macros get_itbl and friends are extremely helpful during debugging. However only a select few of those were available in the compiled RTS as actual symbols as the rest were INLINE macros. This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites but allow us to use their compiled counterparts during debugging. This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell since `get_fun_itbl` will now be available as symbol! - - - - - 93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00 packaging: Introduce CI job for generating hackage documentation This adds a CI job (hackage-doc-tarball) which generates the necessary tarballs for uploading libraries and documentation to hackage. The release script knows to download this folder and the upload script will also upload the release to hackage as part of the release. The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs There are two modes, preparation and upload. * The `prepare` mode takes a link to a bindist and creates a folder containing the source and doc tarballs ready to upload to hackage. * The `upload` mode takes the folder created by prepare and performs the upload to hackage. Fixes #21493 Related to #21512 - - - - - 65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00 Add arity to the INLINE pragmas for pattern synonyms The lack of INLNE arity was exposed by #21531. The fix is simple enough, if a bit clumsy. - - - - - 43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00 Misc cleanup - Remove groupWithName (unused) - Use the RuntimeRepType synonym where possible - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM No functional changes. - - - - - 8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00 TcPlugin: access to irreducible givens + fix passed ev_binds_var - - - - - fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00 driver: Introduce pgmcxx Here we introduce proper support for compilation of C++ objects. This includes: * logic in `configure` to detect the C++ toolchain and propagating this information into the `settings` file * logic in the driver to use the C++ toolchain when compiling C++ sources - - - - - 43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Build T20918 with HC, not CXX - - - - - 0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00 Introduce package to capture dependency on C++ stdlib Here we introduce a new "virtual" package into the initial package database, `system-cxx-std-lib`. This gives users a convenient, platform agnostic way to link against C++ libraries, addressing #20010. Fixes #20010. - - - - - 03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Add tests for system-cxx-std-lib package Test that we can successfully link against C++ code both in GHCi and batch compilation. See #20010 - - - - - 5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00 OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420) - - - - - eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00 Adjust flags for pprTrace We were using defaultSDocContext for pprTrace, which suppresses lots of useful infomation. This small MR adds GHC.Utils.Outputable.traceSDocContext and uses it for pprTrace and pprTraceUserWarning. traceSDocContext is a global, and hence not influenced by flags, but that seems unavoidable. But I made the sdocPprDebug bit controlled by unsafeHasPprDebug, since we have the latter for exactly this purpose. Fixes #21569 - - - - - d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00 Fix bad interaction between withDict and the Specialiser This MR fixes a bad bug, where the withDict was inlined too vigorously, which in turn made the type-class Specialiser generate a bogus specialisation, because it saw the same overloaded function applied to two /different/ dictionaries. Solution: inline `withDict` later. See (WD8) of Note [withDict] in GHC.HsToCore.Expr See #21575, which is fixed by this change. - - - - - 70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00 Bump time submodule to 1.12.2 This bumps the time submodule to the 1.12.2 release. Fixes #21571 - - - - - 2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00 Remove unused test files (#21582) Those files were moved to the perf/ subtree in 11c9a469, and then accidentally reintroduced in 680ef2c8. - - - - - cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00 CafAnal: Improve code clarity Here we implement a few measures to improve the clarity of the CAF analysis implementation. Specifically: * Use CafInfo instead of Bool since the former is more descriptive * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact CAFs * Add numerous comments - - - - - b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00 codeGen: Ensure that static datacon apps are included in SRTs When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT filters out recursive references, as described in Note [recursive SRTs]. However, doing so for static functions would be unsound, for the reason described in Note [Invalid optimisation: shortcutting]. However, the same argument applies to static data constructor applications, as we discovered in #20959. Fix this by ensuring that static data constructor applications are included in recursive SRTs. The approach here is not entirely satisfactory, but it is a starting point. Fixes #20959. - - - - - 0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00 Add test for #21558 This is now fixed on master and 9.2 branch. Closes #21558 - - - - - ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00 Don't store LlvmConfig into DynFlags LlvmConfig contains information read from llvm-passes and llvm-targets files in GHC's top directory. Reading these files is done only when needed (i.e. when the LLVM backend is used) and cached for the whole compiler session. This patch changes the way this is done: - Split LlvmConfig into LlvmConfig and LlvmConfigCache - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no good reason to store it in DynFlags. As it is fixed per session, we store it in the session state instead (HscEnv). - Initializing LlvmConfigCache required some changes to driver functions such as newHscEnv. I've used the opportunity to untangle initHscEnv from initGhcMonad (in top-level GHC module) and to move it to GHC.Driver.Main, close to newHscEnv. - I've also made `cmmPipeline` independent of HscEnv in order to remove the call to newHscEnv in regalloc_unit_tests. - - - - - 828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00 Give all EXTERN_INLINE closure macros prototypes - - - - - cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Introduce [sg]etFinalizerExceptionHandler This introduces a global hook which is called when an exception is thrown during finalization. - - - - - 372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Throw exceptions raised while closing finalized Handles Fixes #21336. - - - - - 3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00 testsuite: Add tests for #21336 - - - - - 297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00 Add release flavour and use it for the release jobs The release flavour is essentially the same as the perf flavour currently but also enables `-haddock`. I have hopefully updated all the relevant places where the `-perf` flavour was hardcoded. Fixes #21486 - - - - - a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Don't build sphinx documentation on centos The centos docker image lacks the sphinx builder so we disable building sphinx docs for these jobs. Fixes #21580 - - - - - 209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Use correct syntax when args list is empty This seems to fail on the ancient version of bash present on CentOS - - - - - 02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00 hadrian: Don't attempt to build dynamic profiling libraries We only support building static profiling libraries, the transformer was requesting things like a dynamic, threaded, debug, profiling RTS, which we have never produced nor distributed. Fixes #21567 - - - - - 35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00 configure: Check CC_STAGE0 for --target support We previously only checked the stage 1/2 compiler for --target support. We got away with this for quite a while but it eventually caught up with us in #21579, where `bytestring`'s new NEON implementation was unbuildable on Darwin due to Rosetta's seemingly random logic for determining which executable image to execute. This lead to a confusing failure to build `bytestring`'s cbits, when `clang` tried to compile NEON builtins while targetting x86-64. Fix this by checking CC_STAGE0 for --target support. Fixes #21579. - - - - - 0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator analysis of `CmmGraph` This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper around two existing algorithms in GHC: the Lengauer-Tarjan dominator analysis from the X86 back end and the reverse postorder ordering from the Cmm Dataflow framework. Issue #20726 proposes that we evaluate some alternatives for dominator analysis, but for the time being, the best path forward is simply to use the existing analysis on `CmmGraph`s. This commit addresses a bullet in #21200. - - - - - 54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator-tree function - - - - - 05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add HasDebugCallStack; remove unneeded extensions - - - - - 0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00 document fields of `DominatorSet` - - - - - 8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00 nonmoving: Fix documentation of GC statistics fields These were previously incorrect. Fixes #21553. - - - - - c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00 Remove pprTrace from pushCoercionIntoLambda (#21555) This firstly caused spurious output to be emitted (as evidenced by #21555) but even worse caused a massive coercion to be attempted to be printed (> 200k terms) which would invariably eats up all the memory of your computer. The good news is that removing this trace allows the program to compile to completion, the bad news is that the program exhibits a core lint error (on 9.0.2) but not any other releases it seems. Fixes #21577 and #21555 - - - - - a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00 docs: Fix LlvmVersion in manpage (#21280) - - - - - 36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00 validate: Use $make rather than make In the validate script we are careful to use the $make variable as this stores whether we are using gmake, make, quiet mode etc. There was just this one place where we failed to use it. Fixes #21598 - - - - - 4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00 Change `Backend` type and remove direct dependencies With this change, `Backend` becomes an abstract type (there are no more exposed value constructors). Decisions that were formerly made by asking "is the current back end equal to (or different from) this named value constructor?" are now made by interrogating the back end about its properties, which are functions exported by `GHC.Driver.Backend`. There is a description of how to migrate code using `Backend` in the user guide. Clients using the GHC API can find a backdoor to access the Backend datatype in GHC.Driver.Backend.Internal. Bumps haddock submodule. Fixes #20927 - - - - - ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00 Respect DESTDIR in hadrian bindist Makefile, fixes #19646 - - - - - 7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00 Test DESTDIR in test_hadrian() - - - - - ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00 Consider the stage of typeable evidence when checking stage restriction We were considering all Typeable evidence to be "BuiltinInstance"s which meant the stage restriction was going unchecked. In-fact, typeable has evidence and so we need to apply the stage restriction. This is complicated by the fact we don't generate typeable evidence and the corresponding DFunIds until after typechecking is concluded so we introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which records whether the evidence is going to be local or not. Fixes #21547 - - - - - ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00 Modularize GHC.Core.Opt.LiberateCase Progress towards #17957 - - - - - bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00 Improve FloatOut and SpecConstr This patch addresses a relatively obscure situation that arose when chasing perf regressions in !7847, which itself is fixing It does two things: * SpecConstr can specialise on ($df d1 d2) dictionary arguments * FloatOut no longer checks argument strictness See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr. A test case is difficult to construct, but it makes a big difference in nofib/real/eff/VSM, at least when we have the patch for #21286 installed. (The latter stops worker/wrapper for dictionary arguments). There is a spectacular, but slightly illusory, improvement in runtime perf on T15426. I have documented the specifics in T15426 itself. Metric Decrease: T15426 - - - - - 1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00 Make debug a `Bool` not an `Int` in `StgToCmmConfig` We don't need any more resolution than this. Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer conveying any "level" information. - - - - - e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00 EPA : Remove duplicate comments in DataFamInstD The code data instance Method PGMigration = MigrationQuery Query -- ^ Run a query against the database | MigrationCode (Connection -> IO (Either String ())) -- ^ Run any arbitrary IO code Resulted in two instances of the "-- ^ Run a query against the database" comment appearing in the Exact Print Annotations when it was parsed. Ensure only one is kept. Closes #20239 - - - - - e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00 EPA: Comment Order Reversed Make sure comments captured in the exact print annotations are in order of increasing location Closes #20718 - - - - - 4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Add test for T21455 - - - - - e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Allow passing -po outside profiling way Resolves #21455 - - - - - 3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00 Fix haddock_*_perf tests on non-GNU-grep systems Using regexp pattern requires `egrep` and straight up `+`. The haddock_parser_perf and haddock_renamer_perf tests now pass on OpenBSD. They previously incorrectly parsed the files and awk complained about invalid syntax. - - - - - 1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00 hadrian/bindist: Drop redundant include of install.mk `install.mk` is already included by `config.mk`. Moreover, `install.mk` depends upon `config.mk` to set `RelocatableBuild`, making this first include incorrect. - - - - - f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00 Remove -z wxneeded for OpenBSD With all the recent W^X fixes in the loader this workaround is not necessary any longer. I verified that the only tests failing for me on OpenBSD 7.1-current are the same (libc++ related) before and after this commit (with --fast). - - - - - 7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00 Use UnionListsOrd instead of UnionLists in most places. This should get rid of most, if not all "Overlong lists" errors and fix #20016 - - - - - 81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00 Fix #21563 by using Word64 for 64bit shift code. We use the 64bit shifts only on 64bit platforms. But we compile the code always so compiling it on 32bit caused a lint error. So use Word64 instead. - - - - - 2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00 Fix compilation with -haddock on GHC <= 8.10 -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors when it encounters invalid haddock syntax. This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b enabled -haddock by default on many flavours. Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem managed to slip throught the cracks. - - - - - cfb9faff by sheaf at 2022-05-24T22:15:12-04:00 Hadrian: don't add "lib" for relocatable builds The conditional in hadrian/bindist/Makefile depended on the target OS, but it makes more sense to use whether we are using a relocatable build. (Currently this only gets set to true on Windows, but this ensures that the logic stays correctly coupled.) - - - - - 9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00 Remove HscEnv from GHC.HsToCore.Usage (related to #17957) Metric Decrease: T16875 - - - - - 2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00 SimpleOpt: beta-reduce through casts The simple optimiser would sometimes fail to beta-reduce a lambda when there were casts in between the lambda and its arguments. This can cause problems because we rely on representation-polymorphic lambdas getting beta-reduced away (for example, those that arise from newtype constructors with representation-polymorphic arguments, with UnliftedNewtypes). - - - - - e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00 Desugar RecordUpd in `tcExpr` This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule - - - - - 2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00 update README - - - - - 3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00 Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602) - - - - - ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00 Add Haddocks for `WwOpts` - - - - - da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00 Avoid global compiler state for `GHC.Core.Opt.WorkWrap` Progress towards #17957 - - - - - 3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00 Optimiser: avoid introducing bad rep-poly The functions `pushCoValArg` and `pushCoercionIntoLambda` could introduce bad representation-polymorphism. Example: type RR :: RuntimeRep type family RR where { RR = IntRep } type F :: TYPE RR type family F where { F = Int# } co = GRefl F (TYPE RR[0]) :: (F :: TYPE RR) ~# (F |> TYPE RR[0] :: TYPE IntRep) f :: F -> () `pushCoValArg` would transform the unproblematic application (f |> (co -> <()>)) (arg :: F |> TYPE RR[0]) into an application in which the argument does not have a fixed `RuntimeRep`: f ((arg |> sym co) :: (F :: TYPE RR)) - - - - - b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00 executablePath test: fix file extension treatment The executablePath test strips the file extension (if any) when comparing the query result with the expected value. This is to handle platforms where GHC adds a file extension to the output program file (e.g. .exe on Windows). After the initial check, the file gets deleted (if supported). However, it tries to delete the *stripped* filename, which is incorrect. The test currently passes only because Windows does not allow deleting the program while any process created from it is alive. Make the test program correct in general by deleting the *non-stripped* executable filename. - - - - - afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00 fix executablePath test for NetBSD executablePath support for NetBSD was added in a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not updated. Update the test so that it works for NetBSD. This requires handling some quirks: - The result of getExecutablePath could include "./" segments. Therefore use System.FilePath.equalFilePath to compare paths. - The sysctl(2) call returns the original executable name even after it was deleted. Add `canQueryAfterDelete :: [FilePath]` and adjust expectations for the post-delete query accordingly. Also add a note to the `executablePath` haddock to advise that NetBSD behaves differently from other OSes when the file has been deleted. Also accept a decrease in memory usage for T16875. On Windows, the metric is -2.2% of baseline, just outside the allowed ±2%. I don't see how this commit could have influenced this metric, so I suppose it's something in the CI environment. Metric Decrease: T16875 - - - - - d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00 Factor out `initArityOps` to `GHC.Driver.Config.*` module We want `DynFlags` only mentioned in `GHC.Driver`. - - - - - 44bb7111 by romes at 2022-05-26T16:27:57+00:00 TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs - - - - - 88e58600 by sheaf at 2022-05-26T17:38:43-04:00 Add tests for eta-expansion of data constructors This patch adds several tests relating to the eta-expansion of data constructors, including UnliftedNewtypes and DataTypeContexts. - - - - - d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00 Generalize breakTyVarCycle to work with TyFamLHS The function breakTyVarCycle_maybe has been installed in a dark corner of GHC to catch some gremlins (a.k.a. occurs-check failures) who lurk there. But it previously only caught gremlins of the form (a ~ ... F a ...), where some of our intrepid users have spawned gremlins of the form (G a ~ ... F (G a) ...). This commit improves breakTyVarCycle_maybe (and renames it to breakTyEqCycle_maybe) to catch the new gremlins. Happily, the change is remarkably small. The gory details are in Note [Type equality cycles]. Test cases: typecheck/should_compile/{T21515,T21473}. - - - - - ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00 [base] Fix the links in the Data.Data module fix #21658 fix #21657 fix #21657 - - - - - 3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00 Use a class to check validity of withDict This moves handling of the magic 'withDict' function from the desugarer to the typechecker. Details in Note [withDict]. I've extracted a part of T16646Fail to a separate file T16646Fail2, because the new error in 'reify' hides the errors from 'f' and 'g'. WithDict now works with casts, this fixes #21328. Part of #19915 - - - - - b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00 Fix FreeVars computation for mdo Commit acb188e0 introduced a regression in the computation of free variables in mdo statements, as the logic in GHC.Rename.Expr.segmentRecStmts was slightly different depending on whether the recursive do block corresponded to an mdo statement or a rec statment. This patch restores the previous computation for mdo blocks. Fixes #21654 - - - - - 0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00 T16875: Stabilise (temporarily) by increasing acceptance threshold The theory is that on windows there is some difference in the environment between pipelines on master and merge requests which affects all tests equally but because T16875 barely allocates anything it is the test which is affected the most. See #21557 - - - - - 6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00 make: Fix make maintainer-clean deleting a file tracked by source control Fixes #21659 - - - - - fbf2f254 by Bodigrim at 2022-05-28T21:01:58-04:00 Expand documentation of hIsTerminalDevice - - - - - 0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00 export IsList from GHC.IsList it is still re-exported from GHC.Exts - - - - - 91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00 MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR ARM64_RELOC_SUBTRACTOR relocations are paired with an AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2 The linker was doing it in two steps, basically: *addend <- *addend - sym2 *addend <- *addend + sym1 The first operation was likely to overflow. For example when the relocation target was 32-bit and both sym1/sym2 were 64-bit addresses. With the small memory model, (sym1-sym2) would fit in 32 bits but (*addend-sym2) may not. Now the linker does it in one step: *addend <- *addend + sym1 - sym2 - - - - - acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Some fixes to SRT documentation - reordered the 3 SRT implementation cases from the most general to the most specific one: USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD - added requirements for each - found and documented a confusion about "SRT inlining" not supported with MachO. (It is fixed in the following commit) - - - - - 5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Enable USE_INLINE_SRT_FIELD on ARM64 It was previously disabled because of: - a confusion about "SRT inlining" (see removed comment in this commit) - a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR relocation: fixed by a previous commit. - - - - - 59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00 ci: Make sure to exit promptly if `make install` fails. Due to the vageries of bash, you have to explicitly handle the failure and exit when in a function. This failed to exit promptly when !8247 was failing. See #21358 for the general issue - - - - - 5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00 Split GHC.HsToCore.Foreign.Decl This is preliminary work for JavaScript support. It's better to put the code handling the desugaring of Prim, C and JavaScript declarations into separate modules. - - - - - 6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00 Bump hadrian to LTS-19.8 (GHC 9.0.2) - - - - - f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00 Hadrian: remove unused code - - - - - 2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Eta reduction with casted function We want to be able to eta-reduce \x y. ((f x) |> co) y by pushing 'co' inwards. A very small change accommodates this See Note [Eta reduction with casted function] - - - - - f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Do arity trimming at bindings, rather than in exprArity Sometimes there are very large casts, and coercionRKind can be slow. - - - - - 610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make findRhsArity take RecFlag This avoids a fixpoint iteration for the common case of non-recursive bindings. - - - - - 80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Comments and white space - - - - - 0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make PrimOpId record levity This patch concerns #20155, part (1) The general idea is that since primops have curried bindings (currently in PrimOpWrappers.hs) we don't need to eta-expand them. But we /do/ need to eta-expand the levity-polymorphic ones, because they /don't/ have bindings. This patch makes a start in that direction, by identifying the levity-polymophic primops in the PrimOpId IdDetails constructor. For the moment, I'm still eta-expanding all primops (by saying that hasNoBinding returns True for all primops), because of the bug reported in #20155. But I hope that before long we can tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding. - - - - - 6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: * Move state-hack stuff from GHC.Types.Id (where it never belonged) to GHC.Core.Opt.Arity (which seems much more appropriate). * Add a crucial mkCast in the Cast case of GHC.Core.Opt.Arity.eta_expand; helps with T18223 * Add clarifying notes about eta-reducing to PAPs. See Note [Do not eta reduce PAPs] * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity, where it properly belongs. See Note [Eta reduce PAPs] * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for when eta-expansion is wanted, to make wantEtaExpansion, and all that same function in GHC.Core.Opt.Simplify.simplStableUnfolding. It was previously inconsistent, but it's doing the same thing. * I did a substantial refactor of ArityType; see Note [ArityType]. This allowed me to do away with the somewhat mysterious takeOneShots; more generally it allows arityType to describe the function, leaving its clients to decide how to use that information. I made ArityType abstract, so that clients have to use functions to access it. * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called mkLam before) aware of the floats that the simplifier builds up, so that it can still do eta-reduction even if there are some floats. (Previously that would not happen.) That means passing the floats to rebuildLam, and an extra check when eta-reducting (etaFloatOk). * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info in the idDemandInfo of the binder, as well as the CallArity info. The occurrence analyser did this but we were failing to take advantage here. In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity; see Note [Combining arityType with demand info], and functions idDemandOneShots and combineWithDemandOneShots. (These changes partly drove my refactoring of ArityType.) * In GHC.Core.Opt.Arity.findRhsArity * I'm now taking account of the demand on the binder to give extra one-shot info. E.g. if the fn is always called with two args, we can give better one-shot info on the binders than if we just look at the RHS. * Don't do any fixpointing in the non-recursive case -- simple short cut. * Trim arity inside the loop. See Note [Trim arity inside the loop] * Make SimpleOpt respect the eta-reduction flag (Some associated refactoring here.) * I made the CallCtxt which the Simplifier uses distinguish between recursive and non-recursive right-hand sides. data CallCtxt = ... | RhsCtxt RecFlag | ... It affects only one thing: - We call an RHS context interesting only if it is non-recursive see Note [RHS of lets] in GHC.Core.Unfold * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification. See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep. Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg Metrics: compile_time/bytes allocated Test Metric Baseline New value Change --------------------------------------------------------------------------------------- MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,743,297,692 2,619,762,992 -4.5% GOOD T18223(normal) ghc/alloc 1,103,161,360 972,415,992 -11.9% GOOD T3064(normal) ghc/alloc 201,222,500 184,085,360 -8.5% GOOD T8095(normal) ghc/alloc 3,216,292,528 3,254,416,960 +1.2% T9630(normal) ghc/alloc 1,514,131,032 1,557,719,312 +2.9% BAD parsing001(normal) ghc/alloc 530,409,812 525,077,696 -1.0% geo. mean -0.1% Nofib: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- banner +0.0% +0.4% -8.9% -8.7% 0.0% exact-reals +0.0% -7.4% -36.3% -37.4% 0.0% fannkuch-redux +0.0% -0.1% -1.0% -1.0% 0.0% fft2 -0.1% -0.2% -17.8% -19.2% 0.0% fluid +0.0% -1.3% -2.1% -2.1% 0.0% gg -0.0% +2.2% -0.2% -0.1% 0.0% spectral-norm +0.1% -0.2% 0.0% 0.0% 0.0% tak +0.0% -0.3% -9.8% -9.8% 0.0% x2n1 +0.0% -0.2% -3.2% -3.2% 0.0% -------------------------------------------------------------------------------- Min -3.5% -7.4% -58.7% -59.9% 0.0% Max +0.1% +2.2% +32.9% +32.9% 0.0% Geometric Mean -0.0% -0.1% -14.2% -14.8% -0.0% Metric Decrease: MultiLayerModulesTH_OneShot T18223 T3064 T15185 T14766 Metric Increase: T9630 - - - - - cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00 hadrian: Fix building from source-dist without alex/happy This fixes two bugs which were adding dependencies on alex/happy when building from a source dist. * When we try to pass `--with-alex` and `--with-happy` to cabal when configuring but the builders are not set. This is fixed by making them optional. * When we configure, cabal requires alex/happy because of the build-tool-depends fields. These are now made optional with a cabal flag (build-tool-depends) for compiler/hpc-bin/genprimopcode. Fixes #21627 - - - - - a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test the bootstrap without ALEX/HAPPY on path - - - - - 0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test bootstrapping in release jobs - - - - - d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label - - - - - 18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00 rts: Remove explicit timescale for deprecating -h flag We originally planned to remove the flag in 9.4 but there's actually no great rush to do so and it's probably less confusing (forever) to keep the message around suggesting an explicit profiling option. Fixes #21545 - - - - - eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00 Enable -dlint in hadrian lint transformer Now #21563 is fixed we can properly enable `-dlint` in CI rather than a subset of the flags. - - - - - 0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00 upload-ghc-libs: Allow candidate-only upload - - - - - 83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00 Avoid using DynFlags in GHC.Linker.Unit (#17957) - - - - - 5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00 hadrian: Introduce new package database for executables needed to build stage0 These executables (such as hsc2hs) are built using the boot compiler and crucially, most libraries from the global package database. We also move other build-time executables to be built in this stage such as linters which also cleans up which libraries end up in the global package database. This allows us to remove hacks where linters-common is removed from the package database when a bindist is created. This fixes issues caused by infinite recursion due to bytestring adding a dependency on template-haskell. Fixes #21634 - - - - - 0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00 Build stage1 with -V as well This helps tracing errors which happen when building stage1 - - - - - 15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00 Revert "packaging: Build perf builds with -split-sections" This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f. Split sections causes segfaults in profiling way with old toolchains (deb9) and on windows (#21670) Fixes #21670 - - - - - d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00 Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard Progress towards #17957 Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other modules as thoroughly as I usually do. This does mean that risk of `DynFlags` "creeping back in" is higher than it usually is. After we do the same process to the other Core passes, and then figure out what we want to do about `CoreM`, we can finish the job started here. That is a good deal more work, however, so it certainly makes sense to land this now. - - - - - a720322f by romes at 2022-06-01T07:44:44-04:00 Restore Note [Quasi-quote overview] - - - - - 392ce3fc by romes at 2022-06-01T07:44:44-04:00 Move UntypedSpliceFlavour from L.H.S to GHC.Hs UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr` but was defined in the client-independent L.H.S.Expr. - - - - - 7975202b by romes at 2022-06-01T07:44:44-04:00 TTG: Rework and improve splices This commit redefines the structure of Splices in the AST. We get rid of `HsSplice` which used to represent typed and untyped splices, quasi quotes, and the result of splicing either an expression, a type or a pattern. Instead we have `HsUntypedSplice` which models an untyped splice or a quasi quoter, which works in practice just like untyped splices. The `HsExpr` constructor `HsSpliceE` which used to be constructed with an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The former is directly constructed with an `HsExpr` and the latter now takes an `HsUntypedSplice`. Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now take an `HsUntypedSplice` instead of a `HsSplice` (remember only /untyped splices/ can be spliced as types or patterns). The result of splicing an expression, type, or pattern is now comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`, `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult (HsExpr GhcRn)` Overall the TTG extension points are now better used to make invalid states unrepresentable and model the progression between stages better. See Note [Lifecycle of an untyped splice, and PendingRnSplice] and Note [Lifecycle of an typed splice, and PendingTcSplice] for more details. Updates haddock submodule Fixes #21263 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - 320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00 Add test for #21619 Fixes #21619 - - - - - ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00 Pure Haskell implementation of GHC.Unicode Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/). Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691. - Remove current Unicode cbits. - Add generator for Unicode property files from Unicode Character Database. - Generate internal modules. - Update GHC.Unicode. - Add unicode003 test for general categories and case mappings. - Add Python scripts to check 'base' Unicode tests outputs and characters properties. Fixes #21375 ------------------------- Metric Decrease: T16875 Metric Increase: T4029 T18304 haddock.base ------------------------- - - - - - 514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00 typos - - - - - 9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00 source-dist: Copy in files created by ./boot Since we started producing source dists with hadrian we stopped copying in the files created by ./boot which adds a dependency on python3 and autoreconf. This adds back in the files which were created by running configure. Fixes #21673 #21672 and #21626 - - - - - a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00 ci: Don't try to run ./boot when testing bootstrap of source dist - - - - - e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00 Language.Haskell.Syntax: Fix docs for PromotedConsT etc. Fixes ghc/ghc#21675. - - - - - 87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump bytestring, process, and text submodules Metric Decrease: T5631 Metric Increase: T18223 (cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af) - - - - - 24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump Cabal submodule To current `master`. (cherry picked from commit fbb59c212415188486aafd970eafef170516356a) - - - - - 5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00 hadrian/tool-args: Write output to intermediate file rather than via stdout This allows us to see the output of hadrian while it is doing the setup. - - - - - 468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00 Make -fcompact-unwind the default This is a follow-up to !7247 (closed) making the inclusion of compact unwinding sections the default. Also a slight refactoring/simplification of the flag handling to add -fno-compact-unwind. - - - - - 819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00 hadrian bootstrap: add plans for 9.0.2 and 9.2.3 - - - - - 9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00 ci: Add matrix for bootstrap sources - - - - - ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00 HsToCore.Coverage: Improve haddocks - - - - - f065804e by John Ericson at 2022-06-02T15:42:59+00:00 Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller No need to inline traversing a maybe for `mkModBreaks`. And better to make each function do one thing and let the caller deside when than scatter the decision making and make the caller seem more imperative. - - - - - d550d907 by John Ericson at 2022-06-02T15:42:59+00:00 Rename `HsToCore.{Coverage -> Ticks}` The old name made it confusing why disabling HPC didn't disable the entire pass. The name makes it clear --- there are other reasons to add ticks in addition. - - - - - 6520da95 by John Ericson at 2022-06-02T15:42:59+00:00 Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq` As proposed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676, `GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and backend-specific (only for the bytecode interpreter), and mix entry writing is just for HPC. With this split we separate out those interpreter- and HPC-specific its, and keep the main `GHC.HsToCore.Ticks` agnostic. Also, instead of passing the reversed list and count around, we use `SizedSeq` which abstracts over the algorithm. This is much nicer to avoid noise and prevents bugs. (The bugs are not just hypothetical! I missed up the reverses on an earlier draft of this commit.) - - - - - 1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00 GHC.HsToCore.Breakpoints: Slightly improve perf We have the length already, so we might as well use that rather than O(n) recomputing it. - - - - - 5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00 HsToCore.Coverage: Purge DynFlags Finishes what !7467 (closed) started. Progress towards #17957 - - - - - 9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00 Deprecate TypeInType extension This commit fixes #20312 It deprecates "TypeInType" extension according to the following proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst It has been already implemented. The migration strategy: 1. Disable TypeInType 2. Enable both DataKinds and PolyKinds extensions Metric Decrease: T16875 - - - - - f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00 Diagnostics conversions, part 6 (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and `GHC.Tc.Gen.Sig`. - - - - - 04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00 Ensure floated dictionaries are in scope (again) In the Specialiser, we missed one more call to bringFloatedDictsIntoScope (see #21391). This omission led to #21689. The problem is that the call to `rewriteClassOps` needs to have in scope any dictionaries floated out of the arguments we have just specialised. Easy fix. - - - - - a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00 Don't print the number of deps in count-deps tests It is redundant information and a source of needless version control conflicts when multiple MRs are changing the deps list. Just printing the list and not also its length is fine. - - - - - a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00 Core.Lint: Reduce `DynFlags` and `HscEnv` Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com> - - - - - 56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00 Fix a CSE shadowing bug. We used to process the rhs of non-recursive bindings and their body using the same env. If we had something like let x = ... x ... this caused trouble because the two xs refer to different binders but we would substitute both for a new binder x2 causing out of scope errors. We now simply use two different envs for the rhs and body in cse_bind. It's all explained in the Note [Separate envs for let rhs and body] Fixes #21685 - - - - - 28880828 by sheaf at 2022-06-09T09:12:19-04:00 Typecheck remaining ValArgs in rebuildHsApps This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it to tcRemainingValArgs. The logic is moved to rebuildHsApps, which ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg. This patch also refactors the treatment of stupid theta for data constructors, changing the place we drop stupid theta arguments from dsConLike to mkDataConRep (now the datacon wrapper drops these arguments). We decided not to implement PHASE 2 of the FixedRuntimeRep plan for these remaining ValArgs. Future directions are outlined on the wiki: https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs Fixes #21544 and #21650 - - - - - 1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00 Add test for T21682 Fixes #21682 - - - - - 8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00 Document dataToTag# primop - - - - - 7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00 Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115 - - - - - 46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00 Fix TcRnPragmaWarning meaning - - - - - 69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00 getProcessCPUTime: Fix the getrusage fallback to account for system CPU time clock_gettime reports the combined total or user AND system time so in order to replicate it with getrusage we need to add both system and user time together. See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime Some sample measurements when building Cabal with this patch t1: rusage t2: clock_gettime t1: 62347518000; t2: 62347520873 t1: 62395687000; t2: 62395690171 t1: 62432435000; t2: 62432437313 t1: 62478489000; t2: 62478492465 t1: 62514990000; t2: 62514992534 t1: 62515479000; t2: 62515480327 t1: 62515485000; t2: 62515486344 Fixes #21656 - - - - - 722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00 Use <br> instead of newline character - - - - - dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00 Use (fixed_lev = True) in mkDataTyConRhs - - - - - ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00 hadrian: Fix testing stage1 compiler There were various issues with testing the stage1 compiler.. 1. The wrapper was not being built 2. The wrapper was picking up the stage0 package database and trying to load prelude from that. 3. The wrappers never worked on windows so just don't support that for now. Fixes #21072 - - - - - ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00 validate: Ensure that $make variable is set Currently the `$make` variable is used without being set in `validate`'s Hadrian path, which uses make to install the binary distribution. Fix this. Fixes #21687. - - - - - 59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00 CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv` The call sites in `Driver.Main` are duplicative, but this is good, because the next step is to remove `InteractiveContext` from `Core.Lint` into `Core.Lint.Interactive`. Also further clean up `Core.Lint` to use a better configuration record than the one we initially added. - - - - - aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00 hadrian: Run xattr -rc . on bindist tarball Fixes #21506. - - - - - cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00 configure: Hide spurious warning from ld Previously the check_for_gold_t22266 configure check could result in spurious warnings coming from the linker being blurted to stderr. Suppress these by piping stderr to /dev/null. - - - - - e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00 cmm: Add surface syntax for MO_MulMayOflo - - - - - bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00 configure: Don't attempt to override linker on Darwin Configure's --enable-ld-override functionality is intended to ensure that we don't rely on ld.bfd, which tends to be slow and buggy, on Linux and Windows. However, on Darwin the lack of sensible package management makes it extremely easy for users to have awkward mixtures of toolchain components from, e.g., XCode, the Apple Command-Line Tools package, and homebrew. This leads to extremely confusing problems like #21712. Here we avoid this by simply giving up on linker selection on Darwin altogether. This isn't so bad since the Apple ld64 linker has decent performance and AFAICT fairly reliable. Closes #21712. - - - - - 25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00 replace quadratic nub to fight byte code gen perf explosion Despite this code having been present in the core-to-bytecode implementation, I have observed it in the wild starting with 9.2, causing enormous slowdown in certain situations. My test case produces the following profiles: Before: ``` total time = 559.77 secs (559766 ticks @ 1000 us, 1 processor) total alloc = 513,985,665,640 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes elem_by Data.OldList libraries/base/Data/OldList.hs:429:1-7 67.6 92.9 378282 477447404296 eqInt GHC.Classes libraries/ghc-prim/GHC/Classes.hs:275:8-14 12.4 0.0 69333 32 $c>>= GHC.Data.IOEnv <no location info> 6.9 0.6 38475 3020371232 ``` After: ``` total time = 89.83 secs (89833 ticks @ 1000 us, 1 processor) total alloc = 39,365,306,360 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes $c>>= GHC.Data.IOEnv <no location info> 43.6 7.7 39156 3020403424 doCase GHC.StgToByteCode compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53) 2.5 7.4 2246 2920777088 ``` - - - - - aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00 hadrian: Don't install `include/` directory in bindist. The install_includes for the RTS package used to be put in the top-level ./include folder but this would lead to confusing things happening if you installed multiple GHC versions side-by-side. We don't need this folder anymore because install-includes is honoured properly by cabal and the relevant header files already copied in by the cabal installation process. If you want to depend on the header files for the RTS in a Haskell project then you just have to depend on the `rts` package and the correct include directories will be provided for you. If you want to depend on the header files in a standard C project then you should query ghc-pkg to get the right paths. ``` ghc-pkg field rts include-dirs --simple-output ``` Fixes #21609 - - - - - 03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00 Enable eventlogs on nightly perf job - - - - - ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00 Repair dead link in TH haddocks Closes #21724 - - - - - 99ff3818 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian: allow configuring Hsc2Hs This patch adds the ability to pass options to Hsc2Hs as Hadrian key/value settings, in the same way as cabal configure options, using the syntax: *.*.hsc2hs.run.opts += ... - - - - - 9c575f24 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian bootstrap: look up hsc2hs Hadrian bootstrapping looks up where to find ghc_pkg, but the same logic was not in place for hsc2hs which meant we could fail to find the appropriate hsc2hs executabe when bootstrapping Hadrian. This patch adds that missing logic. - - - - - 229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Add (broken) test for #21622 - - - - - cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Don't Box NULL pointers Previously we could construct a `Box` of a NULL pointer from the `link` field of `StgWeak`. Now we take care to avoid ever introducing such pointers in `collect_pointers` and ensure that the `link` field is represented as a `Maybe` in the `Closure` type. Fixes #21622 - - - - - 31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00 winio: Add support to console handles to handleToHANDLE - - - - - 711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Add SMUL[LH] instructions These will be needed to fix #21624. - - - - - d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Fix syntax of OpRegShift operands Previously this produced invalid assembly containing a redundant comma. - - - - - a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00 ncg/aarch64: Fix implementation of IntMulMayOflo The code generated for IntMulMayOflo was previously wrong as it depended upon the overflow flag, which the AArch64 MUL instruction does not set. Fix this. Fixes #21624. - - - - - 26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00 testsuite: Add test for #21624 Ensuring that mulIntMayOflo# behaves as expected. - - - - - 94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00 CprAnal: Set signatures of DFuns to top The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal that is observable in a debug build. The CPR signature of a recursive DFunId was never updated and hence the optimistic arity 0 bottom signature triggered a mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any code because WW doesn't exploit bottom CPR signatures. - - - - - b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00 CorePrep: Don't speculatively evaluate recursive calls (#20836) In #20836 we have optimised a terminating program into an endless loop, because we speculated the self-recursive call of a recursive DFun. Now we track the set of enclosing recursive binders in CorePrep to prevent speculation of such self-recursive calls. See the updates to Note [Speculative evaluation] for details. Fixes #20836. - - - - - 49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00 Simplify: Take care with eta reduction in recursive RHSs (#21652) Similar to the fix to #20836 in CorePrep, we now track the set of enclosing recursive binders in the SimplEnv and SimpleOptEnv. See Note [Eta reduction in recursive RHSs] for details. I also updated Note [Arity robustness] with the insights Simon and I had in a call discussing the issue. Fixes #21652. Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation of a large list literal at the top-level that didn't happen before (presumably because it was too interesting to float to the top-level). There's not much we can do about that. Metric Increase: T16577 - - - - - 2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00 Ignore .hie-bios - - - - - e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00 Instantiate top level foralls in partial type signatures The main fix for #21667 is the new call to tcInstTypeBnders in tcHsPartialSigType. It was really a simple omission before. I also moved the decision about whether we need to apply the Monomorphism Restriction, from `decideGeneralisationPlan` to `tcPolyInfer`. That removes a flag from the InferGen constructor, which is good. But more importantly, it allows the new function, checkMonomorphismRestriction called from `tcPolyInfer`, to "see" the `Types` involved rather than the `HsTypes`. And that in turn matters because we invoke the MR for partial signatures if none of the partial signatures in the group have any overloading context; and we can't answer that question for HsTypes. See Note [Partial type signatures and the monomorphism restriction] in GHC.Tc.Gen.Bind. This latter is really a pre-existing bug. - - - - - 262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00 Make Outputable instance for InlineSig print the InlineSpec Fix ghc/ghc#21739 Squash fix ghc/ghc#21739 - - - - - b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00 Add NO_BOOT to hackage_doc_tarball job We were attempting to boot a src-tarball which doesn't work as ./boot is not included in the source tarball. This slipped through as the job is only run on nightly. - - - - - d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00 HsToken for @-patterns and TypeApplications (#19623) One more step towards the new design of EPA. - - - - - 159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00 linker: only keep rtl exception tables if they have been relocated - - - - - da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00 Ticky:Make json info a separate field. - - - - - 1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00 Revert "Ticky:Make json info a separate field." This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862. This was pushed directly without review. - - - - - f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00 Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags These flags affect the behaviour of local let floating. If `-flocal-float-out` is disabled (the default) then we disable all local floating. ``` …(let x = let y = e in (a,b) in body)... ===> …(let y = e; x = (a,b) in body)... ``` Further to this, top-level local floating can be disabled on it's own by passing -fno-local-float-out-top-level. ``` x = let y = e in (a,b) ===> y = e; x = (a,b) ``` Note that this is only about local floating, ie, floating two adjacent lets past each other and doesn't say anything about the global floating pass which is controlled by `-fno-float`. Fixes #13663 - - - - - 4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00 Check for Int overflows in Data.Array.Byte - - - - - 2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00 Add a basic test for ByteArray's Monoid instance - - - - - fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00 Rename `copyByteArray` to `unsafeCopyByteArray` - - - - - ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00 testsuite: Add test for #21719 Happily, this has been fixed since 9.2. - - - - - 19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Use lookupNameCache instead of lookupOrigIO - - - - - 4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Break out thNameToGhcNameIO (ref. #21730) - - - - - eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00 Add laws for 'toInteger' and 'toRational' CLC discussion here: https://github.com/haskell/core-libraries-committee/issues/58 - - - - - c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00 Correct documentation of defaults of the `-V` RTS option - - - - - b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00 Transcribe discussion from #21483 into a Note In #21483 I had a discussion with Simon Marlow about the memory retention behaviour of -Fd. I have just transcribed that conversation here as it elucidates the potentially subtle assumptions which led to the design of the memory retention behaviours of -Fd. Fixes #21483 - - - - - 980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00 eventlog: Don't leave dangling pointers hanging around Previously we failed to reset pointers to various eventlog buffers to NULL after freeing them. In principle we shouldn't look at them after they are freed but nevertheless it is good practice to set them to a well-defined value. - - - - - 575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00 runhaskell - - - - - e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00 re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45 - - - - - 5d45aa97 by Gergo ERDI at 2022-06-22T22:00:46-04:00 When specialising, look through floatable ticks. Fixes #21697. - - - - - 531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00 TagCheck.hs: Properly check if arguments are boxed types. For one by mistake I had been checking against the kind of runtime rep instead of the boxity. This uncovered another bug, namely that we tried to generate the checking code before we had associated the function arguments with a register, so this could never have worked to begin with. This fixes #21729 and both of the above issues. - - - - - c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00 Use correct arch for the FreeBSD triple in gen-data-layout.sh Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798 Relevant upstream issue: #15718 - - - - - 75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00 Bump nofib submodule. Allows the shake runner to build with 9.2.3 among other things. Fixes #21772 - - - - - 0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00 Bump ghc-prim and base versions To 0.9.0 and 4.17.0 respectively. Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm, terminfo, text, unix, haddock, and hsc2hs submodules. (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095) - - - - - 4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00 testsuite: Use normalise_version more consistently Previously several tests' output were unnecessarily dependent on version numbers, particularly of `base`. Fix this. - - - - - d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00 linters: Fix lint-submodule-refs when crashing trying to find plausible branches - - - - - 38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 hadrian: Improve haddocks for ghcDebugAssertions - - - - - ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 Don't mark lambda binders as OtherCon We used to put OtherCon unfoldings on lambda binders of workers and sometimes also join points/specializations with with the assumption that since the wrapper would force these arguments once we execute the RHS they would indeed be in WHNF. This was wrong for reasons detailed in #21472. So now we purge evaluated unfoldings from *all* lambda binders. This fixes #21472, but at the cost of sometimes not using as efficient a calling convention. It can also change inlining behaviour as some occurances will no longer look like value arguments when they did before. As consequence we also change how we compute CBV information for arguments slightly. We now *always* determine the CBV convention for arguments during tidy. Earlier in the pipeline we merely mark functions as candidates for having their arguments treated as CBV. As before the process is described in the relevant notes: Note [CBV Function Ids] Note [Attaching CBV Marks to ids] Note [Never put `OtherCon` unfoldigns on lambda binders] ------------------------- Metric Decrease: T12425 T13035 T18223 T18223 T18923 MultiLayerModulesTH_OneShot Metric Increase: WWRec ------------------------- - - - - - 06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00 Add suggestions for unrecognised pragmas (#21589) In case of a misspelled pragma, offer possible corrections as to what the user could have meant. Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589 - - - - - 3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00 Remove the traces of i386-*-openbsd, long live amd64 OpenBSD will not ship any ghc packages on i386 starting with 7.2 release. This means there will not be a bootstrap compiler easily available. The last available binaries are ghc-8.10.6 which is already not supported as bootstrap for HEAD. See here for more information: https://marc.info/?l=openbsd-ports&m=165060700222580&w=2 - - - - - 58530271 by Bodigrim at 2022-06-27T08:03:34-04:00 Add Foldable1 and Bifoldable1 type classes Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9 Instances roughly follow https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1 but the API of `Foldable1` was expanded in comparison to `semigroupoids`. Compatibility shim is available from https://github.com/phadej/foldable1 (to be released). Closes #13573. - - - - - a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00 add levity polymorphism to addrToAny# - - - - - f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00 add tests for addrToAny# levity - - - - - 07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00 hadrian: Update main README page This README had some quite out-of-date content about the build system so I did a complete pass deleting old material. I also made the section about flavours more prominent and mentioned flavour transformers. - - - - - 79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00 testsuite: Hide output from test compilations with verbosity==2 Previously the output from test compilations used to determine whether, e.g., profiling libraries are available was shown with verbosity levels >= 2. However, the default level is 2, meaning that most users were often spammed with confusing errors. Fix this by bumping the verbosity threshold for this output to >=3. Fixes #21760. - - - - - 995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00 configure: Only probe for LD in FIND_LD Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD rather early in `configure`. However, it turns out that this breaks `configure`'s `ld`-override logic, which assumes that `LD` was set by the user and aborts. Fixes #21778. - - - - - b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00 `.hs-boot` make rules: add missing order-only dependency on target directory Noticed missing target directory dependency as a build failure in `make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100): "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254 make: *** [Makefile:128: all] Error 2 shuffle=1656129254 Note that `cp` complains about inability to create target file. The change adds order-only dependency on a target directory (similar to the rest of rules in that file). The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build system megapatch`.) where upfront directory creation was never added to `.hs-boot` files. - - - - - 57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00 Mark AArch64/Darwin as requiring sign-extension Apple's AArch64 ABI requires that the caller sign-extend small integer arguments. Set platformCConvNeedsExtension to reflect this fact. Fixes #21773. - - - - - df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00 -ddump-llvm shouldn't imply -fllvm Previously -ddump-llvm would change the backend used, which contrasts with all other dump flags. This is quite surprising and cost me quite a bit of time. Dump flags should not change compiler behavior. Fixes #21776. - - - - - 70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Re-format argument handling logic Previously there were very long, hard to parse lines. Fix this. - - - - - 696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Sign-extend narrow C arguments The AArch64/Darwin ABI requires that function arguments narrower than 32-bits must be sign-extended by the caller. We neglected to do this, resulting in #20735. Fixes #20735. - - - - - c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00 testsuite: Add test for #20735 - - - - - 16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00 integer-gmp: Fix cabal file Evidently fields may not come after sections in a cabal file. - - - - - 03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00 ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist) before the change `make install` was failing as: ``` "mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc" make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'. Stop. ``` I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf` is created (somewhat manually), but not the .install varianlt of it. The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere. Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784 - - - - - eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00 Comments only, about join points This MR just adds some documentation about why casts destroy join points, following #21716. - - - - - 251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00 Cleanup BuiltInSyntax vs UserSyntax There was some confusion about whether FUN/TYPE/One/Many should be BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as BuiltInSyntax is for things which are directly constructed by the parser rather than going through normal renaming channels. I fixed all the obviously wrong places I could find and added a test for the original bug which was caused by this (#21752) Fixes #21752 #20695 #18302 - - - - - 0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00 template-haskell: Bump version to 2.19.0.0 Bumps text and exceptions submodules due to bounds. - - - - - bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00 Tiny tweak to `IOPort#` documentation The exclamation mark and bracket don’t seem to make sense here. I’ve looked through the history, and I don’t think they’re deliberate – possibly a copy-and-paste error. - - - - - 70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00 Remove `CoreOccurAnal` constructor of the `CoreToDo` type It was dead code since the last occurence in an expression context got removed in 71916e1c018dded2e68d6769a2dbb8777da12664. - - - - - d0722170 by nineonine at 2022-07-01T08:15:56-04:00 Fix panic with UnliftedFFITypes+CApiFFI (#14624) When declaring foreign import using CAPI calling convention, using unlifted unboxed types would result in compiler panic. There was an attempt to fix the situation in #9274, however it only addressed some of the ByteArray cases. This patch fixes other missed cases for all prims that may be used as basic foreign types. - - - - - eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00 rts: gc stats: account properly for copied bytes in sequential collections We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow] counters during sequential collections. As well, we were double counting for parallel collections. To fix this we add an `else` clause to the `if (is_par_gc())`. The par_* counters do not need to be updated in the sequential case because they must be 0. - - - - - f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00 desugar: Look through ticks when warning about possible literal overflow Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up between the appliation of `neg` to its argument. This defeated the special logic which looks for `NegApp ... (HsOverLit` to warn about possible overflow if a user writes a negative literal (without out NegativeLiterals) in their code. Fixes #21701 - - - - - f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00 ci: Fix definition of slow-validate flavour (so that -dlint) is passed In this embarassing sequence of events we were running slow-validate without -dlint. - - - - - bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00 Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411 - - - - - 9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00 Data.Foldable1: Remove references to Foldable-specific note ...as discussed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455. - - - - - 3a8970ac by romes at 2022-07-03T14:11:31-04:00 TTG: Move HsModule to L.H.S Move the definition of HsModule defined in GHC.Hs to Language.Haskell.Syntax with an added TTG parameter and corresponding extension fields. This is progress towards having the haskell-syntax package, as described in #21592 - - - - - f9f80995 by romes at 2022-07-03T14:11:31-04:00 TTG: Move ImpExp client-independent bits to L.H.S.ImpExp Move the GHC-independent definitions from GHC.Hs.ImpExp to Language.Haskell.Syntax.ImpExp with the required TTG extension fields such as to keep the AST independent from GHC. This is progress towards having the haskell-syntax package, as described in #21592 Bumps haddock submodule - - - - - c43dbac0 by romes at 2022-07-03T14:11:31-04:00 Refactor ModuleName to L.H.S.Module.Name ModuleName used to live in GHC.Unit.Module.Name. In this commit, the definition of ModuleName and its associated functions are moved to Language.Haskell.Syntax.Module.Name according to the current plan towards making the AST GHC-independent. The instances for ModuleName for Outputable, Uniquable and Binary were moved to the module in which the class is defined because these instances depend on GHC. The instance of Eq for ModuleName is slightly changed to no longer depend on unique explicitly and instead uses FastString's instance of Eq. - - - - - 2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00 Expand `Ord` instance for `Down` Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610 - - - - - 36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00 Add applyWhen to Data.Function per CLC prop Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233 - - - - - 3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00 hadrian: Don't read package environments in ghc-stage1 wrapper The stage1 compiler may be on the brink of existence and not have even a working base library. You may have installed packages globally with a similar stage2 compiler which will then lead to arguments such as --show-iface not even working because you are passing too many package flags. The solution is simple, don't read these implicit files. Fixes #21803 - - - - - aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00 Ticky:Make json info a separate field. Fixes #21233 - - - - - 74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00 Add docs:<pkg> command to hadrian to build docs for just one package - - - - - 418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00 upload-docs: propagate publish correctly in upload_sdist - - - - - ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00 docs-upload: Fix upload script when no packages are listed - - - - - d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00 hadrian: Add --haddock-base-url option for specifying base-url when generating docs The motiviation for this flag is to be able to produce documentation which is suitable for uploading for hackage, ie, the cross-package links work correctly. There are basically three values you want to set this to: * off - default, base_url = ../%pkg% which works for local browsing * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation. The `%pkg%` string is a template variable which is replaced with the package identifier for the relevant package. This is one step towards fixing #21749 - - - - - 41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00 Add nightly job for generating docs suitable for hackage upload - - - - - 620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00 ghci: Support :set prompt in multi repl This adds supports for various :set commands apart from `:set <FLAG>` in multi repl, this includes `:set prompt` and so-on. Fixes #21796 - - - - - b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00 Vendor filepath inside template-haskell Adding filepath as a dependency of template-haskell means that it can't be reinstalled if any build-plan depends on template-haskell. This is a temporary solution for the 9.4 release. A longer term solution is to split-up the template-haskell package into the wired-in part and a non-wired-in part which can be reinstalled. This was deemed quite risky on the 9.4 release timescale. Fixes #21738 - - - - - c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00 Factor fields of `CoreDoSimplify` into separate data type This avoids some partiality. The work @mmhat is doing cleaning up and modularizing `Core.Opt` will build on this nicely. - - - - - d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00 https urls - - - - - 803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00 options and typos - - - - - 5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00 grammar - - - - - 4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00 sources - - - - - c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00 Fix lint warnings in bootstrap.py - - - - - 86ced2ad by romes at 2022-07-06T01:36:23-04:00 Restore Eq instance of ImportDeclQualifiedStyle Fixes #21819 - - - - - 3547e264 by romes at 2022-07-06T13:50:27-04:00 Prune L.H.S modules of GHC dependencies Move around datatypes, functions and instances that are GHC-specific out of the `Language.Haskell.Syntax.*` modules to reduce the GHC dependencies in them -- progressing towards #21592 Creates a module `Language.Haskell.Syntax.Basic` to hold basic definitions required by the other L.H.S modules (and don't belong in any of them) - - - - - e4eea07b by romes at 2022-07-06T13:50:27-04:00 TTG: Move CoreTickish out of LHS.Binds Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and move them to the extension point instance, according to the plan outlined in #21592 to separate the base AST from the GHC specific bits. - - - - - acc1816b by romes at 2022-07-06T13:50:27-04:00 TTG for ForeignImport/Export Add a TTG parameter to both `ForeignImport` and `ForeignExport` and, according to #21592, move the GHC-specific bits in them and in the other AST data types related to foreign imports and exports to the TTG extension point. - - - - - 371c5ecf by romes at 2022-07-06T13:50:27-04:00 TTG for HsTyLit Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText` fields to the extension point and out of the base AST. Progress towards #21592 - - - - - fd379d1b by romes at 2022-07-06T13:50:27-04:00 Remove many GHC dependencies from L.H.S Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC imports according to the plan in the linked issue. Moves more GHC-specific declarations to `GHC.*` and brings more required GHC-independent declarations to `Language.Haskell.Syntax.*` (extending e.g. `Language.Haskell.Syntax.Basic`). Progress towards #21592 Bump haddock submodule for !8308 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00 Fix exact printing of the HsRule name Prior to this branch, the HsRule name was XRec pass (SourceText,RuleName) and there is an ExactPrint instance for (SourceText, RuleName). The SourceText has moved to a different location, so synthesise the original to trigger the correct instance when printing. We need both the SourceText and RuleName when exact printing, as it is possible to have a NoSourceText variant, in which case we fall back to the FastString. - - - - - 665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00 driver: Fix issue with module loops and multiple home units We were attempting to rehydrate all dependencies of a particular module, but we actually only needed to rehydrate those of the current package (as those are the ones participating in the loop). This fixes loading GHC into a multi-unit session. Fixes #21814 - - - - - bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00 Remove a bogus #define from ClosureMacros.h - - - - - fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00 winio: make consoleReadNonBlocking not wait for any events at all. - - - - - 42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00 rts: allow NULL to be used as an invalid StgStablePtr - - - - - 3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00 RTS: Add stack marker to StgCRunAsm.S Every object file must be properly marked for non-executable stack, even if it contains no code. - - - - - a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00 Bump unix submodule Adds `config.sub` to unix's `.gitignore`, fixing #19574. - - - - - 3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00 ghci: Fix most calls to isLoaded to work in multi-mode The most egrarious thing this fixes is the report about the total number of loaded modules after starting a session. Ticket #20889 - - - - - fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00 Enable :edit command in ghci multi-mode. This works after the last change to isLoaded. Ticket #20888 - - - - - 46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00 Fix a scoping bug in the Specialiser In the call to `specLookupRule` in `already_covered`, in `specCalls`, we need an in-scope set that includes the free vars of the arguments. But we simply were not guaranteeing that: did not include the `rule_bndrs`. Easily fixed. I'm not sure how how this bug has lain for quite so long without biting us. Fixes #21828. - - - - - 6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Edit Note [idArity varies independently of dmdTypeDepth] ...and refer to it in GHC.Core.Lint.lintLetBind. Fixes #21452 - - - - - 89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Tiny documentation wibbles (comments only) - - - - - 61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix readme - - - - - 61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix bootstrap - - - - - 8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00 tarball - - - - - e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Fix scopes for deriving clauses and instance signatures (#18425) - - - - - c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Record location of filled in default method bindings This is useful for hie files to reconstruct the evidence that default methods depend on. - - - - - 9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00 testsuite: Factor out common parts from hiefile tests - - - - - 6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00 Hadrian: update documentation of settings The documentation for key-value settings was a bit out of date. This patch updates it to account for `cabal.configure.opts` and `hsc2hs.run.opts`. The user-settings document was also re-arranged, to make the key-value settings more prominent (as it doesn't involve changing the Hadrian source code, and thus doesn't require any recompilation of Hadrian). - - - - - a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00 Fix potential space leak that arise from ModuleGraphs retaining references to previous ModuleGraphs, in particular the lazy `mg_non_boot` field. This manifests in `extendMG`. Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which is only called in two places in the compiler, and should only be called at most once for every home unit: GHC.Driver.Make: mainModuleSrcPath :: Maybe String mainModuleSrcPath = do ms <- mgLookupModule mod_graph (mainModIs hue) ml_hs_file (ms_location ms) GHCI.UI: listModuleLine modl line = do graph <- GHC.getModuleGraph let this = GHC.mgLookupModule graph modl Instead `mgLookupModule` can be a linear function that looks through the entire list of `ModuleGraphNodes` Fixes #21816 - - - - - dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00 rts: Fix AdjustorPool bitmap manipulation Previously the implementation of bitmap_first_unset assumed that `__builtin_clz` would accept `uint8_t` however it apparently rather extends its argument to `unsigned int`. To fix this we simply revert to a naive implementation since handling the various corner cases with `clz` is quite tricky. This should be fine given that AdjustorPool isn't particularly hot. Ideally we would have a single, optimised bitmap implementation in the RTS but I'll leave this for future work. Fixes #21838. - - - - - ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00 Change GHCi bytecode return convention for unlifted datatypes. This changes the bytecode return convention for unlifted algebraic datatypes to be the same as for lifted types, i.e. ENTER/PUSH_ALTS instead of RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED Fixes #20849 - - - - - 5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00 Compute record-dot-syntax types Ensures type information for record-dot-syntax is included in HieASTs. See #21797 - - - - - 89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00 Add record-dot-syntax test - - - - - 4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00 Document RuntimeRep polymorphism limitations of catch#, et al As noted in #21868, several primops accepting continuations producing RuntimeRep-polymorphic results aren't nearly as polymorphic as their types suggest. Document this limitation and adapt the `UnliftedWeakPtr` test to avoid breaking this limitation in `keepAlive#`. - - - - - 4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00 Make keepAlive# out-of-line This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203 - - - - - 1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00 Suppress extra output from configure check for c++ libraries - - - - - 3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00 rel-notes: Drop mention of #21745 fix Since we have backported the fix to 9.4.1. - - - - - b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00 Align the behaviour of `dopt` and `log_dopt` Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying function `log_dopt`) were different as the latter did not take the verbosity level into account. This led to problems during the refactoring as we cannot simply replace calls to `dopt` with calls to `logHasDumpFlag`. In addition to that a subtle bug in the GHC module was fixed: `setSessionDynFlags` did not update the logger and as a consequence the verbosity value of the logger was not set appropriately. Fixes #21861 - - - - - 28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00 rts: forkOn context switches the target capability Fixes #21824 - - - - - f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Eliminate orphan Outputable instances Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and `OutputableP` instances for the Cmm AST. This makes it significantly easier to use the Cmm pretty-printers in tracing output without incurring module import cycles. - - - - - f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Move toBlockList to GHC.Cmm - - - - - fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00 compiler: Add haddock sections to GHC.Utils.Panic - - - - - 097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00 configure: Don't override Windows CXXFLAGS At some point we used the clang distribution from msys2's `MINGW64` environment for our Windows toolchain. This defaulted to using libgcc and libstdc++ for its runtime library. However, we found for a variety of reasons that compiler-rt, libunwind, and libc++ were more reliable, consequently we explicitly overrode the CXXFLAGS to use these. However, since then we have switched to use the `CLANG64` packaging, which default to these already. Consequently we can drop these arguments, silencing some redundant argument warnings from clang. Fixes #21669. - - - - - e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Check that there are no NULL ctors - - - - - 616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Introduce support for invoking finalizers on unload Addresses #20494. - - - - - cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add T20494 - - - - - 03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Rename finit field to fini fini is short for "finalizer", which does not contain a "t". - - - - - 033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Refactor handling of oc->info Previously we would free oc->info after running initializers. However, we can't do this is we want to also run finalizers. Moreover, freeing oc->info so early was wrong for another reason: we will need it in order to unregister the exception tables (see the call to `RtlDeleteFunctionTable`). In service of #20494. - - - - - f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Add finalization support This implements #20494 for the PEi386 linker. Happily, this also appears to fix `T9405`, resolving #21361. - - - - - 2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00 Loader: Implement gnu-style -l:$path syntax Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic. - - - - - 5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00 Statically-link against libc++ on Windows Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435. - - - - - 8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run It turns out that PE objects may have multiple `.ctors`/`.dtors` sections but the RTS linker had assumed that there was only one. Fix this. Fixes #21618. - - - - - fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Respect dtor/ctor priority Previously we would run constructors and destructors in arbitrary order despite explicit priorities. Fixes #21847. - - - - - 1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add test for #21618 and #21847 - - - - - 6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Fix exception unwind unregistration RtlDeleteFunctionTable expects a pointer to the .pdata section yet we passed it the .xdata section. Happily, this fixes #21354. - - - - - d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Drop dead code - - - - - d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Use section flags to identify initializers - - - - - fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Introduce finalizer support - - - - - 5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl - - - - - 6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker/Elf: Work around GCC 6 init/fini behavior It appears that GCC 6t (at least on i386) fails to give init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY section types, instead marking them as SHT_PROGBITS. This caused T20494 to fail on Debian. - - - - - 5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Mark T13366Cxx as unbroken on Darwin - - - - - 1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Fix resolution of __dso_handle on Darwin Darwin expects a leading underscore. - - - - - a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Clean up section kinds - - - - - aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Ensure that __cxa_finalize is called on code unload - - - - - 028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00 testsuite: Fix T11829 on Centos 7 It appears that Centos 7 has a more strict C++ compiler than most distributions since std::runtime_error is defined in <stdexcept> rather than <exception>. In T11829 we mistakenly imported the latter. - - - - - a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00 hadrian: Rename documentation directories for consistency with make * Rename `docs` to `doc` * Place pdf documentation in `doc/` instead of `doc/pdfs/` Fixes #21164. - - - - - b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00 Fix incorrect proof of applyWhen’s properties - - - - - eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00 hadrian: Add multi:<pkg> and multi targets for starting a multi-repl This patch adds support to hadrian for starting a multi-repl containing all the packages which stage0 can build. In particular, there is the new user-facing command: ``` ./hadrian/ghci-multi ``` which when executed will start a multi-repl containing the `ghc` package and all it's dependencies. This is implemented by two new hadrian targets: ``` ./hadrian/build multi:<pkg> ``` Construct the arguments for a multi-repl session where the top-level package is <pkg>. For example, `./hadrian/ghci-multi` is implemented using `multi:ghc` target. There is also the `multi` command which constructs a repl for everything in stage0 which we can build. - - - - - 19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00 changelog typo - - - - - af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00 typos - - - - - 415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00 Refactor SpecConstr to use treat bindings uniformly This patch, provoked by #21457, simplifies SpecConstr by treating top-level and nested bindings uniformly (see the new scBind). * Eliminates the mysterious scTopBindEnv * Refactors scBind to handle top-level and nested definitions uniformly. * But, for now at least, continues the status quo of not doing SpecConstr for top-level non-recursive bindings. (In contrast we do specialise nested non-recursive bindings, although the original paper did not; see Note [Local let bindings].) I tried the effect of specialising top-level non-recursive bindings (which is now dead easy to switch on, unlike before) but found some regressions, so I backed off. See !8135. It's a pure refactoring. I think it'll do a better job in a few cases, but there is no regression test. - - - - - d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00 Rule matching: Don't compute the FVs if we don't look at them. - - - - - 5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 White space only in FamInstEnv - - - - - ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make transferPolyIdInfo work for CPR I don't know why this hasn't bitten us before, but it was plain wrong. - - - - - 9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Inline mapAccumLM This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically. - - - - - d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make SetLevels honour floatConsts This fix, in the definition of profitableFloat, is just for consistency. `floatConsts` should do what it says! I don't think it'll affect anything much, though. - - - - - d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Refactor wantToUnboxArg a bit * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg and similarly wantToUnboxResult to canUnboxResult. * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg, avoiding some yukky duplication. I decided it was clearer to give it a new data type for its return type, because I nedeed the FD_RecBox case which was not otherwise readiliy expressible. * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload * Get rid of the Unlift constructor of UnboxingDecision, eliminate two panics, and two arguments to canUnboxArg (new name). Much nicer now. - - - - - 6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00 Allow running memInventory when the concurrent nonmoving gc is enabled If the nonmoving gc is enabled and we are using a threaded RTS, we now try to grab the collector mutex to avoid memInventory and the collection racing. Before memInventory was disabled. - - - - - aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00 gitignore: don't ignore all aclocal.m4 files While GHC's own aclocal.m4 is generated by the aclocal tool, other packages' aclocal.m4 are committed in the repository. Previously `.gitignore` included an entry which covered *any* file named `aclocal.m4`, which lead to quite some confusion (e.g. see #21740). Fix this by modifying GHC's `.gitignore` to only cover GHC's own `aclocal.m4`. - - - - - 4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00 Add mapAccumM, forAccumM to Data.Traversable Approved by Core Libraries Committee in https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433 - - - - - bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00 configure: Use AC_PATH_TOOL to detect tools Previously we used AC_PATH_PROG which, as noted by #21601, does not look for tools with a target prefix, breaking cross-compilation. Fixes #21601. - - - - - e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00 driver: Fix implementation of -S We were failing to stop before running the assembler so the object file was also created. Fixes #21869 - - - - - e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00 rts/ProfHeap: Ensure new Censuses are zeroed When growing the Census array ProfHeap previously neglected to zero the new part of the array. Consequently `freeEra` would attempt to free random words that often looked suspiciously like pointers. Fixes #21880. - - - - - 81d65f7f by sheaf at 2022-07-21T15:37:22+02:00 Make withDict opaque to the specialiser As pointed out in #21575, it is not sufficient to set withDict to inline after the typeclass specialiser, because we might inline withDict in one module and then import it in another, and we run into the same problem. This means we could still end up with incorrect runtime results because the typeclass specialiser would assume that distinct typeclass evidence terms at the same type are equal, when this is not necessarily the case when using withDict. Instead, this patch introduces a new magicId, 'nospec', which is only inlined in CorePrep. We make use of it in the definition of withDict to ensure that the typeclass specialiser does not common up distinct typeclass evidence terms. Fixes #21575 - - - - - 9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00 Refactored Simplify pass * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify namespace and GHC.Core.Opt.Stats. Also removed services from configuration records. * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration. * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm` and moved the Simplify driver to GHC.Core.Opt.Simplify. * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env. * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment in GHC.Core.Opt.Simplify.Monad. * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions for those in a new module GHC.Driver.Config.Core.Opt.Simplify. Also added initialization functions for `SimplMode` to that module. * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types and the counting types and functions (`SimplCount` and `Tick`) to new module GHC.Core.Opt.Stats. * Added getter functions for the fields of `SimplMode`. The pedantic bottoms option and the platform are retrieved from the ArityOpts and RuleOpts and the getter functions allow us to retrieve values from `SpecEnv` without the knowledge where the data is stored exactly. * Moved the coercion optimization options from the top environment to `SimplMode`. This way the values left in the top environment are those dealing with monadic functionality, namely logging, IO related stuff and counting. Added a note "The environments of the Simplify pass". * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead. * Prep work before removing `InteractiveContext` from `HscEnv`. - - - - - 2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00 Make the specialiser deal better with specialised methods This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368. - - - - - ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00 ghc-boot: Clean up UTF-8 codecs In preparation for moving the UTF-8 codecs into `base`: * Move them to GHC.Utils.Encoding.UTF8 * Make names more consistent * Add some Haddocks - - - - - e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00 base: Introduce GHC.Encoding.UTF8 Here we copy a subset of the UTF-8 implementation living in `ghc-boot` into `base`, with the intent of dropping the former in the future. For this reason, the `ghc-boot` copy is now CPP-guarded on `MIN_VERSION_base(4,18,0)`. Naturally, we can't copy *all* of the functions defined by `ghc-boot` as some depend upon `bytestring`; we rather just copy those which only depend upon `base` and `ghc-prim`. Further consolidation? ---------------------- Currently GHC ships with at least five UTF-8 implementations: * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this can be used at a number of types including `Addr#`, `ByteArray#`, `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this can be removed in GHC 9.6+2, when the copies in `base` will become available to `ghc-boot`. * the copy of the `ghc-boot` definition now exported by `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`, `ByteArray#`, and `ForeignPtr` * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`; this is specialised at `Addr#`. * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`; this is specialised at `Addr#` but, unlike the above, supports recovery in the presence of partial codepoints (since in IO contexts codepoints may be broken across buffers) * the implementation provided by the `text` library This does seem a tad silly. On the other hand, these implementations *do* materially differ from one another (e.g. in the types they support, the detail in errors they can report, and the ability to recover from partial codepoints). Consequently, it's quite unclear that further consolidate would be worthwhile. - - - - - f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00 Add a Note summarising GHC's UTF-8 implementations GHC has a somewhat dizzying array of UTF-8 implementations. This note describes why this is the case. - - - - - 72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00 upload_ghc_libs: Fix path to documentation The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35 but this one occurrence was note updated. Finally closes #21164. - - - - - a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00 Add test for #21871 This adds a test for #21871, which was fixed by the No Skolem Info rework (MR !7105). Fixes #21871 - - - - - 6379f942 by sheaf at 2022-07-22T08:18:46-04:00 Add test for #21360 The way record updates are typechecked/desugared changed in MR !7981. Because we desugar in the typechecker to a simple case expression, the pattern match checker becomes able to spot the long-distance information and avoid emitting an incorrect pattern match warning. Fixes #21360 - - - - - ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00 Hadrian: don't try to build "unix" on Windows - - - - - dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Implement DeepSubsumption This MR adds the language extension -XDeepSubsumption, implementing GHC proposal #511. This change mitigates the impact of GHC proposal The changes are highly localised, by design. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. The main changes are: * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010, but off in Haskell2021. -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change. -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds: it makes type inference more complicated and less predictable, but it may be convenient in practice. * The main changes are in: * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result type. Without deep subsumption, unifyExpectedType would be sufficent. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. * There are no changes to Quick Look at all. * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to GHC.Magic.Dict * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where we'd forgotten to take the free vars of the multiplicity of an Id. * I also had to fix tcSplitNestedSigmaTys When I did the shallow-subsumption patch commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f Date: Sun Feb 2 18:23:11 2020 +0000 Simple subsumption I changed tcSplitNestedSigmaTys to not look through function arrows any more. But that was actually an un-forced change. This function is used only in * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect All to do with validity checking and error messages. Acutally its fine to look under function arrows here, and quite useful a test DeepSubsumption05 (a test motivated by a build failure in the `lens` package) shows. The fix is easy. I added Note [tcSplitNestedSigmaTys]. - - - - - e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption - - - - - 67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add DeepSubsumption08 - - - - - 5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Fix the interaction of operator sections and deep subsumption Fixes DeepSubsumption08 - - - - - 918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00 Add DeepSubsumption09 - - - - - 2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00 Default implementation for mempty/(<>) Approved by: https://github.com/haskell/core-libraries-committee/issues/61 This adds a default implementation for `mempty` and `(<>)` along with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid` instances can be defined in terms of `sconcat` / `mconcat`. The description for each class has also been updated to include the equivalent set of laws for the `sconcat`-only / `mconcat`-only instances. - - - - - 73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00 ci: Disable (broken) perf-nofib See #21859 - - - - - c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00 Docs: clarify ConstraintKinds infelicity GHC doesn't consistently require the ConstraintKinds extension to be enabled, as it allows programs such as type families returning a constraint without this extension. MR !7784 fixes this infelicity, but breaking user programs was deemed to not be worth it, so we document it instead. Fixes #21061. - - - - - 5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00 More improvements to worker/wrapper This patch fixes #21888, and simplifies finaliseArgBoxities by eliminating the (recently introduced) data type FinalDecision. A delicate interaction meant that this patch commit d1c25a48154236861a413e058ea38d1b8320273f Date: Tue Jul 12 16:33:46 2022 +0100 Refactor wantToUnboxArg a bit make worker/wrapper go into an infinite loop. This patch fixes it by narrowing the handling of case (B) of Note [Boxity for bottoming functions], to deal only the arguemnts that are type variables. Only then do we drop the trimBoxity call, which is what caused the bug. I also * Added documentation of case (B), which was previously completely un-mentioned. And a regression test, T21888a, to test it. * Made unboxDeeplyDmd stop at lazy demands. It's rare anyway for a bottoming function to have a lazy argument (mainly when the data type is recursive and then we don't want to unbox deeply). Plus there is Note [No lazy, Unboxed demands in demand signature] * Refactored the Case equation for dmdAnal a bit, to do less redundant pattern matching. - - - - - b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00 Fix a small buglet in tryEtaReduce Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was making an ill-formed cast. It didn't matter, because the subsequent guard discarded it; but still worth fixing. Spurious warnings are distracting. - - - - - 3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00 Fix #21889, GHCi misbehaves with Ctrl-C on Windows On Windows, we create multiple levels of wrappers for GHCi which ultimately execute ghc --interactive. In order to handle console events properly, each of these wrappers must call FreeConsole() in order to hand off event processing to the child process. See #14150. In addition to this, FreeConsole must only be called from interactive processes (#13411). This commit makes two changes to fix this situation: 1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole` if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi. 2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`: Before: ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe After: ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe - - - - - 79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00 docs: Fix documentation of \cases Fixes #21902. - - - - - e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00 ghc-cabal: allow Cabal 3.8 to unbreak make build When bootstrapping GHC 9.4.*, the build will fail when configuring ghc-cabal as part of the make based build system due to this upper bound, as Cabal has been updated to a 3.8 release. Reference #21914, see especially https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699 - - - - - 726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Fix isEvaldUnfolding and isValueUnfolding This fixes (1) in #21831. Easy, obviously correct. - - - - - 5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Switch off eta-expansion in rules and unfoldings I think this change will make little difference except to reduce clutter. But that's it -- if it causes problems we can switch it on again. - - - - - d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Teach SpecConstr about typeDeterminesValue This patch addresses #21831, point 2. See Note [generaliseDictPats] in SpecConstr I took the opportunity to refactor the construction of specialisation rules a bit, so that the rule name says what type we are specialising at. Surprisingly, there's a 20% decrease in compile time for test perf/compiler/T18223. I took a look at it, and the code size seems the same throughout. I did a quick ticky profile which seemed to show a bit less substitution going on. Hmm. Maybe it's the "don't do eta-expansion in stable unfoldings" patch, which is part of the same MR as this patch. Anyway, since it's a move in the right direction, I didn't think it was worth looking into further. Metric Decrease: T18223 - - - - - 65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Add a 'notes' file in testsuite/tests/perf/compiler This file is just a place to accumlate notes about particular benchmarks, so that I don't keep re-inventing the wheel. - - - - - 61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00 Get the in-scope set right in FamInstEnv.injectiveBranches There was an assert error, as Gergo pointed out in #21896. I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs. And also to GHC.Core.Unify.niFixTCvSubst. I also took the opportunity to get a couple more InScopeSets right, and to change some substTyUnchecked into substTy. This MR touches a lot of other files, but only because I also took the opportunity to introduce mkInScopeSetList, and use it. - - - - - 4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00 Add location to cc phase - - - - - 96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00 Avoid as pipeline when compiling c - - - - - 2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00 testsuite: Skip test cases involving -S when testing unregisterised GHC We no longer generate .s files anyway. Metric Decrease: MultiLayerModules T10421 T13035 T13701 T14697 T16875 T18140 T18304 T18923 T9198 - - - - - 82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00 testsuite: introduce nonmoving_thread_sanity way (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae) - - - - - 4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Track segment state It can often be useful during debugging to be able to determine the state of a nonmoving segment. Introduce some state, enabled by DEBUG, to track this. (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f) - - - - - 54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Don't scavenge objects which weren't evacuated This fixes a rather subtle bug in the logic responsible for scavenging objects evacuated to the non-moving generation. In particular, objects can be allocated into the non-moving generation by two ways: a. evacuation out of from-space by the garbage collector b. direct allocation by the mutator Like all evacuation, objects moved by (a) must be scavenged, since they may contain references to other objects located in from-space. To accomplish this we have the following scheme: * each nonmoving segment's block descriptor has a scan pointer which points to the first object which has yet to be scavenged * the GC tracks a set of "todo" segments which have pending scavenging work * to scavenge a segment, we scavenge each of the unmarked blocks between the scan pointer and segment's `next_free` pointer. We skip marked blocks since we know the allocator wouldn't have allocated into marked blocks (since they contain presumably live data). We can stop at `next_free` since, by definition, the GC could not have evacuated any objects to blocks above `next_free` (otherwise `next_free wouldn't be the first free block). However, this neglected to consider objects allocated by path (b). In short, the problem is that objects directly allocated by the mutator may become unreachable (but not swept, since the containing segment is not yet full), at which point they may contain references to swept objects. Specifically, we observed this in #21885 in the following way: 1. the mutator (specifically in #21885, a `lockCAF`) allocates an object (specifically a blackhole, which here we will call `blkh`; see Note [Static objects under the nonmoving collector] for the reason why) on the non-moving heap. The bitmap of the allocated block remains 0 (since allocation doesn't affect the bitmap) and the containing segment's (which we will call `blkh_seg`) `next_free` is advanced. 2. We enter the blackhole, evaluating the blackhole to produce a result (specificaly a cons cell) in the nursery 3. The blackhole gets updated into an indirection pointing to the cons cell; it is pushed to the generational remembered set 4. we perform a GC, the cons cell is evacuated into the nonmoving heap (into segment `cons_seg`) 5. the cons cell is marked 6. the GC concludes 7. the CAF and blackhole become unreachable 8. `cons_seg` is filled 9. we start another GC; the cons cell is swept 10. we start a new GC 11. something is evacuated into `blkh_seg`, adding it to the "todo" list 12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks between `scan` and `next_free`, which includes `blkh`). We attempt to evacuate `blkh`'s indirectee, which is the previously-swept cons cell. This is unsafe, since the indirectee is no longer a valid heap object. The problem here was that the scavenging logic *assumed* that (a) was the only source of allocations into the non-moving heap and therefore *all* unmarked blocks between `scan` and `next_free` were evacuated. However, due to (b) this is not true. The solution is to ensure that that the scanned region only encompasses the region of objects allocated during evacuation. We do this by updating `scan` as we push the segment to the todo-segment list to point to the block which was evacuated into. Doing this required changing the nonmoving scavenging implementation's update of the `scan` pointer to bump it *once*, instead of after scavenging each block as was done previously. This is because we may end up evacuating into the segment being scavenged as we scavenge it. This was quite tricky to discover but the result is quite simple, demonstrating yet again that global mutable state should be used exceedingly sparingly. Fixes #21885 (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060) - - - - - 25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00 testsuite: Skip a few tests as in the nonmoving collector Residency monitoring under the non-moving collector is quite conservative (e.g. the reported value is larger than reality) since otherwise we would need to block on concurrent collection. Skip a few tests that are sensitive to residency. (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70) - - - - - 42147534 by sternenseemann at 2022-07-26T16:26:53-04:00 hadrian: add flag disabling selftest rules which require QuickCheck The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699. - - - - - 9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00 Regression test for #21848 - - - - - ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00 driver: Don't create LinkNodes when -no-link is enabled Fixes #21866 - - - - - fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00 Docs: fix mistaken claim about kind signatures This patch fixes #21806 by rectifying an incorrect claim about the usage of kind variables in the header of a data declaration with a standalone kind signature. It also adds some clarifications about the number of parameters expected in GADT declarations and in type family declarations. - - - - - 2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00 testsuite: Correctly set withNativeCodeGen Fixes #21918 - - - - - f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00 Fix since annotations in GHC.Stack.CloneStack Fixes #21894 - - - - - aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00 Add -dsuppress-coercion-types to make coercions even smaller. Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)`` simply print `` `cast` <Co:11> :: ... `` - - - - - 97655ad8 by sheaf at 2022-08-02T19:27:29-04:00 User's guide: fix typo in hasfield.rst Fixes #21950 - - - - - 35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00 Remove TCvSubst and use Subst for both term and type-level subst This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types). - - - - - b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00 Fix TH + defer-type-errors interaction (#21920) Previously, we had to disable defer-type-errors in splices because of #7276. But this fix is no longer necessary, the test T7276 no longer segfaults and is now correctly deferred. - - - - - fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00 Add a note about about W/W for unlifting strict arguments This fixes #21236. - - - - - fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force safeInferred to avoid retaining extra copy of DynFlags This will only have a (very) modest impact on memory but we don't want to retain old copies of DynFlags hanging around so best to force this value. - - - - - 0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force name selectors to ensure no reference to Ids enter the NameCache I observed some unforced thunks in the NameCache which were retaining a whole Id, which ends up retaining a Type.. which ends up retaining old copies of HscEnv containing stale HomeModInfo. - - - - - 0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Fix leaks in --make mode when there are module loops This patch fixes quite a tricky leak where we would end up retaining stale ModDetails due to rehydrating modules against non-finalised interfaces. == Loops with multiple boot files It is possible for a module graph to have a loop (SCC, when ignoring boot files) which requires multiple boot files to break. In this case we must perform the necessary hydration steps before and after compiling modules which have boot files which are described above for corectness but also perform an additional hydration step at the end of the SCC to remove space leaks. Consider the following example: ┌───────┐ ┌───────┐ │ │ │ │ │ A │ │ B │ │ │ │ │ └─────┬─┘ └───┬───┘ │ │ ┌────▼─────────▼──┐ │ │ │ C │ └────┬─────────┬──┘ │ │ ┌────▼──┐ ┌───▼───┐ │ │ │ │ │ A-boot│ │ B-boot│ │ │ │ │ └───────┘ └───────┘ A, B and C live together in a SCC. Say we compile the modules in order A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps (because A has a boot file). Therefore C will be hydrated relative to A, and the ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again, and so B will reference C/A,B, its interface will be hydrated relative to both A and B. Now there is a space leak because say C is a very big module, there are now two different copies of ModDetails kept alive by modules A and B. The way to avoid this space leak is to rehydrate an entire SCC together at the end of compilation so that all the ModDetails point to interfaces for .hs files. In this example, when we hydrate A, B and C together then both A and B will refer to C/A,B. See #21900 for some more discussion. ------------------------------------------------------- In addition to this simple case, there is also the potential for a leak during parallel upsweep which is also fixed by this patch. Transcibed is Note [ModuleNameSet, efficiency and space leaks] Note [ModuleNameSet, efficiency and space leaks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During unsweep the results of compiling modules are placed into a MVar, to find the environment the module needs to compile itself in the MVar is consulted and the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking module dependencies and recreating the HUG from scratch each time is very expensive. In serial mode (-j1), this all works out fine because a module can only be compiled after its dependencies have finished compiling and not interleaved with compiling module loops. Therefore when we create the finalised or no loop interfaces, the HUG only contains finalised interfaces. In parallel mode, we have to be more careful because the HUG variable can contain non-finalised interfaces which have been started by another thread. In order to avoid a space leak where a finalised interface is compiled against a HPT which contains a non-finalised interface we have to restrict the HUG to only the visible modules. The visible modules is recording in the ModuleNameSet, this is propagated upwards whilst compiling and explains which transitive modules are visible from a certain point. This set is then used to restrict the HUG before the module is compiled to only the visible modules and thus avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance because a union occurs for each edge in the module graph. Therefore the set is represented directly as an IntSet which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. See test "jspace" for an example which used to trigger this problem. Fixes #21900 - - - - - 1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Store interfaces in ModIfaceCache more directly I realised hydration was completely irrelavant for this cache because the ModDetails are pruned from the result. So now it simplifies things a lot to just store the ModIface and Linkable, which we can put into the cache straight away rather than wait for the final version of a HomeModInfo to appear. - - - - - 6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00 cmm: Remove unused ReadOnlyData16 We don't actually emit rodata16 sections anywhere. - - - - - 16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00 findExternalRules: Don't needlessly traverse the list of rules. - - - - - 52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00 Remove backported items from 9.6 release notes They have been backported to 9.4 in commits 5423d84bd9a28f, 13c81cb6be95c5, 67ccbd6b2d4b9b. - - - - - 78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00 ci: Fix pages job The job has been failing because we don't bundle haddock docs anymore in the docs dist created by hadrian. Fixes #21789 - - - - - 037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00 codeGen/X86: Don't clobber switch variable in switch generation Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was safe to clobber the switch variable when generating code for a jump table since we were at the end of a block. However, this assumption is wrong; the register could be live in the jump target. Fixes #21968. - - - - - 50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00 Fix equality operator in jspace test - - - - - e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Improve BUILD_PAP comments - - - - - 41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Make dropTail comment a haddock comment - - - - - ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Add one more sanity check in stg_restore_cccs - - - - - 1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00 StgToCmm: Fix isSimpleScrut when profiling is enabled. When profiling is enabled we must enter functions that might represent thunks in order for their sccs to show up in the profile. We might allocate even if the function is already evaluated in this case. So we can't consider any potential function thunk to be a simple scrut when profiling. Not doing so caused profiled binaries to segfault. - - - - - fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Change `-fprof-late` to insert cost centres after unfolding creation. The former behaviour of adding cost centres after optimization but before unfoldings are created is not available via the flag `prof-late-inline` instead. I also reduced the overhead of -fprof-late* by pushing the cost centres into lambdas. This means the cost centres will only account for execution of functions and not their partial application. Further I made LATE_CC cost centres it's own CC flavour so they now won't clash with user defined ones if a user uses the same string for a custom scc. LateCC: Don't put cost centres inside constructor workers. With -fprof-late they are rarely useful as the worker is usually inlined. Even if the worker is not inlined or we use -fprof-late-linline they are generally not helpful but bloat compile and run time significantly. So we just don't add sccs inside constructor workers. ------------------------- Metric Decrease: T13701 ------------------------- - - - - - f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00 gitlab-ci: Fix hadrian bootstrapping of release pipelines Previously we would attempt to test hadrian bootstrapping in the `validate` build flavour. However, `ci.sh` refuses to run validation builds during release pipelines, resulting in job failures. Fix this by testing bootstrapping in the `release` flavour during release pipelines. We also attempted to record perf notes for these builds, which is redundant work and undesirable now since we no longer build in a consistent flavour. - - - - - c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00 compiler: Eliminate two uses of foldr in favor of foldl' These two uses constructed maps, which is a case where foldl' is generally more efficient since we avoid constructing an intermediate O(n)-depth stack. - - - - - d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00 rts: Fix code style - - - - - 57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00 genprimopcode: Drop ArrayArray# references As ArrayArray# no longer exists - - - - - 7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00 base: Organize Haddocks in GHC.Conc.Sync - - - - - aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00 Add primop to list threads A user came to #ghc yesterday wondering how best to check whether they were leaking threads. We ended up using the eventlog but it seems to me like it would be generally useful if Haskell programs could query their own threads. - - - - - 6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00 rts: Move thread labels into TSO This eliminates the thread label HashTable and instead tracks this information in the TSO, allowing us to use proper StgArrBytes arrays for backing the label and greatly simplifying management of object lifetimes when we expose them to the user with the coming `threadLabel#` primop. - - - - - 1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00 Add a primop to query the label of a thread - - - - - 43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00 base: Share finalization thread label For efficiency's sake we float the thread label assigned to the finalization thread to the top-level, ensuring that we only need to encode the label once. - - - - - 1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00 users-guide: Add release notes entry for thread introspection support - - - - - 09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix binary distribution install attributes Previously we would use plain `cp` to install various parts of the binary distribution. However, `cp`'s behavior w.r.t. file attributes is quite unclear; for this reason it is much better to rather use `install`. Fixes #21965. - - - - - 2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix installation of system-cxx-std-lib package conf - - - - - 7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00 gitlab-ci: Bump Docker images To give the ARMv7 job access to lld, fixing #21875. - - - - - afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Don't use mk/config.mk.in Ultimately we want to drop mk/config.mk so here I extract the bits needed by the Hadrian bindist installation logic into a Hadrian-specific file. While doing this I fixed binary distribution installation, #21901. - - - - - b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Fix naming of cross-compiler wrappers - - - - - 78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00 hadrian: Extend xattr Darwin hack to cover /lib As noted in #21506, it is now necessary to remove extended attributes from `/lib` as well as `/bin` to avoid SIP issues on Darwin. Fixes #21506. - - - - - 20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00 NCG(x86): Compile add+shift as lea if possible. - - - - - 742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00 dataToTag#: Skip runtime tag check if argument is infered tagged This addresses one part of #21710. - - - - - 1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00 rts: remove redundant stg_traceCcszh This out-of-line primop has no Haskell wrapper and hasn't been used anywhere in the tree. Furthermore, the code gets in the way of !7632, so it should be garbage collected. - - - - - a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00 Document a divergence from the report in parsing function lhss. GHC is happy to parse `(f) x y = x + y` when it should be a parse error based on the Haskell report. Seems harmless enough so we won't fix it but it's documented now. Fixes #19788 - - - - - 5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00 gitlab-ci: Add release job for aarch64/debian 11 - - - - - 5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Introduce validation job for aarch64 cross-compilation Begins to address #11958. - - - - - e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00 Bump process submodule - - - - - ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Add basic support for cross-compiler testiing Here we add a simple qemu-based test for cross-compilers. - - - - - 50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00 rts: Ensure that Array# card arrays are initialized In #19143 I noticed that newArray# failed to initialize the card table of newly-allocated arrays. However, embarrassingly, I then only fixed the issue in newArrayArray# and, in so doing, introduced the potential for an integer underflow on zero-length arrays (#21962). Here I fix the issue in newArray#, this time ensuring that we do not underflow in pathological cases. Fixes #19143. - - - - - e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00 testsuite: Add test for #21962 - - - - - c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00 gitlab-ci: Don't use coreutils on Darwin In general we want to ensure that the tested environment is as similar as possible to the environment the user will use. In the case of Darwin, this means we want to use the system's BSD command-line utilities, not coreutils. This would have caught #21974. - - - - - 1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00 hadrian: Fix bindist installation on Darwin It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does. - - - - - 681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00 hadrian: Fix access mode of installed package registration files Previously hadrian's bindist Makefile would modify package registrations placed by `install` via a shell pipeline and `mv`. However, the use of `mv` means that if umask is set then the user may otherwise end up with package registrations which are inaccessible. Fix this by ensuring that the mode is 0644. - - - - - e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00 Cleanups around pretty-printing * Remove hack when printing OccNames. No longer needed since e3dcc0d5 * Remove unused `pprCmms` and `instance Outputable Instr` * Simplify `pprCLabel` (no need to pass platform) * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by ImmLit, but that can take just a String instead. * Remove instance `Outputable CLabel` - proper output of labels needs a platform, and is done by the `OutputableP` instance - - - - - 66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00 rts/linker: Resolve iconv_* on FreeBSD FreeBSD's libiconv includes an implementation of the iconv_* functions in libc. Unfortunately these can only be resolved using dlvsym, which is how the RTS linker usually resolves such functions. To fix this we include an ad-hoc special case for iconv_*. Fixes #20354. - - - - - 5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00 system-cxx-std-lib: Add support for FreeBSD libcxxrt - - - - - ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00 gitlab-ci: Bump to use freebsd13 runners - - - - - d71a2051 by sheaf at 2022-08-09T13:47:28-04:00 Fix size_up_alloc to account for UnliftedDatatypes The size_up_alloc function mistakenly considered any type that isn't lifted to not allocate anything, which is wrong. What we want instead is to check the type isn't boxed. This accounts for (BoxedRep Unlifted). Fixes #21939 - - - - - 76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. - - - - - 7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. - - - - - dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00 Updates language extension documentation Adding a 'Status' field with a few values: - Deprecated - Experimental - InternalUseOnly - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98' Those values are pulled from the existing descriptions or elsewhere in the documentation. While at it, include the :implied by: where appropriate, to provide more detail. Fixes #21475 - - - - - 823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00 hadrian RunRest: add type signature for stageNumber avoids warning seen on 9.4.1: src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults] • Defaulting the following constraints to type ‘Integer’ (Show a0) arising from a use of ‘show’ at src/Settings/Builders/RunTest.hs:264:53-84 (Num a0) arising from a use of ‘stageNumber’ at src/Settings/Builders/RunTest.hs:264:59-83 • In the second argument of ‘(++)’, namely ‘show (stageNumber (C.stage ctx))’ In the second argument of ‘($)’, namely ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’ In the expression: arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | 264 | , arg "-e", arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compilation tested locally - - - - - f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00 Add support for external static plugins (#20964) This patch adds a new command-line flag: -fplugin-library=<file-path>;<unit-id>;<module>;<args> used like this: -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"] It allows a plugin to be loaded directly from a shared library. With this approach, GHC doesn't compile anything for the plugin and doesn't load any .hi file for the plugin and its dependencies. As such GHC doesn't need to support two environments (one for plugins, one for target code), which was the more ambitious approach tracked in #14335. Fix #20964 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Fix ARMv7 build It appears that the CI refactoring carried out in 5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some critical configuration: setting the build/host/target platforms and forcing use of a non-broken linker. - - - - - 596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Run ARMv7 jobs when ~ARM label is used - - - - - 7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00 hadrian: Don't attempt to install documentation if doc/ doesn't exist Previously we would attempt to install documentation even if the `doc` directory doesn't exist (e.g. due to `--docs=none`). This would result in the surprising side-effect of the entire contents of the bindist being installed in the destination documentation directory. Fix this. Fixes #21976. - - - - - 67575f20 by normalcoder at 2022-08-10T15:38:34-04:00 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - - - - - 45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00 Note [Trimming auto-rules]: State that this improves compiler perf. - - - - - 5c24b1b3 by Bodigrim at 2022-08-10T22:41:50-04:00 Document that threadDelay / timeout are susceptible to overflows on 32-bit machines - - - - - ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule - - - - - dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00 Revert "gitlab-ci: Add release job for aarch64/debian 11" This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46. The job was not tested before being merged and fails CI (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392) Ticket #22005 - - - - - ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00 typo - - - - - cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00 CmmToLlvm: Don't aliasify builtin LLVM variables Our aliasification logic would previously turn builtin LLVM variables into aliases, which apparently confuses LLVM. This manifested in initializers failing to be emitted, resulting in many profiling failures with the LLVM backend. Fixes #22019. - - - - - dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00 run_ci: remove monoidal-containers Fixes #21492 MonoidalMap is inlined and used to implement Variables, as before. The top-level value "jobs" is reimplemented as a regular Map, since it doesn't use the monoidal union anyway. - - - - - 64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00 CmmToAsm/AArch64: correct a typo - - - - - f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00 Fix #21979 - compact-share failing with -O I don't have good reason to believe the optimization level should affect if sharing works or not here. So limit the test to the normal way. - - - - - 68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix reference to dead llvm-version substitution Fixes #22052. - - - - - 28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix incorrect reference to `:extension: role - - - - - 71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Add :ghc-flag: reference - - - - - 385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00 hadrian: Place manpage in docroot This relocates it from docs/ to doc/ - - - - - 84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00 Bump haddock submodule Includes merge of `main` into `ghc-head` as well as some Haddock users guide fixes. - - - - - 59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00 base: Add changelog entries from ghc-9.2 Closes #21922. - - - - - a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00 relnotes: Add "included libraries" section As noted in #21988, some users rely on this. - - - - - a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Rephrase the rewrite rule documentation Previously the wording was a tad unclear. Fix this. Closes #21114. - - - - - 3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00 Implement Response File support for HPC This is an improvement to HPC authored by Richard Wallace (https://github.com/purefn) and myself. I have received permission from him to attempt to upstream it. This improvement was originally implemented as a patch to HPC via input-output-hk/haskell.nix: https://github.com/input-output-hk/haskell.nix/pull/1464 Paraphrasing Richard, HPC currently requires all inputs as command line arguments. With large projects this can result in an argument list too long error. I have only seen this error in Nix, but I assume it can occur is a plain Unix environment. This MR adds the standard response file syntax support to HPC. For example you can now pass a file to the command line which contains the arguments. ``` hpc @response_file_1 @response_file_2 ... The contents of a Response File must have this format: COMMAND ... example: report my_library.tix --include=ModuleA --include=ModuleB ``` Updates hpc submodule Co-authored-by: Richard Wallace <rwallace at thewallacepack.net> Fixes #22050 - - - - - 436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00 ghc-heap: Fix decoding of TSO closures An extra field was added to the TSO structure in 6d1700b6 but the decoding logic in ghc-heap was not updated for this new field. Fixes #22046 - - - - - a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00 driver: Honour -x option The -x option is used to manually specify which phase a file should be started to be compiled from (even if it lacks the correct extension). I just failed to implement this when refactoring the driver. In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to preprocess source files using GHC. I added a test to exercise this case. Fixes #22044 - - - - - e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00 Be more careful in chooseInferredQuantifiers This fixes #22065. We were failing to retain a quantifier that was mentioned in the kind of another retained quantifier. Easy to fix. - - - - - 714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00 testsuite: Add test for #21583 - - - - - 989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00 compiler: Drop --build-id=none hack Since 2011 the object-joining implementation has had a hack to pass `--build-id=none` to `ld` when supported, seemingly to work around a linker bug. This hack is now unnecessary and may break downstream users who expect objects to have valid build-ids. Remove it. Closes #22060. - - - - - 519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00 Make ru_fn field strict to avoid retaining Ids It's better to perform this projection from Id to Name strictly so we don't retain an old Id (hence IdInfo, hence Unfolding, hence everything etc) - - - - - 7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force `getOccFS bndr` to avoid retaining reference to Bndr. This is another symptom of #19619 - - - - - 4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force unfoldings when they are cleaned-up in Tidy and CorePrep If these thunks are not forced then the entire unfolding for the binding is live throughout the whole of CodeGen despite the fact it should have been discarded. Fixes #22071 - - - - - 2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00 haddock docs: Fix links from identifiers to dependent packages When implementing the base_url changes I made the pretty bad mistake of zipping together two lists which were in different orders. The simpler thing to do is just modify `haddockDependencies` to also return the package identifier so that everything stays in sync. Fixes #22001 - - - - - 9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00 Revert "Refactor SpecConstr to use treat bindings uniformly" This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729. This refactoring introduced quite a severe residency regression (900MB live from 650MB live when compiling mmark), see #21993 for a reproducer and more discussion. Ticket #21993 - - - - - 9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00 tc: warn about lazy annotations on unlifted arguments (fixes #21951) - - - - - e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00 Fix #22048 where we failed to drop rules for -fomit-interface-pragmas. Now we also filter the local rules (again) which fixes the issue. - - - - - 51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00 Print constraints in quotes (#21167) This patch improves the uniformity of error message formatting by printing constraints in quotes, as we do for types. Fix #21167 - - - - - ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00 19217 Implicitly quantify type variables in :kind command - - - - - 9939e95f by MorrowM at 2022-08-21T16:51:38-04:00 Recognize file-header pragmas in GHCi (#21507) - - - - - fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00 hadrian: Fix bootstrapping with ghc-9.4 The error was that we were trying to link together containers from boot package library (which depends template-haskell in boot package library) template-haskell from in-tree package database So the fix is to build containers in stage0 (and link against template-haskell built in stage0). Fixes #21981 - - - - - b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00 Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942. * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence * `ParensT` constructor is now always printed parenthesized * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down * using `>=` instead of former `>` to match the Core type printing logic * some test outputs have changed, losing extraneous parentheses - - - - - fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00 Fix and test for issue #21723 - - - - - 33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00 Test for issue #21942 - - - - - c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00 Updated the changelog - - - - - 80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00 hadrian: Don't duplicate binaries on installation Previously we used `install` on symbolic links, which ended up copying the target file rather than installing a symbolic link. Fixes #22062. - - - - - b929063e by M Farkas-Dyck at 2022-08-24T02:37:01-04:00 Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Closes #22092. - - - - - 112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00 driver: don't actually merge objects when ar -L works - - - - - a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00 rts: Consistently use MiB in stats output Previously we would say `MB` even where we meant `MiB`. - - - - - a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223 - - - - - 909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00 upload_ghc_libs: Add means of passing Hackage credentials - - - - - 28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00 Scrub some partiality in `CommonBlockElim`. - - - - - 54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00 hadrian: Fix whitespace Previously this region of Settings.Packages was incorrectly indented. - - - - - c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00 validate: Drop --legacy flag In preparation for removal of the legacy `make`-based build system. - - - - - 822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00 gitlab-ci: Drop make build validation jobs In preparation for removal of the `make`-based build system - - - - - 6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop make build system Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html - - - - - dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00 Remove testsuite/tests/perf/haddock/.gitignore As noted in #16802, this is no longer needed. Closes #16802. - - - - - fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop hc-build script This has not worked for many, many years and relied on the now-removed `make`-based build system. - - - - - 659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mkdirhier This is only used by nofib's dead `dist` target - - - - - 4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mk/{build,install,config}.mk.in - - - - - 46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00 compiler: Drop comment references to make - - - - - d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add inits1 and tails1 to Data.List.NonEmpty See https://github.com/haskell/core-libraries-committee/issues/67 - - - - - 8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add since annotations and changelog entries - - - - - 6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00 Fix redundant import This fixes a build error on x86_64-linux-alpine3_12-validate. See the function 'loadExternalPlugins' defined in this file. - - - - - 4786acf7 by sheaf at 2022-08-26T15:05:23-04:00 Pmc: consider any 2 dicts of the same type equal This patch massages the keys used in the `TmOracle` `CoreMap` to ensure that dictionaries of coherent classes give the same key. That is, whenever we have an expression we want to insert or lookup in the `TmOracle` `CoreMap`, we first replace any dictionary `$dict_abcd :: ct` with a value of the form `error @ct`. This allows us to common-up view pattern functions with required constraints whose arguments differed only in the uniques of the dictionaries they were provided, thus fixing #21662. This is a rather ad-hoc change to the keys used in the `TmOracle` `CoreMap`. In the long run, we would probably want to use a different representation for the keys instead of simply using `CoreExpr` as-is. This more ambitious plan is outlined in #19272. Fixes #21662 Updates unix submodule - - - - - f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00 Remove label style from printing context Previously, the SDocContext used for code generation contained information whether the labels should use Asm or C style. However, at every individual call site, this is known statically. This removes the parameter to 'PprCode' and replaces every 'pdoc' used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'. The OutputableP instance is now used only for dumps. The output of T15155 changes, it now uses the Asm style (which is faithful to what actually happens). - - - - - 1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00 boot: cleanup legacy args Cleanup legacy boot script args, following removal of the legacy make build system. - - - - - 95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00 Improve SpecConstr for evals As #21763 showed, we were over-specialising in some cases, when the function involved was doing a simple 'eval', but not taking the value apart, or branching on it. This MR fixes the problem. See Note [Do not specialise evals]. Nofib barely budges, except that spectral/cichelli allocates about 3% less. Compiler bytes-allocated improves a bit geo. mean -0.1% minimum -0.5% maximum +0.0% The -0.5% is on T11303b, for what it's worth. - - - - - 565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Revert "Revert "Refactor SpecConstr to use treat bindings uniformly"" This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8. This commit was originally reverted due to an increase in space usage. This was diagnosed as because the SCE increased in size and that was being retained by another leak. See #22102 - - - - - 82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Avoid retaining bindings via ModGuts held on the stack It's better to overwrite the bindings fields of the ModGuts before starting an iteration as then all the old bindings can be collected as soon as the simplifier has processed them. Otherwise we end up with the old bindings being alive until right at the end of the simplifier pass as the mg_binds field is only modified right at the end. - - - - - 64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00 Force imposs_deflt_cons in filterAlts This fixes a pretty serious space leak as the forced thunk would retain `Alt b` values which would then contain reference to a lot of old bindings and other simplifier gunk. The OtherCon unfolding was not forced on subsequent simplifier runs so more and more old stuff would be retained until the end of simplification. Fixing this has a drastic effect on maximum residency for the mmark package which goes from ``` 45,005,401,056 bytes allocated in the heap 17,227,721,856 bytes copied during GC 818,281,720 bytes maximum residency (33 sample(s)) 9,659,144 bytes maximum slop 2245 MiB total memory in use (0 MB lost due to fragmentation) ``` to ``` 45,039,453,304 bytes allocated in the heap 13,128,181,400 bytes copied during GC 331,546,608 bytes maximum residency (40 sample(s)) 7,471,120 bytes maximum slop 916 MiB total memory in use (0 MB lost due to fragmentation) ``` See #21993 for some more discussion. - - - - - a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Use Solo to avoid retaining the SCE but to avoid performing the substitution The use of Solo here allows us to force the selection into the SCE to obtain the Subst but without forcing the substitution to be applied. The resulting thunk is placed into a lazy field which is rarely forced, so forcing it regresses peformance. - - - - - 161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00 Fix a nasty loop in Tidy As the remarkably-simple #22112 showed, we were making a black hole in the unfolding of a self-recursive binding. Boo! It's a bit tricky. Documented in GHC.Iface.Tidy, Note [tidyTopUnfolding: avoiding black holes] - - - - - 68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnIllegalHsigDefaultMethods TcRnBadGenericMethod TcRnWarningMinimalDefIncomplete TcRnDefaultMethodForPragmaLacksBinding TcRnIgnoreSpecialisePragmaOnDefMethod TcRnBadMethodErr TcRnNoExplicitAssocTypeOrDefaultDeclaration - - - - - cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00 Fix a bug in anyInRnEnvR This bug was a subtle error in anyInRnEnvR, introduced by commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06 Author: Andreas Klebinger <klebinger.andreas at gmx.at> Date: Sat Jul 9 01:19:52 2022 +0200 Rule matching: Don't compute the FVs if we don't look at them. The net result was #22028, where a rewrite rule would wrongly match on a lambda. The fix to that function is easy. - - - - - 0154bc80 by sheaf at 2022-08-30T06:05:41-04:00 Various Hadrian bootstrapping fixes - Don't always produce a distribution archive (#21629) - Use correct executable names for ghc-pkg and hsc2hs on windows (we were missing the .exe file extension) - Fix a bug where we weren't using the right archive format on Windows when unpacking the bootstrap sources. Fixes #21629 - - - - - 451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00 ci: Attempt using normal submodule cloning strategy We do not use any recursively cloned submodules, and this protects us from flaky upstream remotes. Fixes #22121 - - - - - 9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: stray "--" - - - - - 3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: syntatic -> syntactic - - - - - 7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00 Add a missing trimArityType This buglet was exposed by #22114, a consequence of my earlier refactoring of arity for join points. - - - - - e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump binary submodule to 0.8.9.1 - - - - - 4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump stm submodule to 2.5.1.0 - - - - - 837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00 users-guide: Document system-cxx-std-lib - - - - - f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00 Update submodule containers to 0.6.6 - - - - - 4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00 Update submodule process to 1.6.15.0 - - - - - 1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00 Bump directory submodule to 1.3.7.1 - - - - - 7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00 Bump text submodule to 2.0.1 - - - - - fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00 Bump deepseq submodule to 1.4.8.0 - - - - - a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00 Add dates to base, ghc-prim changelogs - - - - - 2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00 Update autoconf scripts Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983 - - - - - e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00 Bump bytestring submodule to 0.11.3.1 - - - - - f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00 Update submodule Cabal to tag Cabal-v3.8.1.0 closes #21931 - - - - - e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00 Refine in-tree compiler args for --test-compiler=stage1 Some of the logic to calculate in-tree arguments was not correct for the stage1 compiler. Namely we were not correctly reporting whether we were building static or dynamic executables and whether debug assertions were enabled. Fixes #22096 - - - - - 6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00 Make ghcDebugAssertions into a Stage predicate (Stage -> Bool) We also care whether we have debug assertions enabled for a stage one compiler, but the way which we turned on the assertions was quite different from the stage2 compiler. This makes the logic for turning on consistent across both and has the advantage of being able to correct determine in in-tree args whether a flavour enables assertions or not. Ticket #22096 - - - - - 15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00 Add regression test for #21550 This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5 "Use local instances with least superclass depth" - - - - - 7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00 Minor cleanup - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused), isCoVar_maybe (duplicated by getCoVar_maybe) - Replace a few occurrences of voidPrimId with (# #). void# is a deprecated synonym for the unboxed tuple. - Use showSDoc in :show linker. This makes it consistent with the other :show commands - - - - - 31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00 Fix bootstrap with ghc-9.0 It turns out Solo is a very recent addition to base, so for older GHC versions we just defined it inline here the one place we use it in the compiler. - - - - - d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00 DmdAnal: Don't panic in addCaseBndrDmd (#22039) Rather conservatively return Top. See Note [Untyped demand on case-alternative binders]. I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and `fieldBndrDmds`. Fixes #22039. - - - - - 25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00 gitlab-ci: Ensure that ghc derivation is in scope Previously the lint-ci job attempted to use cabal-install (specifically `cabal update`) without a GHC in PATH. However, cabal-install-3.8 appears to want GHC, even for `cabal update`. - - - - - f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00 typo - - - - - fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00 typos - - - - - a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00 whitespace - - - - - 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - d6a8c222 by Simon Jakobi at 2022-11-02T16:34:08+00:00 Improve setBit, clearBit, complementBit for Integer Fixes #21176. - - - - - cba25862 by Simon Jakobi at 2022-11-02T16:34:08+00:00 Mark clearBit for Integer and integerClearBit[#] as INLINE This fixes T8832 which previously wasn't able to constant-fold the expression clearBit (bit 0) 0 - - - - - 19 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - + .gitlab/upload_ghc_libs.py - HACKING.md - − MAKEHELP.md - − Makefile - README.md - − appveyor.yml - bindisttest/Makefile - − bindisttest/ghc.mk - boot - compiler/.hlint.yaml - compiler/CodeGen.Platform.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0af06cc81305265363f84e881c9aa1a428c22b24...cba25862cd73fb0512a22c5efee4089aa71ae889 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0af06cc81305265363f84e881c9aa1a428c22b24...cba25862cd73fb0512a22c5efee4089aa71ae889 You're receiving 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 Nov 2 16:38:40 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 02 Nov 2022 12:38:40 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 14 commits: rts: introduce (and use) `STG_NORETURN` Message-ID: <63629d10f2a37_6587e6da2e0877bf@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 7f07ca12 by Ben Gamari at 2022-11-02T12:38:12-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 11736d31 by Matthew Pickering at 2022-11-02T12:38:13-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - ca3171ea by M Farkas-Dyck at 2022-11-02T12:38:21-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - 4e93b329 by Matthew Pickering at 2022-11-02T12:38:22-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 30 changed files: - .gitignore - CODEOWNERS - compiler/GHC/IfaceToCore.hs - compiler/GHC/Unit/Module/WholeCoreBindings.hs - configure.ac - libraries/ghc-prim/GHC/Types.hs - rts/CloneStack.c - rts/Heap.c - rts/Hpc.c - rts/Linker.c - rts/RtsAPI.c - rts/RtsFlags.c - rts/RtsMessages.c - rts/RtsStartup.c - rts/RtsUtils.h - rts/StgCRun.c - rts/include/Rts.h - rts/include/RtsAPI.h - rts/include/Stg.h - rts/include/rts/Main.h - rts/include/rts/Messages.h - rts/include/rts/OSThreads.h - rts/include/rts/Threads.h - rts/linker/Elf.c - rts/linker/M32Alloc.h - rts/linker/elf_reloc_aarch64.c - rts/linker/elf_tlsgd.c - rts/posix/OSThreads.c - rts/posix/Select.c - testsuite/tests/numeric/should_run/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e437f7a106655837139bca37e2a1824fd5178ec0...4e93b329148250427bec52030a78a45d683913d1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e437f7a106655837139bca37e2a1824fd5178ec0...4e93b329148250427bec52030a78a45d683913d1 You're receiving 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 Nov 2 18:05:12 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 02 Nov 2022 14:05:12 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22331 Message-ID: <6362b158aaa2f_11c7e25152c67168@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22331 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22331 You're receiving 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 Nov 2 18:13:19 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Wed, 02 Nov 2022 14:13:19 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/strings-refactor3 Message-ID: <6362b33f4c61f_11c7e24b83472692@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/strings-refactor3 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/strings-refactor3 You're receiving 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 Nov 2 21:54:10 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 02 Nov 2022 17:54:10 -0400 Subject: [Git][ghc/ghc][ghc-9.4] 4 commits: Fix nested type splices in hie files Message-ID: <6362e702b59d2_11c7e2515188907d@gitlab.mail> Ben Gamari pushed to branch ghc-9.4 at Glasgow Haskell Compiler / GHC Commits: edfa9f46 by Matthew Pickering at 2022-11-01T17:46:56-04:00 Fix nested type splices in hie files The issue is that when we compile a typed bracket we replace the splice with HsSpliced (unTypeCode ...). Then when computing types for > [|| T $$(...) ||] GHC is asked to compute the type of `T $$(..)`, which panics because of the bogus type of T applied to `HsSpliced`, which is not type correct. The fix is to not attempt to compute the type for `HsSpliceE` constructors if we come across them as they should have either been already evaluated or lifted into a splice environment. As part of the patch I made hie files traverse into the splice environments so now we also get type information for things used inside nested splices. Fixes #21619 - - - - - 27f5c67e by Alan Zimmerman at 2022-11-01T17:46:56-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 (cherry picked from commit 792ef44d455c6e987f342fb61515464322a9fa77) - - - - - 0633665f by Simon Peyton Jones at 2022-11-01T17:46:56-04:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694 and #21755 * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * I realised that, now we have ae_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. And finally, it was the strange treatment of join-point Ids (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring * Rewrote Note [Combining case branches: optimistic one-shot-ness] Compile time improves slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- CoOpt_Read(normal) ghc/alloc 803,788,056 747,832,680 -7.1% GOOD T18223(normal) ghc/alloc 928,207,320 959,424,016 +3.1% BAD geo. mean -0.3% minimum -7.1% maximum +3.1% On Windows it's a bit better: geo mean is -0.6%, and three more benchmarks trip their compile-time bytes-allocated threshold (they were all close on the other build): T18698b(normal) ghc/alloc 235,619,776 233,219,008 -1.0% GOOD T6048(optasm) ghc/alloc 112,208,192 109,704,936 -2.2% GOOD T18140(normal) ghc/alloc 85,064,192 83,168,360 -2.2% GOOD I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3.4% increase in exchange for goodness elsewhere. Metric Decrease: CoOpt_Read LargeRecord ManyAlternatives ManyConstructors MultiComponentModules MultiComponentModulesRecomp T10421 T12425 T12707 T13035 T13253 T13379 T14683 T15703 T18698a T1969 T3064 T3294 T4801 T5321FD T5321Fun T5631 T783 T9020 T9198 T9233 T9872b T9872c T9961 parsing001 Metric Increase: T18223 (cherry picked from commit 5e282da37e19a1ab24ae167daf32276a64ed2842) - - - - - f4200e22 by Ben Gamari at 2022-11-01T17:49:13-04:00 Bump process submodule to v1.6.16.0 - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Syn/Type.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser/PostProcess.hs - compiler/Language/Haskell/Syntax/Expr.hs - libraries/process - + testsuite/tests/arityanal/should_compile/Arity17.hs - + testsuite/tests/arityanal/should_compile/T21755.hs - + testsuite/tests/arityanal/should_compile/T21755.stderr - testsuite/tests/arityanal/should_compile/all.T - + testsuite/tests/callarity/should_compile/T21694a.hs - + testsuite/tests/callarity/should_compile/T21694a.stderr - testsuite/tests/hiefile/should_compile/all.T - + testsuite/tests/hiefile/should_compile/hie011.hs - + testsuite/tests/hiefile/should_compile/hie011.stderr - + testsuite/tests/hiefile/should_run/SpliceTypes.hs - + testsuite/tests/hiefile/should_run/SpliceTypes.stdout - testsuite/tests/hiefile/should_run/all.T - testsuite/tests/linters/notes.stdout - testsuite/tests/printer/Makefile - + testsuite/tests/printer/Test21805.hs - testsuite/tests/printer/all.T - + testsuite/tests/simplCore/should_compile/T21694b.hs - + testsuite/tests/simplCore/should_compile/T21694b.stderr - utils/check-exact/ExactPrint.hs - utils/check-exact/Main.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c08d9a1b40c8c66a5fdcd6cb1b02b20121c93c4...f4200e2219606e73d051f0e2de98cf75d72bd683 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c08d9a1b40c8c66a5fdcd6cb1b02b20121c93c4...f4200e2219606e73d051f0e2de98cf75d72bd683 You're receiving 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 Nov 2 23:36:23 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Wed, 02 Nov 2022 19:36:23 -0400 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve] WIP. GHC compiles, working on check-exact Message-ID: <6362fef7613ab_11c7e251518949eb@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve at Glasgow Haskell Compiler / GHC Commits: 07a1142e by Alan Zimmerman at 2022-11-02T23:35:50+00:00 WIP. GHC compiles, working on check-exact - - - - - 30 changed files: - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Rule.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Class.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07a1142e3a89805531200e50cca4769fc98e3465 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07a1142e3a89805531200e50cca4769fc98e3465 You're receiving 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 Nov 3 00:45:52 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 02 Nov 2022 20:45:52 -0400 Subject: [Git][ghc/ghc][wip/T22264-9.2] Nonconcurrent sweep Message-ID: <63630f40bbe59_11c7e251540957e1@gitlab.mail> Ben Gamari pushed to branch wip/T22264-9.2 at Glasgow Haskell Compiler / GHC Commits: 4b09bd5b by Ben Gamari at 2022-10-23T00:12:23-04:00 Nonconcurrent sweep - - - - - 1 changed file: - rts/sm/NonMoving.c Changes: ===================================== rts/sm/NonMoving.c ===================================== @@ -29,7 +29,10 @@ #include "Sanity.h" #include "Weak.h" // scheduleFinalizers -#define NONCONCURRENT_SWEEP +#if defined(DEBUG) && defined(THREADED_RTS) +// Enable serial sweeping for ease of debugging +//#define NONCONCURRENT_SWEEP +#endif struct NonmovingHeap nonmovingHeap; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b09bd5bdebe32ce864286f19d6c78f7ebc6faf1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4b09bd5bdebe32ce864286f19d6c78f7ebc6faf1 You're receiving 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 Nov 3 01:04:38 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 02 Nov 2022 21:04:38 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: Hadrian: add useNativeBignum transformer Message-ID: <636313a6dd391_11c7e24b7bc96346@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 93be6a34 by doyougnu at 2022-11-02T11:42:49-04:00 Hadrian: add useNativeBignum transformer - - - - - a0438b57 by doyougnu at 2022-11-02T21:03:22-04:00 Hadrian: add Flavours.JavaScript Better Cohesion. - - - - - 6 changed files: - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Settings.hs - + hadrian/src/Settings/Flavours/JavaScript.hs - hadrian/src/Settings/Flavours/Release.hs - hadrian/src/Way/Type.hs Changes: ===================================== hadrian/hadrian.cabal ===================================== @@ -125,6 +125,7 @@ executable hadrian , Settings.Flavours.Quickest , Settings.Flavours.Validate , Settings.Flavours.Release + , Settings.Flavours.JavaScript , Settings.Packages , Settings.Parser , Settings.Program ===================================== hadrian/src/Flavour.hs ===================================== @@ -16,6 +16,8 @@ module Flavour , disableProfiledLibs , enableLinting , enableHaddock + , useNativeBignum + , omitPragmas , completeSetting , applySettings @@ -51,6 +53,7 @@ flavourTransformers = M.fromList , "profiled_ghc" =: enableProfiledGhc , "no_dynamic_ghc" =: disableDynamicGhcPrograms , "no_dynamic_libs" =: disableDynamicLibs + , "native_bignum" =: useNativeBignum , "no_profiled_libs" =: disableProfiledLibs , "omit_pragmas" =: omitPragmas , "ipe" =: enableIPE @@ -254,6 +257,11 @@ disableProfiledLibs flavour = prune :: Ways -> Ways prune = fmap $ Set.filter (not . wayUnit Profiling) +useNativeBignum :: Flavour -> Flavour +useNativeBignum flavour = + flavour { bignumBackend = "native" + } + -- | Build stage2 compiler with -fomit-interface-pragmas to reduce -- recompilation. omitPragmas :: Flavour -> Flavour ===================================== hadrian/src/Settings.hs ===================================== @@ -23,6 +23,7 @@ import Settings.Flavours.Quickest import Settings.Flavours.QuickCross import Settings.Flavours.Validate import Settings.Flavours.Release +import Settings.Flavours.JavaScript getArgs :: Args @@ -53,7 +54,7 @@ hadrianFlavours :: [Flavour] hadrianFlavours = [ benchmarkFlavour, defaultFlavour, developmentFlavour Stage1 , developmentFlavour Stage2, performanceFlavour - , releaseFlavour + , releaseFlavour, releaseJsFlavour , quickFlavour, quickValidateFlavour, quickDebugFlavour , quickestFlavour , quickCrossFlavour ===================================== hadrian/src/Settings/Flavours/JavaScript.hs ===================================== @@ -0,0 +1,57 @@ +module Settings.Flavours.JavaScript + ( quickJsFlavour + , perfJsFlavour + , releaseJsFlavour + ) where + +import qualified Data.Set as Set + +import Flavour +import Expression +import Settings.Flavours.Performance +import {-# SOURCE #-} Settings.Default + +releaseJsFlavour :: Flavour +releaseJsFlavour = disableDynamicLibs + . disableDynamicGhcPrograms + . disableProfiledLibs + . enableO2Stage0 + . useNativeBignum + $ performanceFlavour { name = "release-js" } + +quickJsFlavour :: Flavour +quickJsFlavour = defaultFlavour + { name = "quick-js" + , args = defaultBuilderArgs <> quickJsArgs <> defaultPackageArgs + , dynamicGhcPrograms = pure False + , libraryWays = pure $ Set.singleton vanilla + , rtsWays = pure $ Set.singleton vanilla + } + +perfJsFlavour :: Flavour +perfJsFlavour = defaultFlavour + { name = "perf-js" + , args = defaultBuilderArgs <> perfJsArgs <> defaultPackageArgs + , dynamicGhcPrograms = pure False + , libraryWays = pure $ Set.singleton vanilla + , rtsWays = pure $ Set.singleton vanilla + } + +quickJsArgs :: Args +quickJsArgs = sourceArgs SourceArgs + { hsDefault = mconcat $ + [ pure ["-O0", "-H64m"] + ] + , hsLibrary = notStage0 ? mconcat [ arg "-O" ] + , hsCompiler = stage0 ? arg "-O2" + , hsGhc = mconcat + [ stage0 ? arg "-O" + , stage1 ? mconcat [ arg "-O0" ] ] } + +perfJsArgs :: Args +perfJsArgs = sourceArgs SourceArgs + { hsDefault = mconcat [ arg "-O2", arg "-H64m"] + , hsLibrary = arg "-O2" + , hsCompiler = arg "-O2" + , hsGhc = arg "-O2" + } ===================================== hadrian/src/Settings/Flavours/Release.hs ===================================== @@ -5,10 +5,3 @@ import Flavour releaseFlavour :: Flavour releaseFlavour = enableHaddock performanceFlavour { name = "release" } - -releaseJsFlavour :: Flavour -releaseJsFlavour = disableDynamicLibs - . disableDynamicGhcPrograms - . disableProfiledLibs - . enableO2Stage0 - $ performanceFlavour { name = "release-js" } ===================================== hadrian/src/Way/Type.hs ===================================== @@ -1,5 +1,6 @@ +{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE LambdaCase #-} module Way.Type where import Data.IntSet (IntSet) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2b8b98f8d83b1a7668d83ba4692fc5b4846d037e...a0438b5737d48b6ed09db2b134a0905c2a2e0e27 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2b8b98f8d83b1a7668d83ba4692fc5b4846d037e...a0438b5737d48b6ed09db2b134a0905c2a2e0e27 You're receiving 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 Nov 3 01:11:38 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Wed, 02 Nov 2022 21:11:38 -0400 Subject: [Git][ghc/ghc][wip/js-staging] fixup: forgot to remove now duplicate flavours Message-ID: <6363154a6f167_11c7e24b83496526@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 7d62ae49 by doyougnu at 2022-11-02T21:10:52-04:00 fixup: forgot to remove now duplicate flavours - - - - - 2 changed files: - hadrian/src/Settings/Flavours/QuickCross.hs - hadrian/src/Way/Type.hs Changes: ===================================== hadrian/src/Settings/Flavours/QuickCross.hs ===================================== @@ -1,4 +1,4 @@ -module Settings.Flavours.QuickCross (quickCrossFlavour, quickJsFlavour, perfJsFlavour) where +module Settings.Flavours.QuickCross (quickCrossFlavour) where import qualified Data.Set as Set @@ -7,43 +7,6 @@ import Flavour import Oracles.Flag import {-# SOURCE #-} Settings.Default -quickJsFlavour :: Flavour -quickJsFlavour = defaultFlavour - { name = "quick-js" - , args = defaultBuilderArgs <> quickJsArgs <> defaultPackageArgs - , dynamicGhcPrograms = pure False - , libraryWays = pure $ Set.singleton vanilla - , rtsWays = pure $ Set.singleton vanilla - } - -perfJsFlavour :: Flavour -perfJsFlavour = defaultFlavour - { name = "perf-js" - , args = defaultBuilderArgs <> perfJsArgs <> defaultPackageArgs - , dynamicGhcPrograms = pure False - , libraryWays = pure $ Set.singleton vanilla - , rtsWays = pure $ Set.singleton vanilla - } - -quickJsArgs :: Args -quickJsArgs = sourceArgs SourceArgs - { hsDefault = mconcat $ - [ pure ["-O0", "-H64m"] - ] - , hsLibrary = notStage0 ? mconcat [ arg "-O" ] - , hsCompiler = stage0 ? arg "-O2" - , hsGhc = mconcat - [ stage0 ? arg "-O" - , stage1 ? mconcat [ arg "-O0" ] ] } - -perfJsArgs :: Args -perfJsArgs = sourceArgs SourceArgs - { hsDefault = mconcat [ arg "-O2", arg "-H64m"] - , hsLibrary = arg "-O2" - , hsCompiler = arg "-O2" - , hsGhc = arg "-O2" - } - -- Please update doc/flavours.md when changing this file. quickCrossFlavour :: Flavour quickCrossFlavour = defaultFlavour ===================================== hadrian/src/Way/Type.hs ===================================== @@ -1,6 +1,7 @@ {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} + module Way.Type where import Data.IntSet (IntSet) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d62ae498948dd41d6deba5c78ec642898ecb743 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7d62ae498948dd41d6deba5c78ec642898ecb743 You're receiving 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 Nov 3 01:29:09 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 02 Nov 2022 21:29:09 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] Export pprTrace and friends from GHC.Prelude. Message-ID: <63631965fb9_11c7e2515049697d@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: 85219dd0 by Andreas Klebinger at 2022-11-03T02:26:27+01:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 30 changed files: - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/List/SetOps.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Env.hs - compiler/GHC/HsToCore/Binds.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85219dd0b2060df6bb2cca58d0950839b40cf21d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/85219dd0b2060df6bb2cca58d0950839b40cf21d You're receiving 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 Nov 3 01:32:34 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 02 Nov 2022 21:32:34 -0400 Subject: [Git][ghc/ghc][wip/andreask/ppr_prelude] Export pprTrace and friends from GHC.Prelude. Message-ID: <63631a32d0069_11c7e24b7d09927c@gitlab.mail> Andreas Klebinger pushed to branch wip/andreask/ppr_prelude at Glasgow Haskell Compiler / GHC Commits: dc34a08b by Andreas Klebinger at 2022-11-03T02:29:53+01:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 30 changed files: - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/List/SetOps.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Env.hs - compiler/GHC/HsToCore/Binds.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc34a08ba40d165a9a6609565da67a1f2c503927 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc34a08ba40d165a9a6609565da67a1f2c503927 You're receiving 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 Nov 3 01:39:07 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 02 Nov 2022 21:39:07 -0400 Subject: [Git][ghc/ghc][ghc-9.4] Revert "base: Move CString, CStringLen to GHC.Foreign" Message-ID: <63631bbb70580_11c7e251504100242@gitlab.mail> Ben Gamari pushed to branch ghc-9.4 at Glasgow Haskell Compiler / GHC Commits: 8f8dba01 by Ben Gamari at 2022-11-02T21:38:59-04:00 Revert "base: Move CString, CStringLen to GHC.Foreign" This reverts commit 5ec22f0135483ea8a8a543c53dcc7f9d7f6a8dea. - - - - - 2 changed files: - libraries/base/Foreign/C/String.hs - libraries/base/GHC/Foreign.hs Changes: ===================================== libraries/base/Foreign/C/String.hs ===================================== @@ -110,11 +110,20 @@ import GHC.Base import {-# SOURCE #-} GHC.IO.Encoding import qualified GHC.Foreign as GHC -import GHC.Foreign (CString, CStringLen) ----------------------------------------------------------------------------- -- Strings +-- representation of strings in C +-- ------------------------------ + +-- | A C string is a reference to an array of C characters terminated by NUL. +type CString = Ptr CChar + +-- | A string with explicit length information in bytes instead of a +-- terminating NUL (allowing NUL characters in the middle of the string). +type CStringLen = (Ptr CChar, Int) + -- exported functions -- ------------------ -- ===================================== libraries/base/GHC/Foreign.hs ===================================== @@ -19,7 +19,6 @@ module GHC.Foreign ( -- * C strings with a configurable encoding - CString, CStringLen, -- conversion of C strings into Haskell strings -- @@ -75,11 +74,8 @@ putDebugMsg | c_DEBUG_DUMP = debugLn | otherwise = const (return ()) --- | A C string is a reference to an array of C characters terminated by NUL. +-- These definitions are identical to those in Foreign.C.String, but copied in here to avoid a cycle: type CString = Ptr CChar - --- | A string with explicit length information in bytes instead of a --- terminating NUL (allowing NUL characters in the middle of the string). type CStringLen = (Ptr CChar, Int) -- exported functions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f8dba0190fe2a3a8b148fecf0dc83a725fb3fd2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f8dba0190fe2a3a8b148fecf0dc83a725fb3fd2 You're receiving 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 Nov 3 02:29:10 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 02 Nov 2022 22:29:10 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: gen-dll: Drop it Message-ID: <63632776da408_11c7e24b8201135d2@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f3bfae1e by Ben Gamari at 2022-11-02T22:28:41-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 7b2cb728 by Matthew Pickering at 2022-11-02T22:28:42-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - 310bb412 by M Farkas-Dyck at 2022-11-02T22:28:47-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - cca72802 by Matthew Pickering at 2022-11-02T22:28:47-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 11 changed files: - .gitignore - CODEOWNERS - compiler/GHC/IfaceToCore.hs - compiler/GHC/Unit/Module/WholeCoreBindings.hs - configure.ac - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/numeric/should_run/foundation.hs - + testsuite/tests/numeric/should_run/foundation.stdout - − utils/gen-dll/Main.hs - − utils/gen-dll/Makefile - − utils/gen-dll/gen-dll.cabal.in Changes: ===================================== .gitignore ===================================== @@ -17,6 +17,8 @@ Thumbs.db *.hi *.hi-boot +*.hie +*.hie-boot *.o-boot *.p_o *.t_o ===================================== CODEOWNERS ===================================== @@ -59,7 +59,6 @@ /libraries/libiserv/ @angerman @simonmar /utils/iserv-proxy/ @angerman @simonmar /utils/iserv/ @angerman @simonmar -/utils/gen-dll/ @Phyx /utils/fs/ @Phyx [WinIO related code] ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -240,9 +240,9 @@ typecheckIface iface } typecheckWholeCoreBindings :: IORef TypeEnv -> WholeCoreBindings -> IfG [CoreBind] -typecheckWholeCoreBindings type_var (WholeCoreBindings prepd_binding this_mod _) = +typecheckWholeCoreBindings type_var (WholeCoreBindings tidy_bindings this_mod _) = initIfaceLcl this_mod (text "typecheckWholeCoreBindings") NotBoot $ do - tcTopIfaceBindings type_var prepd_binding + tcTopIfaceBindings type_var tidy_bindings {- ===================================== compiler/GHC/Unit/Module/WholeCoreBindings.hs ===================================== @@ -57,7 +57,7 @@ the object files. -} data WholeCoreBindings = WholeCoreBindings - { wcb_bindings :: [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] - , wcb_module :: Module - , wcb_mod_location :: ModLocation + { wcb_bindings :: [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -- ^ serialised tidied core bindings. + , wcb_module :: Module -- ^ The module which the bindings are for + , wcb_mod_location :: ModLocation -- ^ The location where the sources reside. } ===================================== configure.ac ===================================== @@ -1208,7 +1208,6 @@ AC_CONFIG_FILES( utils/iserv/iserv.cabal utils/ghc-pkg/ghc-pkg.cabal utils/remote-iserv/remote-iserv.cabal - utils/gen-dll/gen-dll.cabal libraries/ghc-boot/ghc-boot.cabal libraries/ghc-boot-th/ghc-boot-th.cabal libraries/ghci/ghci.cabal ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -79,3 +79,4 @@ test('IntegerToFloat', normal, compile_and_run, ['']) test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) +test('foundation', normal, compile_and_run, ['-O -package transformers']) ===================================== testsuite/tests/numeric/should_run/foundation.hs ===================================== @@ -0,0 +1,297 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE RecordWildCards #-} +module Main + ( main + ) where + +import Data.Word +import Data.Int +import GHC.Natural +import Data.Typeable +import Data.Proxy +import GHC.Int +import GHC.Word +import Data.Function +import GHC.Prim +import Control.Monad.Reader +import System.IO +import Foreign.Marshal.Alloc +import Foreign.Storable +import Foreign.Ptr +import Data.List (intercalate) +import Data.IORef +import Unsafe.Coerce + +#include "MachDeps.h" + +newtype Gen a = Gen { runGen :: (ReaderT LCGGen IO a) } + deriving newtype (Functor, Applicative, Monad) + +class Arbitrary a where + arbitrary :: Gen a + +class IsProperty p where + property :: p -> Property + +data PropertyCheck = PropertyBinaryOp Bool String String String + | PropertyAnd PropertyCheck PropertyCheck + +instance IsProperty PropertyCheck where + property check = Prop $ pure (PropertyEOA check) + +data PropertyTestArg = PropertyEOA PropertyCheck + | PropertyArg String PropertyTestArg + +getCheck :: PropertyTestArg -> ([String], PropertyCheck) +getCheck (PropertyEOA pc) = ([], pc) +getCheck (PropertyArg s pta ) = let (ss, pc) = getCheck pta in (s:ss, pc) + +data Property = Prop { unProp :: Gen PropertyTestArg } + +instance (Show a, Arbitrary a, IsProperty prop) => IsProperty (a -> prop) where + property p = forAll arbitrary p + +-- | Running a generator for a specific type under a property +forAll :: (Show a, IsProperty prop) => Gen a -> (a -> prop) -> Property +forAll generator tst = Prop $ do + a <- generator + augment a <$> unProp (property (tst a)) + where + augment a arg = PropertyArg (show a) arg + +-- | A property that check for equality of its 2 members. +propertyCompare :: (Show a) => String -> (a -> a -> Bool) -> a -> a -> PropertyCheck +propertyCompare s f a b = + let sa = show a + sb = show b + in PropertyBinaryOp (a `f` b) s sa sb + +(===) :: (Show a, Eq a) => a -> a -> PropertyCheck +(===) = propertyCompare "==" (==) +infix 4 === + +propertyAnd = PropertyAnd + + +data Test where + Group :: String -> [Test] -> Test + Property :: IsProperty prop => String -> prop -> Test + + +arbitraryInt64 :: Gen Int64 +arbitraryInt64 = Gen $ do + h <- ask + W64# w <- liftIO (randomWord64 h) + return (I64# (unsafeCoerce# w)) + +integralDownsize :: (Integral a) => Int64 -> a +integralDownsize = fromIntegral + +wordDownsize :: (Integral a) => Word64 -> a +wordDownsize = fromIntegral + +arbitraryWord64 :: Gen Word64 +arbitraryWord64 = Gen $ do + h <- ask + liftIO (randomWord64 h) + +instance Arbitrary Natural where + arbitrary = integralDownsize . (`mod` 10000) . abs <$> arbitraryInt64 + +-- Bounded by Int64 +instance Arbitrary Integer where + arbitrary = fromIntegral <$> arbitraryInt64 + +instance Arbitrary Int where + arbitrary = int64ToInt <$> arbitraryInt64 +instance Arbitrary Word where + arbitrary = word64ToWord <$> arbitraryWord64 +instance Arbitrary Word64 where + arbitrary = arbitraryWord64 +instance Arbitrary Word32 where + arbitrary = wordDownsize <$> arbitraryWord64 +instance Arbitrary Word16 where + arbitrary = wordDownsize <$> arbitraryWord64 +instance Arbitrary Word8 where + arbitrary = wordDownsize <$> arbitraryWord64 +instance Arbitrary Int64 where + arbitrary = arbitraryInt64 +instance Arbitrary Int32 where + arbitrary = integralDownsize <$> arbitraryInt64 +instance Arbitrary Int16 where + arbitrary = integralDownsize <$> arbitraryInt64 +instance Arbitrary Int8 where + arbitrary = integralDownsize <$> arbitraryInt64 + +int64ToInt :: Int64 -> Int +#if WORD_SIZE_IN_BITS == 64 +#if __GLASGOW_HASKELL__ >= 904 +int64ToInt (I64# i) = I# (int64ToInt# i) +#else +int64ToInt (I64# i) = I# i +#endif +#else +int64ToInt (I64# i) = I# (int64ToInt# i) +#endif + + +word64ToWord :: Word64 -> Word +#if WORD_SIZE_IN_BITS == 64 +#if __GLASGOW_HASKELL__ >= 904 +word64ToWord (W64# i) = W# (GHC.Prim.word64ToWord# i) +#else +word64ToWord (W64# i) = W# i +#endif +#else +word64ToWord (W64# i) = W# (word64ToWord# i) +#endif + + +data RunS = RunS { depth :: Int, rg :: LCGGen } + +newtype LCGGen = LCGGen { randomWord64 :: IO Word64 } + +data LCGParams = LCGParams { seed :: Word64, a :: Word64, c :: Word64, m :: Word64 } + +newLCGGen :: LCGParams -> IO LCGGen +newLCGGen LCGParams{..} = do + var <- newIORef (fromIntegral seed) + return $ LCGGen $ do + atomicModifyIORef' var (\old_v -> let new_val = (old_v * a + c) `mod` m in (new_val, new_val)) + + +runPropertyCheck (PropertyBinaryOp res desc s1 s2) = + if res then return True else (putMsg ("Failure: " ++ s1 ++ desc ++ s2) >> return False) +runPropertyCheck (PropertyAnd a1 a2) = (&&) <$> runPropertyCheck a1 <*> runPropertyCheck a2 + +runProperty :: Property -> ReaderT RunS IO () +runProperty (Prop p) = do + let iterations = 100 + loop iterations iterations + where + loop iterations 0 = putMsg ("Passed " ++ show iterations ++ " iterations") + loop iterations n = do + h <- rg <$> ask + p <- liftIO (runReaderT (runGen p) h) + let (ss, pc) = getCheck p + res <- runPropertyCheck pc + if res then loop iterations (n-1) + else putMsg ("With arguments " ++ intercalate ", " ss) + +putMsg s = do + n <- depth <$> ask + liftIO . putStrLn $ replicate (n * 2) ' ' ++ s + +nest = local (\s -> s { depth = depth s + 1 }) + +runTestInternal :: Test -> ReaderT RunS IO () +runTestInternal (Group name tests) = do + putMsg ("Group " ++ name) + nest (mapM_ runTestInternal tests) +runTestInternal (Property name p) = do + putMsg ("Running " ++ name) + nest $ runProperty (property p) + + +runTests :: Test -> IO () +runTests t = do + -- These params are the same ones as glibc uses. + h <- newLCGGen (LCGParams { seed = 1238123213, m = 2^31, a = 1103515245, c = 12345 }) + runReaderT (runTestInternal t) (RunS 0 h) + +------------------------------------------------------------------------------- + +testIntegral :: forall a . (Arbitrary a, Show a, Integral a, Typeable a) + => Proxy a -> Test +testIntegral _ = Group "Integral" + [ Property "FromIntegral(Integer(a)) == a" $ \(a :: a) -> fromInteger (toInteger a) === a + ] + +testEqOrd :: forall a . (Arbitrary a, Show a, Eq a, Ord a, Integral a, Typeable a) + => Proxy a -> Test +testEqOrd _ = Group "Property" + [ Property "Eq" $ \(a :: a) -> a === a + -- , Property "Ne" $ \(a :: a) (b :: a) -> if a === w + , Property "Show" $ \(a :: a) -> show a === show (toInteger a) + , Property "Ord" $ \(a :: a) (b :: a) -> compare a b === (compare `on` toInteger) a b + , Property "<" $ \(a :: a) (b :: a) -> case compare a b of + LT -> propertyCompare "<" (<) a b + GT -> propertyCompare "<" (<) b a + EQ -> propertyCompare "not <" ((not .) . (<)) a b `propertyAnd` + propertyCompare "not <" ((not .) . (<)) b a + ] + +testAdditive :: forall a . (Show a, Eq a, Num a, Arbitrary a, Typeable a) + => Proxy a -> Test +testAdditive _ = Group "Additive" + [ Property "a + azero == a" $ \(a :: a) -> a + 0 === a + , Property "azero + a == a" $ \(a :: a) -> 0 + a === a + , Property "a + b == b + a" $ \(a :: a) (b :: a) -> a + b === b + a + ] + +testMultiplicative :: forall a . (Show a, Eq a, Integral a, Arbitrary a, Typeable a) + => Proxy a -> Test +testMultiplicative _ = Group "Multiplicative" + [ Property "a * 1 == a" $ \(a :: a) -> a * 1 === a + , Property "1 * a == a" $ \(a :: a) -> 1 * a === a + , Property "multiplication commutative" $ \(a :: a) (b :: a) -> a * b === b * a + , Property "a * b == Integer(a) * Integer(b)" $ \(a :: a) (b :: a) -> a * b === fromInteger (toInteger a * toInteger b) + ] + +testDividible :: forall a . (Show a, Eq a, Integral a, Num a, Arbitrary a, Typeable a) + => Proxy a -> Test +testDividible _ = Group "Divisible" + [ Property "(x `div` y) * y + (x `mod` y) == x" $ \(a :: a) b -> + if b == 0 then True === True + else a === (a `div` b) * b + (a `mod` b) + ] + +testOperatorPrecedence :: forall a . (Show a, Eq a, Prelude.Num a, Integral a, Num a, Arbitrary a, Typeable a) + => Proxy a -> Test +testOperatorPrecedence _ = Group "Precedence" + [ Property "+ and - (1)" $ \(a :: a) (b :: a) (c :: a) -> (a + b - c) === ((a + b) - c) + , Property "+ and - (2)" $ \(a :: a) (b :: a) (c :: a) -> (a - b + c) === ((a - b) + c) + , Property "+ and * (1)" $ \(a :: a) (b :: a) (c :: a) -> (a + b * c) === (a + (b * c)) + , Property "+ and * (2)" $ \(a :: a) (b :: a) (c :: a) -> (a * b + c) === ((a * b) + c) + , Property "- and * (1)" $ \(a :: a) (b :: a) (c :: a) -> (a - b * c) === (a - (b * c)) + , Property "- and * (2)" $ \(a :: a) (b :: a) (c :: a) -> (a * b - c) === ((a * b) - c) + , Property "* and ^ (1)" $ \(a :: a) (b :: Natural) (c :: a) -> (a ^ b * c) === ((a ^ b) * c) + , Property "* and ^ (2)" $ \(a :: a) (c :: Natural) (b :: a) -> (a * b ^ c) === (a * (b ^ c)) + ] + + +testNumber :: (Show a, Eq a, Prelude.Num a, Integral a, Num a, Arbitrary a, Typeable a) + => String -> Proxy a -> Test +testNumber name proxy = Group name + [ testIntegral proxy + , testEqOrd proxy + , testAdditive proxy + , testMultiplicative proxy + , testDividible proxy + , testOperatorPrecedence proxy + ] + +testNumberRefs :: Test +testNumberRefs = Group "ALL" + [ testNumber "Int" (Proxy :: Proxy Int) + , testNumber "Int8" (Proxy :: Proxy Int8) + , testNumber "Int16" (Proxy :: Proxy Int16) + , testNumber "Int32" (Proxy :: Proxy Int32) + , testNumber "Int64" (Proxy :: Proxy Int64) + , testNumber "Integer" (Proxy :: Proxy Integer) + , testNumber "Word" (Proxy :: Proxy Word) + , testNumber "Word8" (Proxy :: Proxy Word8) + , testNumber "Word16" (Proxy :: Proxy Word16) + , testNumber "Word32" (Proxy :: Proxy Word32) + , testNumber "Word64" (Proxy :: Proxy Word64) + ] + + +main = runTests testNumberRefs + ===================================== testsuite/tests/numeric/should_run/foundation.stdout ===================================== @@ -0,0 +1,540 @@ +Group ALL + Group Int + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Int8 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Int16 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Int32 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Int64 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Integer + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word8 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word16 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word32 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word64 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations ===================================== utils/gen-dll/Main.hs deleted ===================================== @@ -1,509 +0,0 @@ -{-# LANGUAGE Safe #-} -{-# LANGUAGE CPP #-} - -{- - gen-dll is a replacement for dll-split which aims to solve a simple problem - during the building of stage2. The issue is that the PE image format only has - a 16-bit field for the symbol count. This means we can't have more than 2^16-1 - symbols in a single PE file. See #5987. - - gen-dll solves this issue by partitioning the object files in such a way that - a single dll never has more than the allowed amount of symbols. The general - workflow of gen-dll is: - - 1) use nm -g to dump the symbols defined in each object file, from this dump - we collect three key pieces information: - a) the object file the symbol belongs to - b) the symbol's kind (e.g data or function) - c) the symbol name. - - 2) If the amount of symbols is lower than the maximum, we're done and we'll - just link the entire list of symbols and move on. - - If however we have too many symbols we'll partition the symbols using a - per object file granularity. This is because we can't split the content of - an object file. An oc belongs to one and only one image file. - - 3) Once we have the partitioning, we sub partition these into two groups for - each partition: - a) data - b) function - - The reason for this is that data exports are directly accessed, whereas - functions generally go through a trampoline. The trampolines are there to - allow for extra functionality such as delay loading (if requested) and to - cover for memory model changes due to linking all the object code in on - PE image. - - Data is usually accessed direct, so we don't want the trampoline otherwise - extern int foo; - would point to executable code instead of data. - - 4) Once we have everything correctly tagged, the partitions are dumped into a - module definition file (def). Each file is named -pt. - which is also the partitioning scheme used for all other files including - the resulting dlls. - - From the .def file we use genlib to generate an import library. In this - case we generate a GNU style import library See Note [BFD import - library]. - - These import libraries are used to break the cyclic dependencies that may - exist between the symbols due to the random partitioning. e.g. A may - require B, but A and B can be in different dlls. With the import libraries - we promise A that at runtime it'll have B, and vice versa. The Windows - runtime linker and loader will take care of breaking this cycle at runtime. - - 5) Once we have an import library for each partition, we start linking the - final dlls. if e.g. we have 3 dlls, linking dll 1 means passing import - libraries 2 and 3 as an argument to the linking of dll 1. This allows it - to find all symbols since PE image files can't have dangling symbols. - - 6) After creating the dlls the final step is to create one top level import - library that is named after the original dll that we were supposed to link. - - To continue the 3 split example. say we were supposed to make libfoo.dll, - instead we created libfoo-pt1.dll, libfoo-pt2.dll and libfoo-pt3.dll. - Obviously using -lfoo would no longer locate the dlls. - - This is solved by using import libraries again. GNU style import libraries - are just plain AR archives where each object file essentially contains - only 1 symbol and the dll in which to find this symbol. - - A proper linker processes all the object files in this AR file (lld, ld and - ghci do this.) and so while genlib doesn't allow you to create - import libraries with multiple dll pointers, it is trivial to do. - - We use ar to merge together the import libraries into a large complete one. - e.g. libfoo-pt1.dll.a, libfoo-pt2.dll.a and libfoo-pt3.dll.a are merged - into libfoo.dll.a. The name isn't coincidental. On Windows you don't link - directly against a dll, instead you link against an import library that - then tells you how to get to the dll functions. - - In this case by creating a correctly named merged import library we solve - the -lfoo problem. - - In the end we end up with libfoo-pt1.dll, libfoo-pt2.dll and libfoo-pt3.dll - along with libfoo.dll.a. To the rest of the pipeline the split is - completely transparent as -lfoo will just continue to work, and the linker - is responsible for populating the IAT (Import Address Table) with the - actual dlls we need. - - This scheme is fully scalable and will not need manual maintenance or - intervention like dll-split needed. If we ever do switch to compiling using - Microsoft compilers, we need to use a custom tool to modify the PE import - libraries lib.exe creates. This is slightly more work but for now we can just - rely on the GNU import libraries. - - If supported by the stage1 compiler, we'll create dll's which can be used as - SxS assemblies, but in order for us to do so, we have to give GHC some extra - information such as the stable abi name for the dll and the version of the - dll being created. This is purely a deployment thing and does not really - affect the workings of this tool. --} -module Main(main) where - -import Control.Arrow ((***)) -import Control.Monad (when, forM_) -import Control.Exception (bracket) - -import Data.Char (toLower, isSpace) -import Data.List (isPrefixOf, nub, sort, (\\)) -import qualified Data.Map as M (Map(), alter, empty, toList) - -import System.Environment (getArgs) -import System.Exit (ExitCode(..), exitWith) -import System.Directory (findFilesWith, getCurrentDirectory) -import System.FilePath (takeBaseName, takeDirectory, dropExtension, (<.>) - ,takeFileName) -import System.IO (hClose, hGetContents, withFile, IOMode(..), hPutStrLn, openFile) -import System.Process (proc, createProcess_, StdStream (..), CreateProcess(..) - ,waitForProcess) - -import Foreign.C.Types (CInt(..), ) -import Foreign.C.String (withCWString, peekCWString, CWString) -import Foreign.Ptr (Ptr) -import Foreign.Storable (peek) -import Foreign.Marshal.Array (peekArray) -import Foreign.Marshal.Alloc (alloca) - -#if defined(i386_HOST_ARCH) -# define WINDOWS_CCONV stdcall -#elif defined(x86_64_HOST_ARCH) -# define WINDOWS_CCONV ccall -#else -# error Unknown mingw32 arch -#endif - --- Setup some standard program names. -nm :: FilePath -nm = NM_TOOL_BIN - -libexe :: FilePath -libexe = LIB_TOOL_BIN - -genlib :: FilePath -genlib = GENLIB_TOOL_BIN - -ar :: FilePath -ar = AR_TOOL_BIN - --- Technically speaking the limit for the amount of symbols you can have in a --- dll is 2^16-1, however Microsoft's lib.exe for some reason refuses to link --- up to this amount. The reason is likely that it adds some extra symbols in --- the generated dll, such as dllmain etc. So we reserve some space in the --- symbol table to accommodate this. This number is just purely randomly chosen. -#define SYMBOL_PADDING 10 - -usage :: IO () -usage = putStrLn $ unlines [ " -= Split a dll if required and perform the linking =- " - , "" - , " Usage: gen-dll " - , "" - , " Where is one of:" - , " link perform a real link of dll, " - , " arguments: dir distdir way flags libs objs out link_cmd delay name version" - ] - -main :: IO () -main = do - args <- getArgs - if null args - then usage - else case (head args) of - "link" -> let (dir:distdir:way:extra_flags:extra_libs:objs:output: - command:delayed:abi_name:abi_version:_) = tail args - in process_dll_link dir distdir way extra_flags extra_libs - objs output command delayed abi_name - abi_version - _ -> usage - -type Symbol = String -type Symbols = [Symbol] -type SymbolType = Char -data Obj - = Obj { objName :: String - , objCount :: Int - , objItems :: [(SymbolType, Symbol)] - } - deriving Show -type Objs = [Obj] - --- | Create the final DLL by using the provided arguments --- This also creates the resulting special import library. -process_dll_link :: String -- ^ dir - -> String -- ^ distdir - -> String -- ^ way - -> String -- ^ extra flags - -> String -- ^ extra libraries to link - -> String -- ^ object files to link - -> String -- ^ output filename - -> String -- ^ link command - -> String -- ^ create delay load import libs - -> String -- ^ SxS Name - -> String -- ^ SxS version - -> IO () -process_dll_link _dir _distdir _way extra_flags extra_libs objs_files output - link_cmd delay_imp sxs_name sxs_version - = do let base = dropExtension output - -- We need to know how many symbols came from other static archives - -- So take the total number of symbols and remove those we know came - -- from the object files. Use this to lower the max amount of symbols. - -- - -- This granularity is the best we can do without --print-map like info. - raw_exports <- execProg nm Nothing ["-g", "--defined-only", objs_files] - putStrLn $ "Processing symbols.." - - let objs = collectObjs raw_exports - num_sym = foldr (\a b -> b + objCount a) 0 objs - exports = base <.> "lst" - - putStrLn $ "Number of symbols in object files for " ++ output ++ ": " ++ show num_sym - - _ <- withFile exports WriteMode $ \hExports -> - mapM_ (hPutStrLn hExports . unlines . map snd . objItems) objs - -#if defined(GEN_SXS) - -- Side-by-Side assembly generation flags for GHC. Pass these along so the DLLs - -- get the proper manifests generated. - let sxs_opts = [ "-fgen-sxs-assembly" - , "-dylib-abi-name" - , show sxs_name - , "-dylib-abi-version" - , show sxs_version - ] -#else - let sxs_opts = [] -#endif - - -- Now check that the DLL doesn't have too many symbols. See trac #5987. - case num_sym > dll_max_symbols of - False -> do putStrLn $ "DLL " ++ output ++ " OK, no need to split." - let defFile = base <.> "def" - dll_import = base <.> "dll.a" - - build_import_lib base (takeFileName output) defFile objs - - _ <- execProg link_cmd Nothing - $ concat [[objs_files - ,extra_libs - ,extra_flags - ] - ,sxs_opts - ,["-fno-shared-implib" - ,"-optl-Wl,--retain-symbols-file=" ++ exports - ,"-o" - ,output - ] - ] - - build_delay_import_lib defFile dll_import delay_imp - - True -> do putStrLn $ "Too many symbols for a single DLL " ++ output - putStrLn "We'll have to split the dll..." - putStrLn $ "OK, we only have space for " - ++ show dll_max_symbols - ++ " symbols from object files when building " - ++ output - - -- First split the dlls up by whole object files - -- To do this, we iterate over all object file and - -- generate a the partitions based on allowing a - -- maximum of $DLL_MAX_SYMBOLS in one DLL. - let spl_objs = groupObjs objs - n_spl_objs = length spl_objs - base' = base ++ "-pt" - - mapM_ (\(n, _) -> putStrLn $ ">> DLL split at " ++ show n ++ " symbols.") spl_objs - putStrLn $ "OK, based on the amount of symbols we'll split the DLL into " ++ show n_spl_objs ++ " pieces." - - -- Start off by creating the import libraries to break the - -- mutual dependency chain. - forM_ (zip [(1::Int)..] spl_objs) $ \(i, (n, o)) -> - do putStrLn $ "Processing file " ++ show i ++ " of " - ++ show n_spl_objs ++ " with " ++ show n - ++ " symbols." - let base_pt = base' ++ show i - file = base_pt <.> "def" - dll = base_pt <.> "dll" - lst = base_pt <.> "lst" - - _ <- withFile lst WriteMode $ \hExports -> - mapM_ (hPutStrLn hExports . unlines . map snd . objItems) o - - build_import_lib base_pt (takeFileName dll) file o - - -- Now create the actual DLLs by using the import libraries - -- to break the mutual recursion. - forM_ (zip [1..] spl_objs) $ \(i, (n, _)) -> - do putStrLn $ "Creating DLL " ++ show i ++ " of " - ++ show n_spl_objs ++ " with " ++ show n - ++ " symbols." - let base_pt = base' ++ show i - file = base_pt <.> "def" - dll = base_pt <.> "dll" - lst = base_pt <.> "lst" - imp_lib = base_pt <.> "dll.a" - indexes = [1..(length spl_objs)]\\[i] - libs = map (\ix -> (base' ++ show ix) <.> "dll.a") indexes - - _ <- execProg link_cmd Nothing - $ concat [[objs_files - ,extra_libs - ,extra_flags - ,file - ] - ,libs - ,sxs_opts - ,["-fno-shared-implib" - ,"-optl-Wl,--retain-symbols-file=" ++ lst - ,"-o" - ,dll - ] - ] - - -- build_delay_import_lib file imp_lib delay_imp - putStrLn $ "Created " ++ dll ++ "." - - -- And finally, merge the individual import libraries into - -- one with the name of the original library we were - -- supposed to make. This means that nothing has to really - -- know how we split up the DLLs, for everything else it'so - -- as if it's still one large assembly. - create_merged_archive base base' (length spl_objs) - - -collectObjs :: [String] -> Objs -collectObjs = map snd . M.toList . foldr collectObjs' M.empty - -collectObjs' :: String -> M.Map String Obj -> M.Map String Obj -collectObjs' [] m = m -collectObjs' str_in m - = let clean = dropWhile isSpace - str = clean str_in - (file, rest) = ((takeWhile (/=':') . clean) *** clean) $ - break isSpace str - (typ , sym ) = (id *** clean) $ break isSpace rest - obj = Obj { objName = file - , objCount = 1 - , objItems = [(head typ, sym)] - } - upd value - = if length typ /= 1 - then value - else Just $ maybe obj - (\o -> o { objCount = objCount o + 1 - , objItems = (head typ, sym) : objItems o - }) - value - in M.alter upd file m - --- Split a list of objects into globals and functions -splitObjs :: Objs -> (Symbols, Symbols) -splitObjs [] = ([], []) -splitObjs (y:ys) = group_ (objItems y) (splitObjs ys) - where globals = "DdGgrRSsbBC" - group_ :: [(Char, Symbol)] -> (Symbols, Symbols) -> (Symbols, Symbols) - group_ [] x = x - group_ (x:xs) (g, f) | fst x `elem` globals = group_ xs (snd x:g, f) - | otherwise = group_ xs (g, snd x:f) - --- Determine how to split the objects up. -groupObjs :: Objs -> [(Int, Objs)] -groupObjs = binObjs 0 [] - where binObjs :: Int -> Objs -> Objs -> [(Int, Objs)] - binObjs n l [] = [(n, l)] - binObjs n l (o:os) - = let nx = objCount o - n' = n + nx - in if n' > dll_max_symbols - then (n, l) : binObjs 0 [] os - else binObjs n' (o:l) os - --- Maximum number of symbols to allow into --- one DLL. This is the split factor used. -dll_max_symbols :: Int -dll_max_symbols = 65535 - SYMBOL_PADDING -- Some padding for required symbols. - -isTrue :: String -> Bool -isTrue s = let s' = map toLower s - in case () of - () | s' == "yes" -> True - | s' == "no" -> False - | otherwise -> error $ "Expected yes/no but got '" ++ s ++ "'" - -foreign import WINDOWS_CCONV unsafe "Shellapi.h CommandLineToArgvW" - c_CommandLineToArgvW :: CWString -> Ptr CInt -> IO (Ptr CWString) - -foreign import WINDOWS_CCONV unsafe "windows.h LocalFree" - localFree :: Ptr a -> IO (Ptr a) - -mkArgs :: String -> IO [String] -mkArgs [] = return [] -mkArgs arg = - do withCWString arg $ \c_arg -> do - alloca $ \c_size -> do - res <- c_CommandLineToArgvW c_arg c_size - size <- peek c_size - args <- peekArray (fromIntegral size) res - values <- mapM peekCWString args - _ <- localFree res - return values - -execProg :: String -> Maybe FilePath -> [String] -> IO [String] -execProg prog m_stdin args = - do args' <- fmap concat $ mapM mkArgs args - prog' <- mkArgs prog - let full@(c_prog:c_args) = prog' ++ args' - -- print the commands we're executing for debugging and transparency - putStrLn $ unwords $ full ++ [maybe "" ("< " ++) m_stdin] - cwdir <- getCurrentDirectory - let cp = (proc c_prog c_args) - { std_out = CreatePipe, cwd = Just cwdir } - cp' <- case m_stdin of - Nothing -> return cp - Just path -> do h <- openFile path ReadMode - return cp{ std_in = UseHandle h} - bracket - (createProcess_ ("execProg: " ++ prog) cp') - (\(_, Just hout, _, ph) -> do - hClose hout - code <- waitForProcess ph - case std_in cp' of - UseHandle h -> hClose h - _ -> return () - case code of - ExitFailure _ -> exitWith code - ExitSuccess -> return ()) - (\(_, Just hout, _, _) -> do - results <- hGetContents hout - length results `seq` return $ lines results) - --- | Mingw-w64's genlib.exe is generally a few order of magnitudes faster than --- libtool which is BFD based. We used to support both but the libtool path --- would literally require fractions of hours to finish so we dropped it in the --- name of consistency and simplicity. -execLibTool :: String -> String -> IO [String] -execLibTool input_def output_lib - = execProg genlib Nothing [input_def, "-o", output_lib] - --- Builds a delay import lib at the very end which is used to --- be able to delay the picking of a DLL on Windows. --- This function is called always and decided internally --- what to do. -build_delay_import_lib :: String -- ^ input def file - -> String -- ^ output import delayed import lib - -> String -- ^ flag to indicate if delay import - -- lib should be created - -> IO () -build_delay_import_lib input_def output_lib create_delayed - = when (isTrue create_delayed) $ - execLibTool input_def output_lib >> return () - --- Build a normal import library from the object file definitions -build_import_lib :: FilePath -> FilePath -> FilePath -> Objs -> IO () -build_import_lib base dll_name defFile objs - = do -- Create a def file hiding symbols not in original object files - -- because --export-all is re-exporting things from static libs - -- we need to separate out data from functions. So first create two temporaries - let (globals, functions) = splitObjs objs - - -- This split is important because for DATA entries the compiler should not generate - -- a trampoline since CONST DATA is directly referenced and not executed. This is not very - -- important for mingw-w64 which would generate both the trampoline and direct reference - -- by default, but nevertheless for mingw-w64 we can trim the output. - _ <- withFile defFile WriteMode $ \hDef -> do - hPutStrLn hDef $ unlines $ ["LIBRARY " ++ show dll_name - ,"EXPORTS" - ] - mapM_ (\v -> hPutStrLn hDef $ " " ++ show v ++ " DATA") globals - mapM_ (\v -> hPutStrLn hDef $ " " ++ show v ) functions - - let dll_import = base <.> "dll.a" - _ <- execLibTool defFile dll_import - return () - --- Do some cleanup and create merged lib. --- Because we have no split the DLL we need --- to provide a way for the linker to know about the split --- DLL. Also the compile was supposed to produce a DLL --- foo.dll and import library foo.lib. However we've actually --- produced foo-pt1.dll, foo-pt2.dll etc. What we don't want is to have --- To somehow convey back to the compiler that we split the DLL in x pieces --- as this would require a lot of changes. --- --- Instead we produce a merged import library which contains the union of --- all the import libraries produced. This works because import libraries contain --- only .idata section which point to the right dlls. So LD will do the right thing. --- And this means we don't have to do any special handling for the rest of the pipeline. -create_merged_archive :: FilePath -> String -> Int -> IO () -create_merged_archive base prefix count - = do let ar_script = base <.> "mri" - imp_lib = base <.> "dll.a" - imp_libs = map (\i -> prefix ++ show i <.> "dll.a") [1..count] - let script = [ "create " ++ imp_lib ] ++ - map ("addlib " ++) imp_libs ++ - [ "save", "end" ] - writeFile ar_script (unlines script) - _ <- execProg ar (Just ar_script) ["-M"] - return () ===================================== utils/gen-dll/Makefile deleted ===================================== @@ -1,15 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2009 The University of Glasgow -# -# This file is part of the GHC build system. -# -# To understand how the build system works and how to modify it, see -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -dir = utils/gen-dll -TOP = ../.. -include $(TOP)/mk/sub-makefile.mk ===================================== utils/gen-dll/gen-dll.cabal.in deleted ===================================== @@ -1,36 +0,0 @@ --- WARNING: gen-dll.cabal is automatically generated from gen-dll.cabal.in by --- ./configure. Make sure you are editing gen-dll.cabal.in, not gen-dll.cabal. - -Name: gen-dll -Version: 0.1 -Copyright: XXX -License: BSD3 --- XXX License-File: LICENSE -Maintainer: ghc-devs at haskell.org -author: Tamar Christina -Synopsis: Generate GHC core boot library dlls -Description: - This package is responsible for building DLLs that are delay loaded and - create optimized import libraries that can be used to delay load DLLs. - Particularly the RTS. This allows us to delay the loading of the DLL while - still having const data imports work. It also allows us to work around - certain dlltool limitations and the very slow BFD import lib implementation. - -build-type: Simple -cabal-version: >=1.10 - -Executable gen-dll - Default-Language: Haskell2010 - Main-Is: Main.hs - Build-Depends: base >= 3 && < 5 , - pretty >= 1.1 && < 1.2, - process >= 1.2 && < 1.9, - filepath >= 1.3 && < 1.5, - directory >= 1.1 && < 1.4, - containers >= 0.5 && < 0.7 - Extra-Libraries: Shell32 - ghc-options: -UGEN_SXS - -DHAS_GENLIB=@HAVE_GENLIB@ - -DNM_TOOL_BIN="\"@NmCmd@\"" - -DGENLIB_TOOL_BIN="\"@GenlibCmd@\"" - -DAR_TOOL_BIN="\"@ArCmd@\"" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e93b329148250427bec52030a78a45d683913d1...cca7280205f195900cf3fb9d3170cb832b359250 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e93b329148250427bec52030a78a45d683913d1...cca7280205f195900cf3fb9d3170cb832b359250 You're receiving 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 Nov 3 05:59:13 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 03 Nov 2022 01:59:13 -0400 Subject: [Git][ghc/ghc][master] gen-dll: Drop it Message-ID: <636358b19b0ab_11c7e24b7bc133376@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 5 changed files: - CODEOWNERS - configure.ac - − utils/gen-dll/Main.hs - − utils/gen-dll/Makefile - − utils/gen-dll/gen-dll.cabal.in Changes: ===================================== CODEOWNERS ===================================== @@ -59,7 +59,6 @@ /libraries/libiserv/ @angerman @simonmar /utils/iserv-proxy/ @angerman @simonmar /utils/iserv/ @angerman @simonmar -/utils/gen-dll/ @Phyx /utils/fs/ @Phyx [WinIO related code] ===================================== configure.ac ===================================== @@ -1208,7 +1208,6 @@ AC_CONFIG_FILES( utils/iserv/iserv.cabal utils/ghc-pkg/ghc-pkg.cabal utils/remote-iserv/remote-iserv.cabal - utils/gen-dll/gen-dll.cabal libraries/ghc-boot/ghc-boot.cabal libraries/ghc-boot-th/ghc-boot-th.cabal libraries/ghci/ghci.cabal ===================================== utils/gen-dll/Main.hs deleted ===================================== @@ -1,509 +0,0 @@ -{-# LANGUAGE Safe #-} -{-# LANGUAGE CPP #-} - -{- - gen-dll is a replacement for dll-split which aims to solve a simple problem - during the building of stage2. The issue is that the PE image format only has - a 16-bit field for the symbol count. This means we can't have more than 2^16-1 - symbols in a single PE file. See #5987. - - gen-dll solves this issue by partitioning the object files in such a way that - a single dll never has more than the allowed amount of symbols. The general - workflow of gen-dll is: - - 1) use nm -g to dump the symbols defined in each object file, from this dump - we collect three key pieces information: - a) the object file the symbol belongs to - b) the symbol's kind (e.g data or function) - c) the symbol name. - - 2) If the amount of symbols is lower than the maximum, we're done and we'll - just link the entire list of symbols and move on. - - If however we have too many symbols we'll partition the symbols using a - per object file granularity. This is because we can't split the content of - an object file. An oc belongs to one and only one image file. - - 3) Once we have the partitioning, we sub partition these into two groups for - each partition: - a) data - b) function - - The reason for this is that data exports are directly accessed, whereas - functions generally go through a trampoline. The trampolines are there to - allow for extra functionality such as delay loading (if requested) and to - cover for memory model changes due to linking all the object code in on - PE image. - - Data is usually accessed direct, so we don't want the trampoline otherwise - extern int foo; - would point to executable code instead of data. - - 4) Once we have everything correctly tagged, the partitions are dumped into a - module definition file (def). Each file is named -pt. - which is also the partitioning scheme used for all other files including - the resulting dlls. - - From the .def file we use genlib to generate an import library. In this - case we generate a GNU style import library See Note [BFD import - library]. - - These import libraries are used to break the cyclic dependencies that may - exist between the symbols due to the random partitioning. e.g. A may - require B, but A and B can be in different dlls. With the import libraries - we promise A that at runtime it'll have B, and vice versa. The Windows - runtime linker and loader will take care of breaking this cycle at runtime. - - 5) Once we have an import library for each partition, we start linking the - final dlls. if e.g. we have 3 dlls, linking dll 1 means passing import - libraries 2 and 3 as an argument to the linking of dll 1. This allows it - to find all symbols since PE image files can't have dangling symbols. - - 6) After creating the dlls the final step is to create one top level import - library that is named after the original dll that we were supposed to link. - - To continue the 3 split example. say we were supposed to make libfoo.dll, - instead we created libfoo-pt1.dll, libfoo-pt2.dll and libfoo-pt3.dll. - Obviously using -lfoo would no longer locate the dlls. - - This is solved by using import libraries again. GNU style import libraries - are just plain AR archives where each object file essentially contains - only 1 symbol and the dll in which to find this symbol. - - A proper linker processes all the object files in this AR file (lld, ld and - ghci do this.) and so while genlib doesn't allow you to create - import libraries with multiple dll pointers, it is trivial to do. - - We use ar to merge together the import libraries into a large complete one. - e.g. libfoo-pt1.dll.a, libfoo-pt2.dll.a and libfoo-pt3.dll.a are merged - into libfoo.dll.a. The name isn't coincidental. On Windows you don't link - directly against a dll, instead you link against an import library that - then tells you how to get to the dll functions. - - In this case by creating a correctly named merged import library we solve - the -lfoo problem. - - In the end we end up with libfoo-pt1.dll, libfoo-pt2.dll and libfoo-pt3.dll - along with libfoo.dll.a. To the rest of the pipeline the split is - completely transparent as -lfoo will just continue to work, and the linker - is responsible for populating the IAT (Import Address Table) with the - actual dlls we need. - - This scheme is fully scalable and will not need manual maintenance or - intervention like dll-split needed. If we ever do switch to compiling using - Microsoft compilers, we need to use a custom tool to modify the PE import - libraries lib.exe creates. This is slightly more work but for now we can just - rely on the GNU import libraries. - - If supported by the stage1 compiler, we'll create dll's which can be used as - SxS assemblies, but in order for us to do so, we have to give GHC some extra - information such as the stable abi name for the dll and the version of the - dll being created. This is purely a deployment thing and does not really - affect the workings of this tool. --} -module Main(main) where - -import Control.Arrow ((***)) -import Control.Monad (when, forM_) -import Control.Exception (bracket) - -import Data.Char (toLower, isSpace) -import Data.List (isPrefixOf, nub, sort, (\\)) -import qualified Data.Map as M (Map(), alter, empty, toList) - -import System.Environment (getArgs) -import System.Exit (ExitCode(..), exitWith) -import System.Directory (findFilesWith, getCurrentDirectory) -import System.FilePath (takeBaseName, takeDirectory, dropExtension, (<.>) - ,takeFileName) -import System.IO (hClose, hGetContents, withFile, IOMode(..), hPutStrLn, openFile) -import System.Process (proc, createProcess_, StdStream (..), CreateProcess(..) - ,waitForProcess) - -import Foreign.C.Types (CInt(..), ) -import Foreign.C.String (withCWString, peekCWString, CWString) -import Foreign.Ptr (Ptr) -import Foreign.Storable (peek) -import Foreign.Marshal.Array (peekArray) -import Foreign.Marshal.Alloc (alloca) - -#if defined(i386_HOST_ARCH) -# define WINDOWS_CCONV stdcall -#elif defined(x86_64_HOST_ARCH) -# define WINDOWS_CCONV ccall -#else -# error Unknown mingw32 arch -#endif - --- Setup some standard program names. -nm :: FilePath -nm = NM_TOOL_BIN - -libexe :: FilePath -libexe = LIB_TOOL_BIN - -genlib :: FilePath -genlib = GENLIB_TOOL_BIN - -ar :: FilePath -ar = AR_TOOL_BIN - --- Technically speaking the limit for the amount of symbols you can have in a --- dll is 2^16-1, however Microsoft's lib.exe for some reason refuses to link --- up to this amount. The reason is likely that it adds some extra symbols in --- the generated dll, such as dllmain etc. So we reserve some space in the --- symbol table to accommodate this. This number is just purely randomly chosen. -#define SYMBOL_PADDING 10 - -usage :: IO () -usage = putStrLn $ unlines [ " -= Split a dll if required and perform the linking =- " - , "" - , " Usage: gen-dll " - , "" - , " Where is one of:" - , " link perform a real link of dll, " - , " arguments: dir distdir way flags libs objs out link_cmd delay name version" - ] - -main :: IO () -main = do - args <- getArgs - if null args - then usage - else case (head args) of - "link" -> let (dir:distdir:way:extra_flags:extra_libs:objs:output: - command:delayed:abi_name:abi_version:_) = tail args - in process_dll_link dir distdir way extra_flags extra_libs - objs output command delayed abi_name - abi_version - _ -> usage - -type Symbol = String -type Symbols = [Symbol] -type SymbolType = Char -data Obj - = Obj { objName :: String - , objCount :: Int - , objItems :: [(SymbolType, Symbol)] - } - deriving Show -type Objs = [Obj] - --- | Create the final DLL by using the provided arguments --- This also creates the resulting special import library. -process_dll_link :: String -- ^ dir - -> String -- ^ distdir - -> String -- ^ way - -> String -- ^ extra flags - -> String -- ^ extra libraries to link - -> String -- ^ object files to link - -> String -- ^ output filename - -> String -- ^ link command - -> String -- ^ create delay load import libs - -> String -- ^ SxS Name - -> String -- ^ SxS version - -> IO () -process_dll_link _dir _distdir _way extra_flags extra_libs objs_files output - link_cmd delay_imp sxs_name sxs_version - = do let base = dropExtension output - -- We need to know how many symbols came from other static archives - -- So take the total number of symbols and remove those we know came - -- from the object files. Use this to lower the max amount of symbols. - -- - -- This granularity is the best we can do without --print-map like info. - raw_exports <- execProg nm Nothing ["-g", "--defined-only", objs_files] - putStrLn $ "Processing symbols.." - - let objs = collectObjs raw_exports - num_sym = foldr (\a b -> b + objCount a) 0 objs - exports = base <.> "lst" - - putStrLn $ "Number of symbols in object files for " ++ output ++ ": " ++ show num_sym - - _ <- withFile exports WriteMode $ \hExports -> - mapM_ (hPutStrLn hExports . unlines . map snd . objItems) objs - -#if defined(GEN_SXS) - -- Side-by-Side assembly generation flags for GHC. Pass these along so the DLLs - -- get the proper manifests generated. - let sxs_opts = [ "-fgen-sxs-assembly" - , "-dylib-abi-name" - , show sxs_name - , "-dylib-abi-version" - , show sxs_version - ] -#else - let sxs_opts = [] -#endif - - -- Now check that the DLL doesn't have too many symbols. See trac #5987. - case num_sym > dll_max_symbols of - False -> do putStrLn $ "DLL " ++ output ++ " OK, no need to split." - let defFile = base <.> "def" - dll_import = base <.> "dll.a" - - build_import_lib base (takeFileName output) defFile objs - - _ <- execProg link_cmd Nothing - $ concat [[objs_files - ,extra_libs - ,extra_flags - ] - ,sxs_opts - ,["-fno-shared-implib" - ,"-optl-Wl,--retain-symbols-file=" ++ exports - ,"-o" - ,output - ] - ] - - build_delay_import_lib defFile dll_import delay_imp - - True -> do putStrLn $ "Too many symbols for a single DLL " ++ output - putStrLn "We'll have to split the dll..." - putStrLn $ "OK, we only have space for " - ++ show dll_max_symbols - ++ " symbols from object files when building " - ++ output - - -- First split the dlls up by whole object files - -- To do this, we iterate over all object file and - -- generate a the partitions based on allowing a - -- maximum of $DLL_MAX_SYMBOLS in one DLL. - let spl_objs = groupObjs objs - n_spl_objs = length spl_objs - base' = base ++ "-pt" - - mapM_ (\(n, _) -> putStrLn $ ">> DLL split at " ++ show n ++ " symbols.") spl_objs - putStrLn $ "OK, based on the amount of symbols we'll split the DLL into " ++ show n_spl_objs ++ " pieces." - - -- Start off by creating the import libraries to break the - -- mutual dependency chain. - forM_ (zip [(1::Int)..] spl_objs) $ \(i, (n, o)) -> - do putStrLn $ "Processing file " ++ show i ++ " of " - ++ show n_spl_objs ++ " with " ++ show n - ++ " symbols." - let base_pt = base' ++ show i - file = base_pt <.> "def" - dll = base_pt <.> "dll" - lst = base_pt <.> "lst" - - _ <- withFile lst WriteMode $ \hExports -> - mapM_ (hPutStrLn hExports . unlines . map snd . objItems) o - - build_import_lib base_pt (takeFileName dll) file o - - -- Now create the actual DLLs by using the import libraries - -- to break the mutual recursion. - forM_ (zip [1..] spl_objs) $ \(i, (n, _)) -> - do putStrLn $ "Creating DLL " ++ show i ++ " of " - ++ show n_spl_objs ++ " with " ++ show n - ++ " symbols." - let base_pt = base' ++ show i - file = base_pt <.> "def" - dll = base_pt <.> "dll" - lst = base_pt <.> "lst" - imp_lib = base_pt <.> "dll.a" - indexes = [1..(length spl_objs)]\\[i] - libs = map (\ix -> (base' ++ show ix) <.> "dll.a") indexes - - _ <- execProg link_cmd Nothing - $ concat [[objs_files - ,extra_libs - ,extra_flags - ,file - ] - ,libs - ,sxs_opts - ,["-fno-shared-implib" - ,"-optl-Wl,--retain-symbols-file=" ++ lst - ,"-o" - ,dll - ] - ] - - -- build_delay_import_lib file imp_lib delay_imp - putStrLn $ "Created " ++ dll ++ "." - - -- And finally, merge the individual import libraries into - -- one with the name of the original library we were - -- supposed to make. This means that nothing has to really - -- know how we split up the DLLs, for everything else it'so - -- as if it's still one large assembly. - create_merged_archive base base' (length spl_objs) - - -collectObjs :: [String] -> Objs -collectObjs = map snd . M.toList . foldr collectObjs' M.empty - -collectObjs' :: String -> M.Map String Obj -> M.Map String Obj -collectObjs' [] m = m -collectObjs' str_in m - = let clean = dropWhile isSpace - str = clean str_in - (file, rest) = ((takeWhile (/=':') . clean) *** clean) $ - break isSpace str - (typ , sym ) = (id *** clean) $ break isSpace rest - obj = Obj { objName = file - , objCount = 1 - , objItems = [(head typ, sym)] - } - upd value - = if length typ /= 1 - then value - else Just $ maybe obj - (\o -> o { objCount = objCount o + 1 - , objItems = (head typ, sym) : objItems o - }) - value - in M.alter upd file m - --- Split a list of objects into globals and functions -splitObjs :: Objs -> (Symbols, Symbols) -splitObjs [] = ([], []) -splitObjs (y:ys) = group_ (objItems y) (splitObjs ys) - where globals = "DdGgrRSsbBC" - group_ :: [(Char, Symbol)] -> (Symbols, Symbols) -> (Symbols, Symbols) - group_ [] x = x - group_ (x:xs) (g, f) | fst x `elem` globals = group_ xs (snd x:g, f) - | otherwise = group_ xs (g, snd x:f) - --- Determine how to split the objects up. -groupObjs :: Objs -> [(Int, Objs)] -groupObjs = binObjs 0 [] - where binObjs :: Int -> Objs -> Objs -> [(Int, Objs)] - binObjs n l [] = [(n, l)] - binObjs n l (o:os) - = let nx = objCount o - n' = n + nx - in if n' > dll_max_symbols - then (n, l) : binObjs 0 [] os - else binObjs n' (o:l) os - --- Maximum number of symbols to allow into --- one DLL. This is the split factor used. -dll_max_symbols :: Int -dll_max_symbols = 65535 - SYMBOL_PADDING -- Some padding for required symbols. - -isTrue :: String -> Bool -isTrue s = let s' = map toLower s - in case () of - () | s' == "yes" -> True - | s' == "no" -> False - | otherwise -> error $ "Expected yes/no but got '" ++ s ++ "'" - -foreign import WINDOWS_CCONV unsafe "Shellapi.h CommandLineToArgvW" - c_CommandLineToArgvW :: CWString -> Ptr CInt -> IO (Ptr CWString) - -foreign import WINDOWS_CCONV unsafe "windows.h LocalFree" - localFree :: Ptr a -> IO (Ptr a) - -mkArgs :: String -> IO [String] -mkArgs [] = return [] -mkArgs arg = - do withCWString arg $ \c_arg -> do - alloca $ \c_size -> do - res <- c_CommandLineToArgvW c_arg c_size - size <- peek c_size - args <- peekArray (fromIntegral size) res - values <- mapM peekCWString args - _ <- localFree res - return values - -execProg :: String -> Maybe FilePath -> [String] -> IO [String] -execProg prog m_stdin args = - do args' <- fmap concat $ mapM mkArgs args - prog' <- mkArgs prog - let full@(c_prog:c_args) = prog' ++ args' - -- print the commands we're executing for debugging and transparency - putStrLn $ unwords $ full ++ [maybe "" ("< " ++) m_stdin] - cwdir <- getCurrentDirectory - let cp = (proc c_prog c_args) - { std_out = CreatePipe, cwd = Just cwdir } - cp' <- case m_stdin of - Nothing -> return cp - Just path -> do h <- openFile path ReadMode - return cp{ std_in = UseHandle h} - bracket - (createProcess_ ("execProg: " ++ prog) cp') - (\(_, Just hout, _, ph) -> do - hClose hout - code <- waitForProcess ph - case std_in cp' of - UseHandle h -> hClose h - _ -> return () - case code of - ExitFailure _ -> exitWith code - ExitSuccess -> return ()) - (\(_, Just hout, _, _) -> do - results <- hGetContents hout - length results `seq` return $ lines results) - --- | Mingw-w64's genlib.exe is generally a few order of magnitudes faster than --- libtool which is BFD based. We used to support both but the libtool path --- would literally require fractions of hours to finish so we dropped it in the --- name of consistency and simplicity. -execLibTool :: String -> String -> IO [String] -execLibTool input_def output_lib - = execProg genlib Nothing [input_def, "-o", output_lib] - --- Builds a delay import lib at the very end which is used to --- be able to delay the picking of a DLL on Windows. --- This function is called always and decided internally --- what to do. -build_delay_import_lib :: String -- ^ input def file - -> String -- ^ output import delayed import lib - -> String -- ^ flag to indicate if delay import - -- lib should be created - -> IO () -build_delay_import_lib input_def output_lib create_delayed - = when (isTrue create_delayed) $ - execLibTool input_def output_lib >> return () - --- Build a normal import library from the object file definitions -build_import_lib :: FilePath -> FilePath -> FilePath -> Objs -> IO () -build_import_lib base dll_name defFile objs - = do -- Create a def file hiding symbols not in original object files - -- because --export-all is re-exporting things from static libs - -- we need to separate out data from functions. So first create two temporaries - let (globals, functions) = splitObjs objs - - -- This split is important because for DATA entries the compiler should not generate - -- a trampoline since CONST DATA is directly referenced and not executed. This is not very - -- important for mingw-w64 which would generate both the trampoline and direct reference - -- by default, but nevertheless for mingw-w64 we can trim the output. - _ <- withFile defFile WriteMode $ \hDef -> do - hPutStrLn hDef $ unlines $ ["LIBRARY " ++ show dll_name - ,"EXPORTS" - ] - mapM_ (\v -> hPutStrLn hDef $ " " ++ show v ++ " DATA") globals - mapM_ (\v -> hPutStrLn hDef $ " " ++ show v ) functions - - let dll_import = base <.> "dll.a" - _ <- execLibTool defFile dll_import - return () - --- Do some cleanup and create merged lib. --- Because we have no split the DLL we need --- to provide a way for the linker to know about the split --- DLL. Also the compile was supposed to produce a DLL --- foo.dll and import library foo.lib. However we've actually --- produced foo-pt1.dll, foo-pt2.dll etc. What we don't want is to have --- To somehow convey back to the compiler that we split the DLL in x pieces --- as this would require a lot of changes. --- --- Instead we produce a merged import library which contains the union of --- all the import libraries produced. This works because import libraries contain --- only .idata section which point to the right dlls. So LD will do the right thing. --- And this means we don't have to do any special handling for the rest of the pipeline. -create_merged_archive :: FilePath -> String -> Int -> IO () -create_merged_archive base prefix count - = do let ar_script = base <.> "mri" - imp_lib = base <.> "dll.a" - imp_libs = map (\i -> prefix ++ show i <.> "dll.a") [1..count] - let script = [ "create " ++ imp_lib ] ++ - map ("addlib " ++) imp_libs ++ - [ "save", "end" ] - writeFile ar_script (unlines script) - _ <- execProg ar (Just ar_script) ["-M"] - return () ===================================== utils/gen-dll/Makefile deleted ===================================== @@ -1,15 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2009 The University of Glasgow -# -# This file is part of the GHC build system. -# -# To understand how the build system works and how to modify it, see -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -dir = utils/gen-dll -TOP = ../.. -include $(TOP)/mk/sub-makefile.mk ===================================== utils/gen-dll/gen-dll.cabal.in deleted ===================================== @@ -1,36 +0,0 @@ --- WARNING: gen-dll.cabal is automatically generated from gen-dll.cabal.in by --- ./configure. Make sure you are editing gen-dll.cabal.in, not gen-dll.cabal. - -Name: gen-dll -Version: 0.1 -Copyright: XXX -License: BSD3 --- XXX License-File: LICENSE -Maintainer: ghc-devs at haskell.org -author: Tamar Christina -Synopsis: Generate GHC core boot library dlls -Description: - This package is responsible for building DLLs that are delay loaded and - create optimized import libraries that can be used to delay load DLLs. - Particularly the RTS. This allows us to delay the loading of the DLL while - still having const data imports work. It also allows us to work around - certain dlltool limitations and the very slow BFD import lib implementation. - -build-type: Simple -cabal-version: >=1.10 - -Executable gen-dll - Default-Language: Haskell2010 - Main-Is: Main.hs - Build-Depends: base >= 3 && < 5 , - pretty >= 1.1 && < 1.2, - process >= 1.2 && < 1.9, - filepath >= 1.3 && < 1.5, - directory >= 1.1 && < 1.4, - containers >= 0.5 && < 0.7 - Extra-Libraries: Shell32 - ghc-options: -UGEN_SXS - -DHAS_GENLIB=@HAVE_GENLIB@ - -DNM_TOOL_BIN="\"@NmCmd@\"" - -DGENLIB_TOOL_BIN="\"@GenlibCmd@\"" - -DAR_TOOL_BIN="\"@ArCmd@\"" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/284fd39c33c652c11430770c8bb420bb7af2f4cc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/284fd39c33c652c11430770c8bb420bb7af2f4cc You're receiving 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 Nov 3 05:59:49 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 03 Nov 2022 01:59:49 -0400 Subject: [Git][ghc/ghc][master] Port foundation numeric tests to GHC testsuite Message-ID: <636358d51f992_11c7e24b7bc1372bc@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - 3 changed files: - testsuite/tests/numeric/should_run/all.T - + testsuite/tests/numeric/should_run/foundation.hs - + testsuite/tests/numeric/should_run/foundation.stdout Changes: ===================================== testsuite/tests/numeric/should_run/all.T ===================================== @@ -79,3 +79,4 @@ test('IntegerToFloat', normal, compile_and_run, ['']) test('T20291', normal, compile_and_run, ['']) test('T22282', normal, compile_and_run, ['']) +test('foundation', normal, compile_and_run, ['-O -package transformers']) ===================================== testsuite/tests/numeric/should_run/foundation.hs ===================================== @@ -0,0 +1,297 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE RecordWildCards #-} +module Main + ( main + ) where + +import Data.Word +import Data.Int +import GHC.Natural +import Data.Typeable +import Data.Proxy +import GHC.Int +import GHC.Word +import Data.Function +import GHC.Prim +import Control.Monad.Reader +import System.IO +import Foreign.Marshal.Alloc +import Foreign.Storable +import Foreign.Ptr +import Data.List (intercalate) +import Data.IORef +import Unsafe.Coerce + +#include "MachDeps.h" + +newtype Gen a = Gen { runGen :: (ReaderT LCGGen IO a) } + deriving newtype (Functor, Applicative, Monad) + +class Arbitrary a where + arbitrary :: Gen a + +class IsProperty p where + property :: p -> Property + +data PropertyCheck = PropertyBinaryOp Bool String String String + | PropertyAnd PropertyCheck PropertyCheck + +instance IsProperty PropertyCheck where + property check = Prop $ pure (PropertyEOA check) + +data PropertyTestArg = PropertyEOA PropertyCheck + | PropertyArg String PropertyTestArg + +getCheck :: PropertyTestArg -> ([String], PropertyCheck) +getCheck (PropertyEOA pc) = ([], pc) +getCheck (PropertyArg s pta ) = let (ss, pc) = getCheck pta in (s:ss, pc) + +data Property = Prop { unProp :: Gen PropertyTestArg } + +instance (Show a, Arbitrary a, IsProperty prop) => IsProperty (a -> prop) where + property p = forAll arbitrary p + +-- | Running a generator for a specific type under a property +forAll :: (Show a, IsProperty prop) => Gen a -> (a -> prop) -> Property +forAll generator tst = Prop $ do + a <- generator + augment a <$> unProp (property (tst a)) + where + augment a arg = PropertyArg (show a) arg + +-- | A property that check for equality of its 2 members. +propertyCompare :: (Show a) => String -> (a -> a -> Bool) -> a -> a -> PropertyCheck +propertyCompare s f a b = + let sa = show a + sb = show b + in PropertyBinaryOp (a `f` b) s sa sb + +(===) :: (Show a, Eq a) => a -> a -> PropertyCheck +(===) = propertyCompare "==" (==) +infix 4 === + +propertyAnd = PropertyAnd + + +data Test where + Group :: String -> [Test] -> Test + Property :: IsProperty prop => String -> prop -> Test + + +arbitraryInt64 :: Gen Int64 +arbitraryInt64 = Gen $ do + h <- ask + W64# w <- liftIO (randomWord64 h) + return (I64# (unsafeCoerce# w)) + +integralDownsize :: (Integral a) => Int64 -> a +integralDownsize = fromIntegral + +wordDownsize :: (Integral a) => Word64 -> a +wordDownsize = fromIntegral + +arbitraryWord64 :: Gen Word64 +arbitraryWord64 = Gen $ do + h <- ask + liftIO (randomWord64 h) + +instance Arbitrary Natural where + arbitrary = integralDownsize . (`mod` 10000) . abs <$> arbitraryInt64 + +-- Bounded by Int64 +instance Arbitrary Integer where + arbitrary = fromIntegral <$> arbitraryInt64 + +instance Arbitrary Int where + arbitrary = int64ToInt <$> arbitraryInt64 +instance Arbitrary Word where + arbitrary = word64ToWord <$> arbitraryWord64 +instance Arbitrary Word64 where + arbitrary = arbitraryWord64 +instance Arbitrary Word32 where + arbitrary = wordDownsize <$> arbitraryWord64 +instance Arbitrary Word16 where + arbitrary = wordDownsize <$> arbitraryWord64 +instance Arbitrary Word8 where + arbitrary = wordDownsize <$> arbitraryWord64 +instance Arbitrary Int64 where + arbitrary = arbitraryInt64 +instance Arbitrary Int32 where + arbitrary = integralDownsize <$> arbitraryInt64 +instance Arbitrary Int16 where + arbitrary = integralDownsize <$> arbitraryInt64 +instance Arbitrary Int8 where + arbitrary = integralDownsize <$> arbitraryInt64 + +int64ToInt :: Int64 -> Int +#if WORD_SIZE_IN_BITS == 64 +#if __GLASGOW_HASKELL__ >= 904 +int64ToInt (I64# i) = I# (int64ToInt# i) +#else +int64ToInt (I64# i) = I# i +#endif +#else +int64ToInt (I64# i) = I# (int64ToInt# i) +#endif + + +word64ToWord :: Word64 -> Word +#if WORD_SIZE_IN_BITS == 64 +#if __GLASGOW_HASKELL__ >= 904 +word64ToWord (W64# i) = W# (GHC.Prim.word64ToWord# i) +#else +word64ToWord (W64# i) = W# i +#endif +#else +word64ToWord (W64# i) = W# (word64ToWord# i) +#endif + + +data RunS = RunS { depth :: Int, rg :: LCGGen } + +newtype LCGGen = LCGGen { randomWord64 :: IO Word64 } + +data LCGParams = LCGParams { seed :: Word64, a :: Word64, c :: Word64, m :: Word64 } + +newLCGGen :: LCGParams -> IO LCGGen +newLCGGen LCGParams{..} = do + var <- newIORef (fromIntegral seed) + return $ LCGGen $ do + atomicModifyIORef' var (\old_v -> let new_val = (old_v * a + c) `mod` m in (new_val, new_val)) + + +runPropertyCheck (PropertyBinaryOp res desc s1 s2) = + if res then return True else (putMsg ("Failure: " ++ s1 ++ desc ++ s2) >> return False) +runPropertyCheck (PropertyAnd a1 a2) = (&&) <$> runPropertyCheck a1 <*> runPropertyCheck a2 + +runProperty :: Property -> ReaderT RunS IO () +runProperty (Prop p) = do + let iterations = 100 + loop iterations iterations + where + loop iterations 0 = putMsg ("Passed " ++ show iterations ++ " iterations") + loop iterations n = do + h <- rg <$> ask + p <- liftIO (runReaderT (runGen p) h) + let (ss, pc) = getCheck p + res <- runPropertyCheck pc + if res then loop iterations (n-1) + else putMsg ("With arguments " ++ intercalate ", " ss) + +putMsg s = do + n <- depth <$> ask + liftIO . putStrLn $ replicate (n * 2) ' ' ++ s + +nest = local (\s -> s { depth = depth s + 1 }) + +runTestInternal :: Test -> ReaderT RunS IO () +runTestInternal (Group name tests) = do + putMsg ("Group " ++ name) + nest (mapM_ runTestInternal tests) +runTestInternal (Property name p) = do + putMsg ("Running " ++ name) + nest $ runProperty (property p) + + +runTests :: Test -> IO () +runTests t = do + -- These params are the same ones as glibc uses. + h <- newLCGGen (LCGParams { seed = 1238123213, m = 2^31, a = 1103515245, c = 12345 }) + runReaderT (runTestInternal t) (RunS 0 h) + +------------------------------------------------------------------------------- + +testIntegral :: forall a . (Arbitrary a, Show a, Integral a, Typeable a) + => Proxy a -> Test +testIntegral _ = Group "Integral" + [ Property "FromIntegral(Integer(a)) == a" $ \(a :: a) -> fromInteger (toInteger a) === a + ] + +testEqOrd :: forall a . (Arbitrary a, Show a, Eq a, Ord a, Integral a, Typeable a) + => Proxy a -> Test +testEqOrd _ = Group "Property" + [ Property "Eq" $ \(a :: a) -> a === a + -- , Property "Ne" $ \(a :: a) (b :: a) -> if a === w + , Property "Show" $ \(a :: a) -> show a === show (toInteger a) + , Property "Ord" $ \(a :: a) (b :: a) -> compare a b === (compare `on` toInteger) a b + , Property "<" $ \(a :: a) (b :: a) -> case compare a b of + LT -> propertyCompare "<" (<) a b + GT -> propertyCompare "<" (<) b a + EQ -> propertyCompare "not <" ((not .) . (<)) a b `propertyAnd` + propertyCompare "not <" ((not .) . (<)) b a + ] + +testAdditive :: forall a . (Show a, Eq a, Num a, Arbitrary a, Typeable a) + => Proxy a -> Test +testAdditive _ = Group "Additive" + [ Property "a + azero == a" $ \(a :: a) -> a + 0 === a + , Property "azero + a == a" $ \(a :: a) -> 0 + a === a + , Property "a + b == b + a" $ \(a :: a) (b :: a) -> a + b === b + a + ] + +testMultiplicative :: forall a . (Show a, Eq a, Integral a, Arbitrary a, Typeable a) + => Proxy a -> Test +testMultiplicative _ = Group "Multiplicative" + [ Property "a * 1 == a" $ \(a :: a) -> a * 1 === a + , Property "1 * a == a" $ \(a :: a) -> 1 * a === a + , Property "multiplication commutative" $ \(a :: a) (b :: a) -> a * b === b * a + , Property "a * b == Integer(a) * Integer(b)" $ \(a :: a) (b :: a) -> a * b === fromInteger (toInteger a * toInteger b) + ] + +testDividible :: forall a . (Show a, Eq a, Integral a, Num a, Arbitrary a, Typeable a) + => Proxy a -> Test +testDividible _ = Group "Divisible" + [ Property "(x `div` y) * y + (x `mod` y) == x" $ \(a :: a) b -> + if b == 0 then True === True + else a === (a `div` b) * b + (a `mod` b) + ] + +testOperatorPrecedence :: forall a . (Show a, Eq a, Prelude.Num a, Integral a, Num a, Arbitrary a, Typeable a) + => Proxy a -> Test +testOperatorPrecedence _ = Group "Precedence" + [ Property "+ and - (1)" $ \(a :: a) (b :: a) (c :: a) -> (a + b - c) === ((a + b) - c) + , Property "+ and - (2)" $ \(a :: a) (b :: a) (c :: a) -> (a - b + c) === ((a - b) + c) + , Property "+ and * (1)" $ \(a :: a) (b :: a) (c :: a) -> (a + b * c) === (a + (b * c)) + , Property "+ and * (2)" $ \(a :: a) (b :: a) (c :: a) -> (a * b + c) === ((a * b) + c) + , Property "- and * (1)" $ \(a :: a) (b :: a) (c :: a) -> (a - b * c) === (a - (b * c)) + , Property "- and * (2)" $ \(a :: a) (b :: a) (c :: a) -> (a * b - c) === ((a * b) - c) + , Property "* and ^ (1)" $ \(a :: a) (b :: Natural) (c :: a) -> (a ^ b * c) === ((a ^ b) * c) + , Property "* and ^ (2)" $ \(a :: a) (c :: Natural) (b :: a) -> (a * b ^ c) === (a * (b ^ c)) + ] + + +testNumber :: (Show a, Eq a, Prelude.Num a, Integral a, Num a, Arbitrary a, Typeable a) + => String -> Proxy a -> Test +testNumber name proxy = Group name + [ testIntegral proxy + , testEqOrd proxy + , testAdditive proxy + , testMultiplicative proxy + , testDividible proxy + , testOperatorPrecedence proxy + ] + +testNumberRefs :: Test +testNumberRefs = Group "ALL" + [ testNumber "Int" (Proxy :: Proxy Int) + , testNumber "Int8" (Proxy :: Proxy Int8) + , testNumber "Int16" (Proxy :: Proxy Int16) + , testNumber "Int32" (Proxy :: Proxy Int32) + , testNumber "Int64" (Proxy :: Proxy Int64) + , testNumber "Integer" (Proxy :: Proxy Integer) + , testNumber "Word" (Proxy :: Proxy Word) + , testNumber "Word8" (Proxy :: Proxy Word8) + , testNumber "Word16" (Proxy :: Proxy Word16) + , testNumber "Word32" (Proxy :: Proxy Word32) + , testNumber "Word64" (Proxy :: Proxy Word64) + ] + + +main = runTests testNumberRefs + ===================================== testsuite/tests/numeric/should_run/foundation.stdout ===================================== @@ -0,0 +1,540 @@ +Group ALL + Group Int + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Int8 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Int16 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Int32 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Int64 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Integer + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word8 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word16 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word32 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations + Group Word64 + Group Integral + Running FromIntegral(Integer(a)) == a + Passed 100 iterations + Group Property + Running Eq + Passed 100 iterations + Running Show + Passed 100 iterations + Running Ord + Passed 100 iterations + Running < + Passed 100 iterations + Group Additive + Running a + azero == a + Passed 100 iterations + Running azero + a == a + Passed 100 iterations + Running a + b == b + a + Passed 100 iterations + Group Multiplicative + Running a * 1 == a + Passed 100 iterations + Running 1 * a == a + Passed 100 iterations + Running multiplication commutative + Passed 100 iterations + Running a * b == Integer(a) * Integer(b) + Passed 100 iterations + Group Divisible + Running (x `div` y) * y + (x `mod` y) == x + Passed 100 iterations + Group Precedence + Running + and - (1) + Passed 100 iterations + Running + and - (2) + Passed 100 iterations + Running + and * (1) + Passed 100 iterations + Running + and * (2) + Passed 100 iterations + Running - and * (1) + Passed 100 iterations + Running - and * (2) + Passed 100 iterations + Running * and ^ (1) + Passed 100 iterations + Running * and ^ (2) + Passed 100 iterations View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/24f4f54f0da3c6af3ad579b9551de481bf35087a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/24f4f54f0da3c6af3ad579b9551de481bf35087a You're receiving 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 Nov 3 06:00:27 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 03 Nov 2022 02:00:27 -0400 Subject: [Git][ghc/ghc][master] git: ignore HIE files. Message-ID: <636358fbd383f_11c7e25154014101c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - 1 changed file: - .gitignore Changes: ===================================== .gitignore ===================================== @@ -17,6 +17,8 @@ Thumbs.db *.hi *.hi-boot +*.hie +*.hie-boot *.o-boot *.p_o *.t_o View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d51bf7bd5f6ca959020e34527d869201a7c8a290 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d51bf7bd5f6ca959020e34527d869201a7c8a290 You're receiving 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 Nov 3 06:01:01 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 03 Nov 2022 02:01:01 -0400 Subject: [Git][ghc/ghc][master] Clarify status of bindings in WholeCoreBindings Message-ID: <6363591dc7d84_11c7e24b8341461ba@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 2 changed files: - compiler/GHC/IfaceToCore.hs - compiler/GHC/Unit/Module/WholeCoreBindings.hs Changes: ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -240,9 +240,9 @@ typecheckIface iface } typecheckWholeCoreBindings :: IORef TypeEnv -> WholeCoreBindings -> IfG [CoreBind] -typecheckWholeCoreBindings type_var (WholeCoreBindings prepd_binding this_mod _) = +typecheckWholeCoreBindings type_var (WholeCoreBindings tidy_bindings this_mod _) = initIfaceLcl this_mod (text "typecheckWholeCoreBindings") NotBoot $ do - tcTopIfaceBindings type_var prepd_binding + tcTopIfaceBindings type_var tidy_bindings {- ===================================== compiler/GHC/Unit/Module/WholeCoreBindings.hs ===================================== @@ -57,7 +57,7 @@ the object files. -} data WholeCoreBindings = WholeCoreBindings - { wcb_bindings :: [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] - , wcb_module :: Module - , wcb_mod_location :: ModLocation + { wcb_bindings :: [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -- ^ serialised tidied core bindings. + , wcb_module :: Module -- ^ The module which the bindings are for + , wcb_mod_location :: ModLocation -- ^ The location where the sources reside. } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9fc15b1228d557c2241a28ac702d4a6e140d975 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a9fc15b1228d557c2241a28ac702d4a6e140d975 You're receiving 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 Nov 3 06:43:40 2022 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Thu, 03 Nov 2022 02:43:40 -0400 Subject: [Git][ghc/ghc][wip/bump-boot-libraries] 16 commits: rts: introduce (and use) `STG_NORETURN` Message-ID: <6363631caaf1a_11c7e2515041496d7@gitlab.mail> Cheng Shao pushed to branch wip/bump-boot-libraries at Glasgow Haskell Compiler / GHC Commits: 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - f9356d2a by Matthew Pickering at 2022-11-03T06:42:43+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. - - - - - a40c5679 by Matthew Pickering at 2022-11-03T06:42:59+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - 30 changed files: - .gitignore - CODEOWNERS - compiler/GHC/IfaceToCore.hs - compiler/GHC/Unit/Module/WholeCoreBindings.hs - compiler/ghc.cabal.in - configure.ac - ghc/ghc-bin.cabal.in - libraries/Win32 - libraries/base/tests/T7773.hs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/ghc-prim/GHC/Types.hs - libraries/process - libraries/unix - rts/CloneStack.c - rts/Heap.c - rts/Hpc.c - rts/Linker.c - rts/RtsAPI.c - rts/RtsFlags.c - rts/RtsMessages.c - rts/RtsStartup.c - rts/RtsUtils.h - rts/StgCRun.c - rts/include/Rts.h - rts/include/RtsAPI.h - rts/include/Stg.h - rts/include/rts/Main.h - rts/include/rts/Messages.h - rts/include/rts/OSThreads.h - rts/include/rts/Threads.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/76c14a18f3638c4894af759583e5da9b1e962425...a40c5679a5d01dc6450c72a9df994eeb4e0e965d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/76c14a18f3638c4894af759583e5da9b1e962425...a40c5679a5d01dc6450c72a9df994eeb4e0e965d You're receiving 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 Nov 3 06:52:19 2022 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Thu, 03 Nov 2022 02:52:19 -0400 Subject: [Git][ghc/ghc][wip/bump-boot-libraries] Bump haskeline submodule Message-ID: <63636523c965c_11c7e25150415007a@gitlab.mail> Cheng Shao pushed to branch wip/bump-boot-libraries at Glasgow Haskell Compiler / GHC Commits: e0113fa4 by Cheng Shao at 2022-11-03T06:51:25+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 1 changed file: - libraries/haskeline Changes: ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit aae0bfeec7ae767e3c30844ca2f99b6825185467 +Subproject commit d4f343509e905a717ea463ad84462c126d8990d8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0113fa4d944a1b38038af12d34c200030e7a2dc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0113fa4d944a1b38038af12d34c200030e7a2dc You're receiving 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 Nov 3 08:09:22 2022 From: gitlab at gitlab.haskell.org (Josh Meredith (@JoshMeredith)) Date: Thu, 03 Nov 2022 04:09:22 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Change js_skip to js_broken(22261) in process submodule Message-ID: <636377326a2c8_11c7e251504158338@gitlab.mail> Josh Meredith pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 978f3010 by Josh Meredith at 2022-11-03T08:09:12+00:00 Change js_skip to js_broken(22261) in process submodule - - - - - 1 changed file: - libraries/process Changes: ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit 9a28b5a2b47d8f2abdeff6dc9f4c01f7f59e0ad5 +Subproject commit 2fc014c61763f89ba1c658e6727c4b62be8a995a View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/978f301075f3fa8505a2614aaaf3ec0486a912c3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/978f301075f3fa8505a2614aaaf3ec0486a912c3 You're receiving 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 Nov 3 08:54:52 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 03 Nov 2022 04:54:52 -0400 Subject: [Git][ghc/ghc][wip/mp-9.2.5-backports] 8 commits: Rubbish literals for all representations (#18983) Message-ID: <636381dc927ac_11c7e24b848166736@gitlab.mail> Zubin pushed to branch wip/mp-9.2.5-backports at Glasgow Haskell Compiler / GHC Commits: 63fe2ee2 by Sebastian Graf at 2022-11-03T14:21:10+05:30 Rubbish literals for all representations (#18983) This patch cleans up the complexity around WW's `mk_absent_let` by broadening the scope of `LitRubbish`. Rubbish literals now store the `PrimRep` they represent and are ultimately lowered in Cmm. This in turn allows absent literals of `VecRep` or `VoidRep`. The latter allows absent literals for unlifted coercions, as requested in #18983. I took the liberty to rewrite and clean up `Note [Absent fillers]` and `Note [Rubbish values]` to account for the new implementation and to make them more orthogonal in their description. I didn't add a new regression test, as `T18982` already contains the test in the ticket and its test output changes as expected. Fixes #18983. - - - - - 2b654c44 by Dai at 2022-11-03T14:23:18+05:30 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 (cherry picked from commit 5b3a992f5d166007c3c5a22f120ed08e0a27f01a) - - - - - b9d898a7 by sheaf at 2022-11-03T14:23:20+05:30 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. (cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262) - - - - - 886dfbe4 by sheaf at 2022-11-03T14:23:21+05:30 Disable some SIMD tests on non-X86 architectures (cherry picked from commit f7b7a3122185222d5059e37315991afcf319e43c) - - - - - b3230a38 by Zubin Duggal at 2022-11-03T14:23:21+05:30 Bump process to 1.6.16.0 - - - - - 000d3a78 by Zubin Duggal at 2022-11-03T14:23:21+05:30 Attemp fix for core lint failures For an expression: joinrec foo = ... in expr we compute the arityType as `foldr andArityType (arityType expr) [arityType foo]` which is the same as `andArityType (arityType expr) (arityType foo)`. However, this is incorrect: joinrec go x = ... in go 0 then the arity of go is 1 (\?. T), but the arity of the overall expression is 0 (_|_). `andArityType` however returns (\?. T) for these, which is wrong. (cherry picked from commit 53235edd478bd4c5e29e4f254ce02559af259dd5) - - - - - 63678ccd by Zubin Duggal at 2022-11-03T14:23:21+05:30 Bump base to 4.16.4.0 and add release notes - - - - - 1f9d14d5 by Zubin Duggal at 2022-11-03T14:23:21+05:30 Fix bkpcabal02 - - - - - 30 changed files: - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Utils.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/ArgRep.hs - compiler/GHC/StgToCmm/Env.hs - compiler/GHC/StgToCmm/Expr.hs - + compiler/GHC/StgToCmm/Expr.hs-boot - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Heap.hs - compiler/GHC/StgToCmm/Layout.hs - + compiler/GHC/StgToCmm/Lit.hs - compiler/GHC/StgToCmm/Monad.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToCmm/Prof.hs - compiler/GHC/StgToCmm/Ticky.hs - compiler/GHC/StgToCmm/Utils.hs - compiler/GHC/Types/Literal.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Utils/Misc.hs - compiler/ghc.cabal.in - configure.ac The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/040b80725bbc18db49023a53a73808c5c59cbbd4...1f9d14d56dfec93cf2ed2f4e25902e378423dfdc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/040b80725bbc18db49023a53a73808c5c59cbbd4...1f9d14d56dfec93cf2ed2f4e25902e378423dfdc You're receiving 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 Nov 3 09:14:34 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 03 Nov 2022 05:14:34 -0400 Subject: [Git][ghc/ghc][wip/mp-9.2.5-backports] 7 commits: Add VecSlot for unboxed sums of SIMD vectors Message-ID: <6363867a166fa_11c7e2515041694b4@gitlab.mail> Zubin pushed to branch wip/mp-9.2.5-backports at Glasgow Haskell Compiler / GHC Commits: ff29c2d6 by Dai at 2022-11-03T14:44:20+05:30 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 (cherry picked from commit 5b3a992f5d166007c3c5a22f120ed08e0a27f01a) - - - - - 3cbe16a6 by sheaf at 2022-11-03T14:44:20+05:30 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. (cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262) - - - - - 3df35c83 by sheaf at 2022-11-03T14:44:20+05:30 Disable some SIMD tests on non-X86 architectures (cherry picked from commit f7b7a3122185222d5059e37315991afcf319e43c) - - - - - d22197c2 by Zubin Duggal at 2022-11-03T14:44:20+05:30 Bump process to 1.6.16.0 - - - - - 8494b554 by Zubin Duggal at 2022-11-03T14:44:20+05:30 Attemp fix for core lint failures For an expression: joinrec foo = ... in expr we compute the arityType as `foldr andArityType (arityType expr) [arityType foo]` which is the same as `andArityType (arityType expr) (arityType foo)`. However, this is incorrect: joinrec go x = ... in go 0 then the arity of go is 1 (\?. T), but the arity of the overall expression is 0 (_|_). `andArityType` however returns (\?. T) for these, which is wrong. (cherry picked from commit 53235edd478bd4c5e29e4f254ce02559af259dd5) - - - - - d0039f67 by Zubin Duggal at 2022-11-03T14:44:21+05:30 Bump base to 4.16.4.0 and add release notes - - - - - 07a1c4b0 by Zubin Duggal at 2022-11-03T14:44:21+05:30 Fix bkpcabal02 - - - - - 29 changed files: - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Types/RepType.hs - configure.ac - docs/users_guide/release-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md - libraries/process - + testsuite/tests/arityanal/should_compile/Arity17.hs - testsuite/tests/arityanal/should_compile/all.T - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - 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/printer/T18052a.stderr - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr - + testsuite/tests/unboxedsums/T22187.hs - + testsuite/tests/unboxedsums/T22187_run.hs - + testsuite/tests/unboxedsums/T22187_run.stdout - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Cmm/Lint.hs ===================================== @@ -170,9 +170,21 @@ lintCmmMiddle node = case node of platform <- getPlatform erep <- lintCmmExpr expr let reg_ty = cmmRegType platform reg - if (erep `cmmEqType_ignoring_ptrhood` reg_ty) - then return () - else cmmLintAssignErr (CmmAssign reg expr) erep reg_ty + unless (compat_regs erep reg_ty) $ + cmmLintAssignErr (CmmAssign reg expr) erep reg_ty + where + compat_regs :: CmmType -> CmmType -> Bool + compat_regs ty1 ty2 + -- As noted in #22297, SIMD vector registers can be used for + -- multiple different purposes, e.g. xmm1 can be used to hold 4 Floats, + -- or 4 Int32s, or 2 Word64s, ... + -- To allow this, we relax the check: we only ensure that the widths + -- match, until we can find a more robust solution. + | isVecType ty1 + , isVecType ty2 + = typeWidth ty1 == typeWidth ty2 + | otherwise + = cmmEqType_ignoring_ptrhood ty1 ty2 CmmStore l r _alignment -> do _ <- lintCmmExpr l ===================================== compiler/GHC/Cmm/Utils.hs ===================================== @@ -115,7 +115,7 @@ primRepCmmType platform = \case AddrRep -> bWord platform FloatRep -> f32 DoubleRep -> f64 - (VecRep len rep) -> vec len (primElemRepCmmType rep) + VecRep len rep -> vec len (primElemRepCmmType rep) slotCmmType :: Platform -> SlotTy -> CmmType slotCmmType platform = \case @@ -125,6 +125,7 @@ slotCmmType platform = \case Word64Slot -> b64 FloatSlot -> f32 DoubleSlot -> f64 + VecSlot l e -> vec l (primElemRepCmmType e) primElemRepCmmType :: PrimElemRep -> CmmType primElemRepCmmType Int8ElemRep = b8 ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1104,22 +1104,6 @@ arityType env (Let (NonRec b r) e) cheap_rhs = myExprIsCheap env r (Just (idType b)) env' = extendSigEnv env b (arityType env r) -arityType env (Let (Rec pairs) body) - | ((j,_):_) <- pairs - , isJoinId j - = -- See Note [arityType for join bindings] - foldr (andArityType env . do_one) (arityType rec_env body) pairs - where - rec_env = foldl add_bot env pairs - add_bot env (j,_) = extendSigEnv env j botArityType - - do_one :: (JoinId, CoreExpr) -> ArityType - do_one (j,rhs) - | Just arity <- isJoinId_maybe j - = arityType rec_env $ snd $ collectNBinders arity rhs - | otherwise - = pprPanic "arityType:joinrec" (ppr pairs) - arityType env (Let (Rec prs) e) = floatIn (all is_cheap prs) (arityType env' e) where ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -658,6 +658,7 @@ ubxSumRubbishArg WordSlot = StgLitArg (LitNumber LitNumWord 0) ubxSumRubbishArg Word64Slot = StgLitArg (LitNumber LitNumWord64 0) ubxSumRubbishArg FloatSlot = StgLitArg (LitFloat 0) ubxSumRubbishArg DoubleSlot = StgLitArg (LitDouble 0) +ubxSumRubbishArg (VecSlot n e) = StgLitArg (LitRubbish [VecRep n e]) -------------------------------------------------------------------------------- ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -235,7 +235,7 @@ layoutUbxSum sum_slots0 arg_slots0 = -- -- TODO(michalt): We should probably introduce `SlotTy`s for 8-/16-/32-bit -- values, so that we can pack things more tightly. -data SlotTy = PtrLiftedSlot | PtrUnliftedSlot | WordSlot | Word64Slot | FloatSlot | DoubleSlot +data SlotTy = PtrLiftedSlot | PtrUnliftedSlot | WordSlot | Word64Slot | FloatSlot | DoubleSlot | VecSlot Int PrimElemRep deriving (Eq, Ord) -- Constructor order is important! If slot A could fit into slot B -- then slot A must occur first. E.g. FloatSlot before DoubleSlot @@ -250,6 +250,7 @@ instance Outputable SlotTy where ppr WordSlot = text "WordSlot" ppr DoubleSlot = text "DoubleSlot" ppr FloatSlot = text "FloatSlot" + ppr (VecSlot n e) = text "VecSlot" <+> ppr n <+> ppr e typeSlotTy :: UnaryType -> Maybe SlotTy typeSlotTy ty @@ -275,7 +276,7 @@ primRepSlot Word64Rep = Word64Slot primRepSlot AddrRep = WordSlot primRepSlot FloatRep = FloatSlot primRepSlot DoubleRep = DoubleSlot -primRepSlot VecRep{} = pprPanic "primRepSlot" (text "No slot for VecRep") +primRepSlot (VecRep n e) = VecSlot n e slotPrimRep :: SlotTy -> PrimRep slotPrimRep PtrLiftedSlot = LiftedRep @@ -284,6 +285,7 @@ slotPrimRep Word64Slot = Word64Rep slotPrimRep WordSlot = WordRep slotPrimRep DoubleSlot = DoubleRep slotPrimRep FloatSlot = FloatRep +slotPrimRep (VecSlot n e) = VecRep n e -- | Returns the bigger type if one fits into the other. (commutative) fitsIn :: SlotTy -> SlotTy -> Maybe SlotTy ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.2.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.2.5], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on HEAD must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058) ===================================== docs/users_guide/release-notes.rst ===================================== @@ -8,3 +8,4 @@ Release notes 9.2.2-notes 9.2.3-notes 9.2.4-notes + 9.2.5-notes ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.16.3.0 +version: 4.16.4.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.16.4.0 *Nov 2022* + + * Shipped with GHC 9.2.5 + + * Fix races in IOManager (setNumCapabilities,closeFdWith) (#21651) + + * winio: do not re-translate input when handle is uncooked + ## 4.16.3.0 *May 2022* * Shipped with GHC 9.2.4 ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit b39bbc0625c99c8c02840d8fd3ae45f062c9c78a +Subproject commit 2e7e0d6fed946c333eb679a8381e3a6383704a4f ===================================== testsuite/tests/arityanal/should_compile/Arity17.hs ===================================== @@ -0,0 +1,27 @@ +module Bug (downsweep) where + +import GHC.Utils.Misc ( filterOut ) +import qualified Data.Map.Strict as M ( Map, elems ) +import qualified Data.Map as Map ( fromListWith ) + +type DownsweepCache = M.Map Int Int + +downsweep :: [Int] -> IO DownsweepCache +downsweep rootSummariesOk = do + let root_map = mkRootMap rootSummariesOk + checkDuplicates root_map + return root_map + where + checkDuplicates :: DownsweepCache -> IO () + checkDuplicates root_map = multiRootsErr dup_roots + where + dup_roots = filterOut (>2) (M.elems root_map) + +mkRootMap + :: [Int] + -> DownsweepCache +mkRootMap summaries = Map.fromListWith const + [ (s, s) | s <- summaries ] + +multiRootsErr :: [a] -> IO () +multiRootsErr [] = pure () ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -16,6 +16,7 @@ test('Arity13', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn test('Arity14', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity15', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('Arity17', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-package ghc -dcore-lint -O2']) # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-9bjQYYw8j3tIrm7euzOF3W-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-G3FVTX5iIPDDr8H2ahirUB-p ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,4 +11,4 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -54,4 +54,4 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,4 +9,4 @@ FAMILY INSTANCES data instance forall {k1} {j :: k1} {k2} {c :: k2}. DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,4 +5,4 @@ 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.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,4 +4,4 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/printer/T18052a.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS PATTERN SYNONYMS (:||:) :: forall {a} {b}. a -> b -> (a, b) Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ==================== Tidy Core ==================== Result size of Tidy Core ===================================== testsuite/tests/roles/should_compile/T8958.stderr ===================================== @@ -16,7 +16,7 @@ CLASS INSTANCES -- Defined at T8958.hs:11:10 instance [incoherent] Nominal a -- Defined at T8958.hs:8:10 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ==================== Typechecker ==================== T8958.$tcMap ===================================== testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout ===================================== @@ -4,17 +4,17 @@ pdb.safePkg01/local.db trusted: False M_SafePkg -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe require own pkg trusted: False M_SafePkg2 -package dependencies: base-4.16.3.0 ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0 ghc-bignum-1.2 ghc-prim-0.8.0 trusted: trustworthy require own pkg trusted: False M_SafePkg3 -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe require own pkg trusted: True @@ -24,7 +24,7 @@ trusted: safe require own pkg trusted: True M_SafePkg5 -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe-inferred require own pkg trusted: True ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,4 +8,4 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -8,10 +8,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.16.3.0:Data.OldList’)) + (and originally defined in ‘base-4.16.4.0:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.16.3.0:Data.OldList’)) + (and originally defined in ‘base-4.16.4.0:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 ===================================== testsuite/tests/unboxedsums/T22187.hs ===================================== @@ -0,0 +1,6 @@ +{-# language MagicHash,UnboxedSums #-} +module T22187 where +import GHC.Exts + +foo :: (# Int64X2# | () #) -> () +foo _ = () ===================================== testsuite/tests/unboxedsums/T22187_run.hs ===================================== @@ -0,0 +1,51 @@ +{-# language MagicHash, UnboxedTuples, UnboxedSums #-} + +module Main ( main ) where + +import GHC.Exts +import GHC.Int +import GHC.Word +import GHC.Float +import GHC.Prim + +foo :: (# Int64X2# | Bool | DoubleX2# #) + -> (# Integer | (# FloatX4#, Int64#, Int64# #) | Char #) +foo (# i64x2 | | #) = + case unpackInt64X2# i64x2 of + (# i1, i2 #) -> + let + s = sum $ map fromIntegral + [ I64# i1, I64# i2 ] + in (# s | | #) + +foo (# | b | #) = if b then (# 0 | | #) else (# | | 'F' #) +foo (# | | dx2 #) = + case unpackDoubleX2# dx2 of + (# d1, d2 #) -> + let (# m1, e1 #) = decodeDouble_Int64# d1 + (# m2, e2 #) = decodeDouble_Int64# d2 + v = packFloatX4# + (# double2Float# d1 + , int2Float# e1 + , double2Float# d2 + , int2Float# e1 #) + in (# | (# v, m1, m2 #) | #) + +show_it :: (# Integer | (# FloatX4#, Int64#, Int64# #) | Char #) -> String +show_it (# i | | #) = "(# " ++ show i ++ " | | #)" +show_it (# | (# fx4, m1, m2 #) | #) = "(# | (# " ++ showFloatX4 fx4 ++ ", " ++ show (I64# m1) ++ ", " ++ show (I64# m2) ++ " #) | #)" +show_it (# | | c #) = "(# | | " ++ show c ++ " #)" + +showFloatX4 :: FloatX4# -> String +showFloatX4 fx4 = case unpackFloatX4# fx4 of + (# f1, f2, f3, f4 #) -> + "(# " ++ show (F# f1) ++ ", " ++ show (F# f2) ++ ", " + ++ show (F# f3) ++ ", " ++ show (F# f4) ++ " #)" + +main :: IO () +main = do + putStrLn $ show_it ( foo (# broadcastInt64X2# ( intToInt64# 1# ) | | #) ) + putStrLn $ show_it ( foo (# | False | #) ) + putStrLn $ show_it ( foo (# | True | #) ) + let dx2 = packDoubleX2# (# 128.0##, -0.0025## #) + putStrLn $ show_it ( foo (# | | dx2 #) ) ===================================== testsuite/tests/unboxedsums/T22187_run.stdout ===================================== @@ -0,0 +1,4 @@ +(# 2 | | #) +(# | | 'F' #) +(# 0 | | #) +(# | (# (# 128.0, -45.0, -2.5e-3, -45.0 #), 4503599627370496, -5764607523034235 #) | #) ===================================== testsuite/tests/unboxedsums/all.T ===================================== @@ -27,3 +27,8 @@ test('T12711', only_ways(['ghci']), ghci_script, ['T12711.script']) test('UbxSumLevPoly', normal, compile, ['-Wno-overlapping-patterns']) test('T14051', normal, multi_compile, ['T14051.hs', [('T14051a.hs', '')], '-O2 -v0']) test('T19645', normal, compile_and_run, ['']) + +test('T22187',[only_ways(llvm_ways)],compile,['']) +test('T22187_run',[only_ways(llvm_ways) + ,unless(arch('x86_64'), skip)],compile_and_run,['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f9d14d56dfec93cf2ed2f4e25902e378423dfdc...07a1c4b05ebb988443980de1acba4f9f3e721aa4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1f9d14d56dfec93cf2ed2f4e25902e378423dfdc...07a1c4b05ebb988443980de1acba4f9f3e721aa4 You're receiving 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 Nov 3 09:42:53 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 03 Nov 2022 05:42:53 -0400 Subject: [Git][ghc/ghc][wip/mp-9.2.5-backports] 7 commits: Add VecSlot for unboxed sums of SIMD vectors Message-ID: <63638d1d39996_11c7e251504172155@gitlab.mail> Zubin pushed to branch wip/mp-9.2.5-backports at Glasgow Haskell Compiler / GHC Commits: 1fabaae4 by Dai at 2022-11-03T15:12:38+05:30 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 (cherry picked from commit 5b3a992f5d166007c3c5a22f120ed08e0a27f01a) - - - - - 9d469bff by sheaf at 2022-11-03T15:12:38+05:30 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. (cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262) - - - - - 14e0442e by sheaf at 2022-11-03T15:12:38+05:30 Disable some SIMD tests on non-X86 architectures (cherry picked from commit f7b7a3122185222d5059e37315991afcf319e43c) - - - - - 45459cce by Zubin Duggal at 2022-11-03T15:12:38+05:30 Bump process to 1.6.16.0 - - - - - 5674eb8b by Zubin Duggal at 2022-11-03T15:12:38+05:30 Attemp fix for core lint failures For an expression: joinrec foo = ... in expr we compute the arityType as `foldr andArityType (arityType expr) [arityType foo]` which is the same as `andArityType (arityType expr) (arityType foo)`. However, this is incorrect: joinrec go x = ... in go 0 then the arity of go is 1 (\?. T), but the arity of the overall expression is 0 (_|_). `andArityType` however returns (\?. T) for these, which is wrong. (cherry picked from commit 53235edd478bd4c5e29e4f254ce02559af259dd5) - - - - - 36cfeb7c by Zubin Duggal at 2022-11-03T15:12:38+05:30 Bump base to 4.16.4.0 and add release notes - - - - - 3588c3a9 by Zubin Duggal at 2022-11-03T15:12:38+05:30 Fix bkpcabal02 - - - - - 29 changed files: - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Types/RepType.hs - configure.ac - docs/users_guide/release-notes.rst - libraries/base/base.cabal - libraries/base/changelog.md - libraries/process - + testsuite/tests/arityanal/should_compile/Arity17.hs - testsuite/tests/arityanal/should_compile/all.T - testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout - 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/printer/T18052a.stderr - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout - testsuite/tests/typecheck/should_compile/T12763.stderr - testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr - + testsuite/tests/unboxedsums/T22187.hs - + testsuite/tests/unboxedsums/T22187_run.hs - + testsuite/tests/unboxedsums/T22187_run.stdout - testsuite/tests/unboxedsums/all.T Changes: ===================================== compiler/GHC/Cmm/Lint.hs ===================================== @@ -170,9 +170,21 @@ lintCmmMiddle node = case node of platform <- getPlatform erep <- lintCmmExpr expr let reg_ty = cmmRegType platform reg - if (erep `cmmEqType_ignoring_ptrhood` reg_ty) - then return () - else cmmLintAssignErr (CmmAssign reg expr) erep reg_ty + unless (compat_regs erep reg_ty) $ + cmmLintAssignErr (CmmAssign reg expr) erep reg_ty + where + compat_regs :: CmmType -> CmmType -> Bool + compat_regs ty1 ty2 + -- As noted in #22297, SIMD vector registers can be used for + -- multiple different purposes, e.g. xmm1 can be used to hold 4 Floats, + -- or 4 Int32s, or 2 Word64s, ... + -- To allow this, we relax the check: we only ensure that the widths + -- match, until we can find a more robust solution. + | isVecType ty1 + , isVecType ty2 + = typeWidth ty1 == typeWidth ty2 + | otherwise + = cmmEqType_ignoring_ptrhood ty1 ty2 CmmStore l r _alignment -> do _ <- lintCmmExpr l ===================================== compiler/GHC/Cmm/Utils.hs ===================================== @@ -115,7 +115,7 @@ primRepCmmType platform = \case AddrRep -> bWord platform FloatRep -> f32 DoubleRep -> f64 - (VecRep len rep) -> vec len (primElemRepCmmType rep) + VecRep len rep -> vec len (primElemRepCmmType rep) slotCmmType :: Platform -> SlotTy -> CmmType slotCmmType platform = \case @@ -125,6 +125,7 @@ slotCmmType platform = \case Word64Slot -> b64 FloatSlot -> f32 DoubleSlot -> f64 + VecSlot l e -> vec l (primElemRepCmmType e) primElemRepCmmType :: PrimElemRep -> CmmType primElemRepCmmType Int8ElemRep = b8 ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -1104,22 +1104,6 @@ arityType env (Let (NonRec b r) e) cheap_rhs = myExprIsCheap env r (Just (idType b)) env' = extendSigEnv env b (arityType env r) -arityType env (Let (Rec pairs) body) - | ((j,_):_) <- pairs - , isJoinId j - = -- See Note [arityType for join bindings] - foldr (andArityType env . do_one) (arityType rec_env body) pairs - where - rec_env = foldl add_bot env pairs - add_bot env (j,_) = extendSigEnv env j botArityType - - do_one :: (JoinId, CoreExpr) -> ArityType - do_one (j,rhs) - | Just arity <- isJoinId_maybe j - = arityType rec_env $ snd $ collectNBinders arity rhs - | otherwise - = pprPanic "arityType:joinrec" (ppr pairs) - arityType env (Let (Rec prs) e) = floatIn (all is_cheap prs) (arityType env' e) where ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -658,6 +658,7 @@ ubxSumRubbishArg WordSlot = StgLitArg (LitNumber LitNumWord 0) ubxSumRubbishArg Word64Slot = StgLitArg (LitNumber LitNumWord64 0) ubxSumRubbishArg FloatSlot = StgLitArg (LitFloat 0) ubxSumRubbishArg DoubleSlot = StgLitArg (LitDouble 0) +ubxSumRubbishArg (VecSlot n e) = StgLitArg (LitRubbish [VecRep n e]) -------------------------------------------------------------------------------- ===================================== compiler/GHC/Types/RepType.hs ===================================== @@ -235,7 +235,7 @@ layoutUbxSum sum_slots0 arg_slots0 = -- -- TODO(michalt): We should probably introduce `SlotTy`s for 8-/16-/32-bit -- values, so that we can pack things more tightly. -data SlotTy = PtrLiftedSlot | PtrUnliftedSlot | WordSlot | Word64Slot | FloatSlot | DoubleSlot +data SlotTy = PtrLiftedSlot | PtrUnliftedSlot | WordSlot | Word64Slot | FloatSlot | DoubleSlot | VecSlot Int PrimElemRep deriving (Eq, Ord) -- Constructor order is important! If slot A could fit into slot B -- then slot A must occur first. E.g. FloatSlot before DoubleSlot @@ -250,6 +250,7 @@ instance Outputable SlotTy where ppr WordSlot = text "WordSlot" ppr DoubleSlot = text "DoubleSlot" ppr FloatSlot = text "FloatSlot" + ppr (VecSlot n e) = text "VecSlot" <+> ppr n <+> ppr e typeSlotTy :: UnaryType -> Maybe SlotTy typeSlotTy ty @@ -275,7 +276,7 @@ primRepSlot Word64Rep = Word64Slot primRepSlot AddrRep = WordSlot primRepSlot FloatRep = FloatSlot primRepSlot DoubleRep = DoubleSlot -primRepSlot VecRep{} = pprPanic "primRepSlot" (text "No slot for VecRep") +primRepSlot (VecRep n e) = VecSlot n e slotPrimRep :: SlotTy -> PrimRep slotPrimRep PtrLiftedSlot = LiftedRep @@ -284,6 +285,7 @@ slotPrimRep Word64Slot = Word64Rep slotPrimRep WordSlot = WordRep slotPrimRep DoubleSlot = DoubleRep slotPrimRep FloatSlot = FloatRep +slotPrimRep (VecSlot n e) = VecRep n e -- | Returns the bigger type if one fits into the other. (commutative) fitsIn :: SlotTy -> SlotTy -> Maybe SlotTy ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.2.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.2.5], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on HEAD must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058) ===================================== docs/users_guide/release-notes.rst ===================================== @@ -8,3 +8,4 @@ Release notes 9.2.2-notes 9.2.3-notes 9.2.4-notes + 9.2.5-notes ===================================== libraries/base/base.cabal ===================================== @@ -1,6 +1,6 @@ cabal-version: 3.0 name: base -version: 4.16.3.0 +version: 4.16.4.0 -- NOTE: Don't forget to update ./changelog.md license: BSD-3-Clause ===================================== libraries/base/changelog.md ===================================== @@ -1,5 +1,13 @@ # Changelog for [`base` package](http://hackage.haskell.org/package/base) +## 4.16.4.0 *Nov 2022* + + * Shipped with GHC 9.2.5 + + * Fix races in IOManager (setNumCapabilities,closeFdWith) (#21651) + + * winio: do not re-translate input when handle is uncooked + ## 4.16.3.0 *May 2022* * Shipped with GHC 9.2.4 ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit b39bbc0625c99c8c02840d8fd3ae45f062c9c78a +Subproject commit 2e7e0d6fed946c333eb679a8381e3a6383704a4f ===================================== testsuite/tests/arityanal/should_compile/Arity17.hs ===================================== @@ -0,0 +1,27 @@ +module Bug (downsweep) where + +import GHC.Utils.Misc ( filterOut ) +import qualified Data.Map.Strict as M ( Map, elems ) +import qualified Data.Map as Map ( fromListWith ) + +type DownsweepCache = M.Map Int Int + +downsweep :: [Int] -> IO DownsweepCache +downsweep rootSummariesOk = do + let root_map = mkRootMap rootSummariesOk + checkDuplicates root_map + return root_map + where + checkDuplicates :: DownsweepCache -> IO () + checkDuplicates root_map = multiRootsErr dup_roots + where + dup_roots = filterOut (>2) (M.elems root_map) + +mkRootMap + :: [Int] + -> DownsweepCache +mkRootMap summaries = Map.fromListWith const + [ (s, s) | s <- summaries ] + +multiRootsErr :: [a] -> IO () +multiRootsErr [] = pure () ===================================== testsuite/tests/arityanal/should_compile/all.T ===================================== @@ -16,6 +16,7 @@ test('Arity13', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dn test('Arity14', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity15', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) test('Arity16', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) +test('Arity17', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-package ghc -dcore-lint -O2']) # Regression tests test('T18793', [ only_ways(['optasm']), grep_errmsg('Arity=') ], compile, ['-dno-typeable-binds -ddump-simpl -dppr-cols=99999 -dsuppress-uniques']) ===================================== testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout ===================================== @@ -4,4 +4,4 @@ for bkpcabal01-0.1.0.0.. Preprocessing library 'q' for bkpcabal01-0.1.0.0.. Building library 'q' instantiated with H = for bkpcabal01-0.1.0.0.. -[2 of 2] Instantiating bkpcabal01-0.1.0.0-9bjQYYw8j3tIrm7euzOF3W-p +[2 of 2] Instantiating bkpcabal01-0.1.0.0-G3FVTX5iIPDDr8H2ahirUB-p ===================================== testsuite/tests/dependent/should_compile/T14729.stderr ===================================== @@ -11,4 +11,4 @@ COERCION AXIOMS FAMILY INSTANCES type instance F Int = Bool -- Defined at T14729.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/dependent/should_compile/T15743.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS forall {k1} k2 (k3 :: k2). Proxy k3 -> k1 -> k2 -> * roles nominal nominal nominal phantom phantom phantom Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/dependent/should_compile/T15743e.stderr ===================================== @@ -54,4 +54,4 @@ DATA CONSTRUCTORS (d :: Proxy k5) (e :: Proxy k7). f c -> T k8 a b f c d e Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/indexed-types/should_compile/T15711.stderr ===================================== @@ -3,4 +3,4 @@ TYPE CONSTRUCTORS associated type family F{2} :: forall a. Maybe a -> * roles nominal nominal Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/indexed-types/should_compile/T15852.stderr ===================================== @@ -9,4 +9,4 @@ FAMILY INSTANCES data instance forall {k1} {j :: k1} {k2} {c :: k2}. DF (Proxy c) -- Defined at T15852.hs:10:15 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/polykinds/T15592.stderr ===================================== @@ -5,4 +5,4 @@ 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.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/polykinds/T15592b.stderr ===================================== @@ -4,4 +4,4 @@ TYPE CONSTRUCTORS forall k (f :: k -> *) (a :: k). f a -> * roles nominal nominal nominal nominal Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/printer/T18052a.stderr ===================================== @@ -6,7 +6,7 @@ TYPE CONSTRUCTORS PATTERN SYNONYMS (:||:) :: forall {a} {b}. a -> b -> (a, b) Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ==================== Tidy Core ==================== Result size of Tidy Core ===================================== testsuite/tests/roles/should_compile/T8958.stderr ===================================== @@ -16,7 +16,7 @@ CLASS INSTANCES -- Defined at T8958.hs:11:10 instance [incoherent] Nominal a -- Defined at T8958.hs:8:10 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ==================== Typechecker ==================== T8958.$tcMap ===================================== testsuite/tests/safeHaskell/check/pkg01/safePkg01.stdout ===================================== @@ -4,17 +4,17 @@ pdb.safePkg01/local.db trusted: False M_SafePkg -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe require own pkg trusted: False M_SafePkg2 -package dependencies: base-4.16.3.0 ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0 ghc-bignum-1.2 ghc-prim-0.8.0 trusted: trustworthy require own pkg trusted: False M_SafePkg3 -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe require own pkg trusted: True @@ -24,7 +24,7 @@ trusted: safe require own pkg trusted: True M_SafePkg5 -package dependencies: base-4.16.3.0* ghc-bignum-1.2 ghc-prim-0.8.0 +package dependencies: base-4.16.4.0* ghc-bignum-1.2 ghc-prim-0.8.0 trusted: safe-inferred require own pkg trusted: True ===================================== testsuite/tests/typecheck/should_compile/T12763.stderr ===================================== @@ -8,4 +8,4 @@ COERCION AXIOMS CLASS INSTANCES instance C Int -- Defined at T12763.hs:9:10 Dependent modules: [] -Dependent packages: [base-4.16.3.0, ghc-bignum-1.2, ghc-prim-0.8.0] +Dependent packages: [base-4.16.4.0, ghc-bignum-1.2, ghc-prim-0.8.0] ===================================== testsuite/tests/typecheck/should_compile/subsumption_sort_hole_fits.stderr ===================================== @@ -8,10 +8,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.16.3.0:Data.OldList’)) + (and originally defined in ‘base-4.16.4.0:Data.OldList’)) words :: String -> [String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 - (and originally defined in ‘base-4.16.3.0:Data.OldList’)) + (and originally defined in ‘base-4.16.4.0:Data.OldList’)) read :: forall a. Read a => String -> a with read @[String] (imported from ‘Prelude’ at subsumption_sort_hole_fits.hs:1:1 ===================================== testsuite/tests/unboxedsums/T22187.hs ===================================== @@ -0,0 +1,6 @@ +{-# language MagicHash,UnboxedSums #-} +module T22187 where +import GHC.Exts + +foo :: (# Int64X2# | () #) -> () +foo _ = () ===================================== testsuite/tests/unboxedsums/T22187_run.hs ===================================== @@ -0,0 +1,51 @@ +{-# language MagicHash, UnboxedTuples, UnboxedSums #-} + +module Main ( main ) where + +import GHC.Exts +import GHC.Int +import GHC.Word +import GHC.Float +import GHC.Prim + +foo :: (# Int64X2# | Bool | DoubleX2# #) + -> (# Integer | (# FloatX4#, Int#, Int# #) | Char #) +foo (# i64x2 | | #) = + case unpackInt64X2# i64x2 of + (# i1, i2 #) -> + let + s = sum $ map fromIntegral + [ I64# i1, I64# i2 ] + in (# s | | #) + +foo (# | b | #) = if b then (# 0 | | #) else (# | | 'F' #) +foo (# | | dx2 #) = + case unpackDoubleX2# dx2 of + (# d1, d2 #) -> + let (# m1, e1 #) = decodeDouble_Int64# d1 + (# m2, e2 #) = decodeDouble_Int64# d2 + v = packFloatX4# + (# double2Float# d1 + , int2Float# e1 + , double2Float# d2 + , int2Float# e1 #) + in (# | (# v, m1, m2 #) | #) + +show_it :: (# Integer | (# FloatX4#, Int#, Int# #) | Char #) -> String +show_it (# i | | #) = "(# " ++ show i ++ " | | #)" +show_it (# | (# fx4, m1, m2 #) | #) = "(# | (# " ++ showFloatX4 fx4 ++ ", " ++ show (I64# m1) ++ ", " ++ show (I64# m2) ++ " #) | #)" +show_it (# | | c #) = "(# | | " ++ show c ++ " #)" + +showFloatX4 :: FloatX4# -> String +showFloatX4 fx4 = case unpackFloatX4# fx4 of + (# f1, f2, f3, f4 #) -> + "(# " ++ show (F# f1) ++ ", " ++ show (F# f2) ++ ", " + ++ show (F# f3) ++ ", " ++ show (F# f4) ++ " #)" + +main :: IO () +main = do + putStrLn $ show_it ( foo (# broadcastInt64X2# 1# | | #) ) + putStrLn $ show_it ( foo (# | False | #) ) + putStrLn $ show_it ( foo (# | True | #) ) + let dx2 = packDoubleX2# (# 128.0##, -0.0025## #) + putStrLn $ show_it ( foo (# | | dx2 #) ) ===================================== testsuite/tests/unboxedsums/T22187_run.stdout ===================================== @@ -0,0 +1,4 @@ +(# 2 | | #) +(# | | 'F' #) +(# 0 | | #) +(# | (# (# 128.0, -45.0, -2.5e-3, -45.0 #), 4503599627370496, -5764607523034235 #) | #) ===================================== testsuite/tests/unboxedsums/all.T ===================================== @@ -27,3 +27,8 @@ test('T12711', only_ways(['ghci']), ghci_script, ['T12711.script']) test('UbxSumLevPoly', normal, compile, ['-Wno-overlapping-patterns']) test('T14051', normal, multi_compile, ['T14051.hs', [('T14051a.hs', '')], '-O2 -v0']) test('T19645', normal, compile_and_run, ['']) + +test('T22187',[only_ways(llvm_ways)],compile,['']) +test('T22187_run',[only_ways(llvm_ways) + ,unless(arch('x86_64'), skip)],compile_and_run,['']) + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/07a1c4b05ebb988443980de1acba4f9f3e721aa4...3588c3a950ca64064d770101dce74237dfe9d5f0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/07a1c4b05ebb988443980de1acba4f9f3e721aa4...3588c3a950ca64064d770101dce74237dfe9d5f0 You're receiving 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 Nov 3 10:40:15 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 03 Nov 2022 06:40:15 -0400 Subject: [Git][ghc/ghc][wip/T22331] 25 commits: Drop a kludge for binutils<2.17, which is now over 10 years old. Message-ID: <63639a8f96429_11c7e25152c182951@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22331 at Glasgow Haskell Compiler / GHC Commits: d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - ef590e55 by Simon Peyton Jones at 2022-11-03T10:42:00+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 30 changed files: - .gitignore - CODEOWNERS - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcMType.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/ThToHs.hs - compiler/GHC/Unit/Env.hs - compiler/GHC/Unit/Module/WholeCoreBindings.hs - configure.ac - docs/users_guide/phases.rst - libraries/ghc-prim/GHC/Types.hs - rts/CloneStack.c - rts/Heap.c - rts/Hpc.c - rts/Linker.c - rts/RtsAPI.c - rts/RtsFlags.c - rts/RtsMessages.c - rts/RtsStartup.c - rts/RtsUtils.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3438c61d53b7b6b519986148fb5d0f533d00c8c6...ef590e55d72fdd12e9f0aba3cd1f0f09e2bc719e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3438c61d53b7b6b519986148fb5d0f533d00c8c6...ef590e55d72fdd12e9f0aba3cd1f0f09e2bc719e You're receiving 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 Nov 3 11:39:12 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Thu, 03 Nov 2022 07:39:12 -0400 Subject: [Git][ghc/ghc][wip/T22342] CI: Bump ci-images so more jobs boot with 9.2 Message-ID: <6363a860ac8cb_11c7e24b848199867@gitlab.mail> Bryan R pushed to branch wip/T22342 at Glasgow Haskell Compiler / GHC Commits: 432b05ed by Bryan Richter at 2022-11-03T13:38:42+02:00 CI: Bump ci-images so more jobs boot with 9.2 - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -2,7 +2,9 @@ variables: GIT_SSL_NO_VERIFY: "1" # Commit of ghc/ci-images repository from which to pull Docker images - DOCKER_REV: 9e4c540d9e4972a36291dfdf81f079f37d748890 + # FIXME: Currently set to a wip branch so that CI will do my testing for me, + # since I am not a Docker genius + DOCKER_REV: b8122a59ec3ea06a386b8545aaeeb88674b9cf64 # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/432b05ed2296f7cf11b6119663492044c2643771 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/432b05ed2296f7cf11b6119663492044c2643771 You're receiving 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 Nov 3 11:48:44 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 03 Nov 2022 07:48:44 -0400 Subject: [Git][ghc/ghc][wip/mp-9.2.5-backports] Fix core lint errors to do with SIMD vector indexing in T22187_run. Message-ID: <6363aa9c8acd7_11c7e25152c2014b@gitlab.mail> Zubin pushed to branch wip/mp-9.2.5-backports at Glasgow Haskell Compiler / GHC Commits: c35d3f80 by Zubin Duggal at 2022-11-03T17:15:22+05:30 Fix core lint errors to do with SIMD vector indexing in T22187_run. This patch was originally from 6d7d91817795d7ee7f45557411368a1738daa488, but all the changes in that commit can't make it because we don't want to change the interface of primops in a backport. - - - - - 1 changed file: - compiler/GHC/Cmm/MachOp.hs Changes: ===================================== compiler/GHC/Cmm/MachOp.hs ===================================== @@ -515,8 +515,8 @@ machOpArgReps platform op = MO_FS_Conv from _ -> [from] MO_FF_Conv from _ -> [from] - MO_V_Insert l r -> [typeWidth (vec l (cmmBits r)),r,wordWidth platform] - MO_V_Extract l r -> [typeWidth (vec l (cmmBits r)),wordWidth platform] + MO_V_Insert l r -> [typeWidth (vec l (cmmBits r)),r, W32] + MO_V_Extract l r -> [typeWidth (vec l (cmmBits r)), W32] MO_V_Add _ r -> [r,r] MO_V_Sub _ r -> [r,r] @@ -529,8 +529,8 @@ machOpArgReps platform op = MO_VU_Quot _ r -> [r,r] MO_VU_Rem _ r -> [r,r] - MO_VF_Insert l r -> [typeWidth (vec l (cmmFloat r)),r,wordWidth platform] - MO_VF_Extract l r -> [typeWidth (vec l (cmmFloat r)),wordWidth platform] + MO_VF_Insert l r -> [typeWidth (vec l (cmmFloat r)),r,W32] + MO_VF_Extract l r -> [typeWidth (vec l (cmmFloat r)),W32] MO_VF_Add _ r -> [r,r] MO_VF_Sub _ r -> [r,r] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c35d3f805da2f70cf76fca1d76d984c7a428f42b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c35d3f805da2f70cf76fca1d76d984c7a428f42b You're receiving 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 Nov 3 16:31:33 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 03 Nov 2022 12:31:33 -0400 Subject: [Git][ghc/ghc][wip/T22331] Fix decomposition of TyConApps Message-ID: <6363ece5a6a26_11c7e2d6d96442479bd@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22331 at Glasgow Haskell Compiler / GHC Commits: c2482b5a by Simon Peyton Jones at 2022-11-03T16:32:57+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 6 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/InertSet.hs - compiler/GHC/Tc/Solver/Interact.hs - + testsuite/tests/typecheck/should_compile/T22331.hs - testsuite/tests/typecheck/should_compile/all.T Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -2142,7 +2142,7 @@ isDataTyCon _ = False -- (where X is the role passed in): -- If (T a1 b1 c1) ~X (T a2 b2 c2), then (a1 ~X1 a2), (b1 ~X2 b2), and (c1 ~X3 c2) -- (where X1, X2, and X3, are the roles given by tyConRolesX tc X) --- See also Note [Decomposing equality] in "GHC.Tc.Solver.Canonical" +-- See also Note [Decomposing TyConApp equalities] in "GHC.Tc.Solver.Canonical" isInjectiveTyCon :: TyCon -> Role -> Bool isInjectiveTyCon _ Phantom = False isInjectiveTyCon (FunTyCon {}) _ = True @@ -2163,7 +2163,7 @@ isInjectiveTyCon (TcTyCon {}) _ = True -- | 'isGenerativeTyCon' is true of 'TyCon's for which this property holds -- (where X is the role passed in): -- If (T tys ~X t), then (t's head ~X T). --- See also Note [Decomposing equality] in "GHC.Tc.Solver.Canonical" +-- See also Note [Decomposing TyConApp equalities] in "GHC.Tc.Solver.Canonical" isGenerativeTyCon :: TyCon -> Role -> Bool isGenerativeTyCon (FamilyTyCon { famTcFlav = DataFamilyTyCon _ }) Nominal = True isGenerativeTyCon (FamilyTyCon {}) _ = False ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -1066,7 +1066,8 @@ can_eq_nc' _rewritten _rdr_env _envs ev eq_rel -- See Note [Canonicalising type applications] about why we require rewritten types -- Use tcSplitAppTy, not matching on AppTy, to catch oversaturated type families --- NB: Only decompose AppTy for nominal equality. See Note [Decomposing equality] +-- NB: Only decompose AppTy for nominal equality. +-- See Note [Decomposing AppTy equalities] can_eq_nc' True _rdr_env _envs ev NomEq ty1 _ ty2 _ | Just (t1, s1) <- tcSplitAppTy_maybe ty1 , Just (t2, s2) <- tcSplitAppTy_maybe ty2 @@ -1517,7 +1518,7 @@ can_eq_app :: CtEvidence -- :: s1 t1 ~N s2 t2 -- AppTys only decompose for nominal equality, so this case just leads -- to an irreducible constraint; see typecheck/should_compile/T10494 --- See Note [Decomposing AppTy at representational role] +-- See Note [Decomposing AppTy equalities] can_eq_app ev s1 t1 s2 t2 | CtWanted { ctev_dest = dest, ctev_rewriters = rewriters } <- ev = do { co_s <- unifyWanted rewriters loc Nominal s1 s2 @@ -1584,8 +1585,9 @@ canTyConApp :: CtEvidence -> EqRel -> TyCon -> [TcType] -> TyCon -> [TcType] -> TcS (StopOrContinue Ct) --- See Note [Decomposing TyConApps] --- Neither tc1 nor tc2 is a saturated funTyCon +-- See Note [Decomposing TyConApp equalities] +-- Neither tc1 nor tc2 is a saturated funTyCon, nor a type family +-- But they can be data families. canTyConApp ev eq_rel tc1 tys1 tc2 tys2 | tc1 == tc2 , tys1 `equalLength` tys2 @@ -1614,13 +1616,13 @@ canTyConApp ev eq_rel tc1 tys1 tc2 tys2 ty1 = mkTyConApp tc1 tys1 ty2 = mkTyConApp tc2 tys2 - loc = ctEvLoc ev - pred = ctEvPred ev - - -- See Note [Decomposing equality] + -- See Note [Decomposing TyConApp equalities] can_decompose inerts = isInjectiveTyCon tc1 (eqRelRole eq_rel) - || (ctEvFlavour ev /= Given && isEmptyBag (matchableGivens loc pred inerts)) + || (assert (eq_rel == ReprEq) $ + -- assert: isInjectiveTyCon is always True for Nominal except + -- for type synonyms/families, neither of which happen here + ctEvFlavour ev == Wanted && noGivenIrreds inerts) {- Note [Use canEqFailure in canDecomposableTyConApp] @@ -1654,219 +1656,270 @@ For example, see typecheck/should_compile/T10493, repeated here: That should compile, but only because we use canEqFailure and not canEqHardFailure. -Note [Decomposing equality] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If we have a constraint (of any flavour and role) that looks like -T tys1 ~ T tys2, what can we conclude about tys1 and tys2? The answer, -of course, is "it depends". This Note spells it all out. - -In this Note, "decomposition" refers to taking the constraint - [fl] (T tys1 ~X T tys2) -(for some flavour fl and some role X) and replacing it with - [fls'] (tys1 ~Xs' tys2) -where that notation indicates a list of new constraints, where the -new constraints may have different flavours and different roles. - -The key property to consider is injectivity. When decomposing a Given, the -decomposition is sound if and only if T is injective in all of its type -arguments. When decomposing a Wanted, the decomposition is sound (assuming the -correct roles in the produced equality constraints), but it may be a guess -- -that is, an unforced decision by the constraint solver. Decomposing Wanteds -over injective TyCons does not entail guessing. But sometimes we want to -decompose a Wanted even when the TyCon involved is not injective! (See below.) - -So, in broad strokes, we want this rule: - -(*) Decompose a constraint (T tys1 ~X T tys2) if and only if T is injective -at role X. - -Pursuing the details requires exploring three axes: -* Flavour: Given vs. Wanted -* Role: Nominal vs. Representational -* TyCon species: datatype vs. newtype vs. data family vs. type family vs. type variable - -(A type variable isn't a TyCon, of course, but it's convenient to put the AppTy case -in the same table.) - -Here is a table (discussion following) detailing where decomposition of - (T s1 ... sn) ~r (T t1 .. tn) -is allowed. The first four lines (Data types ... type family) refer -to TyConApps with various TyCons T; the last line is for AppTy, covering -both where there is a type variable at the head and the case for an over- -saturated type family. - -NOMINAL GIVEN WANTED WHERE - -Datatype YES YES canTyConApp -Newtype YES YES canTyConApp -Data family YES YES canTyConApp -Type family NO{1} YES, in injective args{1} canEqCanLHS2 -AppTy YES YES can_eq_app - -REPRESENTATIONAL GIVEN WANTED - -Datatype YES YES canTyConApp -Newtype NO{2} MAYBE{2} canTyConApp(can_decompose) -Data family NO{3} MAYBE{3} canTyConApp(can_decompose) -Type family NO NO canEqCanLHS2 -AppTy NO{4} NO{4} can_eq_nc' - -{1}: Type families can be injective in some, but not all, of their arguments, -so we want to do partial decomposition. This is quite different than the way -other decomposition is done, where the decomposed equalities replace the original -one. We thus proceed much like we do with superclasses, emitting new Wanteds -when "decomposing" a partially-injective type family Wanted. Injective type -families have no corresponding evidence of their injectivity, so we cannot -decompose an injective-type-family Given. - -{2}: See Note [Decomposing newtypes at representational role] - -{3}: Because of the possibility of newtype instances, we must treat -data families like newtypes. See also -Note [Decomposing newtypes at representational role]. See #10534 and -test case typecheck/should_fail/T10534. - -{4}: See Note [Decomposing AppTy at representational role] - - Because type variables can stand in for newtypes, we conservatively do not - decompose AppTys over representational equality. Here are two examples that - demonstrate why we can't: - - 4a: newtype Phant a = MkPhant Int - [W] alpha Int ~R beta Bool - - If we eventually solve alpha := Phant and beta := Phant, then we can solve - this equality by unwrapping. But it would have been disastrous to decompose - the wanted to produce Int ~ Bool, which is definitely insoluble. - - 4b: newtype Age = MkAge Int - [W] alpha Age ~R Maybe Int - - First, a question: if we know that ty1 ~R ty2, can we conclude that - a ty1 ~R a ty2? Not for all a. This is precisely why we need role annotations - on type constructors. So, if we were to decompose, we would need to - decompose to [W] alpha ~R Maybe and [W] Age ~ Int. On the other hand, if we - later solve alpha := Maybe, then we would decompose to [W] Age ~R Int, and - that would be soluble. - -In the implementation of can_eq_nc and friends, we don't directly pattern -match using lines like in the tables above, as those tables don't cover -all cases (what about PrimTyCon? tuples?). Instead we just ask about injectivity, -boiling the tables above down to rule (*). The exceptions to rule (*) are for -injective type families, which are handled separately from other decompositions, -and the MAYBE entries above. - -Note [Decomposing newtypes at representational role] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -This note discusses the 'newtype' line in the REPRESENTATIONAL table -in Note [Decomposing equality]. (At nominal role, newtypes are fully -decomposable.) +Note [Fast path when decomposing TyConApps] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If we see (T s1 t1 ~ T s2 t2), then we can just decompose to + (s1 ~ s2, t1 ~ t2) +and push those back into the work list. But if + s1 = K k1 s2 = K k2 +then we will just decompose s1~s2, and it might be better to +do so on the spot. An important special case is where s1=s2, +and we get just Refl. -Here is a representative example of why representational equality over -newtypes is tricky: +So canDecomposableTyConAppOK uses unifyWanted etc to short-cut that work. - newtype Nt a = Mk Bool -- NB: a is not used in the RHS, - type role Nt representational -- but the user gives it an R role anyway +Note [Decomposing TyConApp equalities] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we have + [G/W] T ty1 ~X T ty2 +Can we decompose it, and replace it by + [G/W] ty1 ~X' ty2 +and if so what role is X'? (In this Note, all the "~" are primitive +equalities "~#", but I have dropped the noisy "#" symbols.) Lots of +background in the paper "Safe zero-cost coercions for Haskell". + +This Note covers the topic for + * Datatypes + * Newtypes + * Data families +For the rest: + * Type synonyms are always expanded + * Type families: see Note [Decomposing type family applications] + * AppTy: see Note [Decomposing AppTy equalities]. + +---- Roles of the decomposed constraints ---- +For a start, the role X' will always be defined like this: + * If X=N then X' = N + * If X=X then X' = role of T's first argument + +For example: + data TR a = MkTR a -- Role of T's first arg is Representational + data TN a = MkTN (F a) -- Role of T's first arg is Nominal + +The function tyConRolesX :: Role -> TyCon -> [Role] gets the argument +role X' for a TyCon T at role X. E.g. + tyConRolesX Nominal TR = [Nominal] + tyConRolesX Representational TR = [Representational] + +---- Soundness and completeness ---- +For Givens, for /soundness/ of decomposition we need: + T ty1 ~X T ty2 ===> ty1 ~X' ty2 +Here "===>" means "implies". That is, given evidence for (co1 : T ty1 ~X T +ty2) we can produce evidence for (co2 : ty1 ~X' ty2). But in the solver we +/replace/ co1 with co2 in the inert set, and we don't want to lose any proofs +thereby. So for /completeness/ of decomposition we also need the reverse: + ty1 ~X' ty2 ===> T ty1 ~X T ty2 + +For Wanteds, for /soundess/ of decomposition we need: + ty1 ~X' ty2 ===> T ty1 ~X T ty2 +because if we do decompose we'll get evidence (co2 : ty1 ~X' ty2) and +from that we want to give evidence for (co1 : co1 : T ty1 ~X T ty2). +For /completeness/ of decomposition we need the reverse implication too, +else we may decompose to a new proof obligiation that is stronger than +the one we started with. See Note [Decomposing newtype equalities]. + +---- Injectivity ---- +When do these bi-implications hold? In one direction it is easy. +We /always/ have + ty1 ~X' ty2 ===> T ty1 ~X T ty2 +This is the CO_TYCONAPP rule of the paper (Fig 5); see also the +TyConAppCo case of GHC.Core.Lint.lintCoercion. + +In the other direction, we have + T ty1 ~X T ty2 ==> ty1 ~X' ty2 if T is /injective at role X/ +This is the very /definition/ of injectivity: injectivity means result +is the same => arguments are the same, modulo the role shift. +See comments on GHC.Core.TyCon.isInjectiveTyCon. This is also +the CO_NTH rule in Fig 5 of the paper, except in the paper only +newtypes are non-injective at representation role, so the rule says "H +is not a newtype". + +Injectivity is a bit subtle: + Nominal Representational + Datatype YES YES + Newtype types YES NO{1} + Data family YES NO{2} + +{1} Consider newtype N a = MkN (F a) -- Arg has Nominal role + Is it true that (N t1) ~R (N t2) ==> t1 ~N t2 ? + No, absolutely not. E.g. + type instance F Int = Int; type instance F Bool = Char + Then (N Int) ~R (N Bool), by unwrapping, but we don't want Int~Char! + + See Note [Decomposing newtype equalities] + +{2} We must treat data families precisely like newtypes, because of the + possibility of newtype instances. See also + Note [Decomposing newtype equalities]. See #10534 and + test case typecheck/should_fail/T10534. + +---- Takeaway summary ----- +For sound and complete decomposition, we simply need injectivity; +that is for isInjectiveTyCon to be true: + +* At Nominal role, isInjectiveTyCon is True for all the TyCons we are + considering in this Note: datatypes, newtypes, and data families. + +* For Givens, injectivity is necessary for soundness; completeness has no + side conditions. + +* For Wanteds, soundness has no side conditions; but injectivity is needed + for completeness. See Note [Decomposing newtype equalities] + +This is implemented in `can_decompose` in `canTyConApp`; it looks at +injectivity, just as specified above. + + +Note [Decomposing type family applications] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Supose we have + [G/W] (F ty1) ~X (F ty2) +This is handled by the TyFamLHS/TyFamLHS case of canEqCanLHS2. + +We never decompose to + [G/W] ty1 ~X' ty2 + +Instead + +* For Givens we do nothing. Injective type families have no corresponding + evidence of their injectivity, so we cannot decompose an + injective-type-family Given. + +* For Wanteds, for the Nominal role only, we emit new Wanteds rather like + functional dependencies, for each injective argument position. + + E.g type family F a b -- injective in first arg, but not second + [W] (F s1 t1) ~N (F s2 t2) + Emit new Wanteds + [W] s1 ~N s2 + But retain the existing, unsolved constraint. + +Note [Decomposing newtype equalities] (also applies to data families) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +As Note [Decomposing TyConApp equalities] describes, if N is injective +at role X, we can do this decomposition? + [G/W] N ty1 ~X N ty2 to [G/W] ty1 ~X' ty2 + +For a Given with X=R, the answer is a solid NO: newtypes are not injective at +representational role, and we must not decompose, or we lose soundness. +Example is wrinkle {1} in Note [Decomposing TyConApp equalities]. + +For a Wanted with X=R, since newtypes are not injective at representational +role, decomposition is sound, but we may lose completeness. But +decomposition is the /only/ way to solve -If we have [W] Nt alpha ~R Nt beta, we *don't* want to decompose to -[W] alpha ~R beta, because it's possible that alpha and beta aren't -representationally equal. Here's another example. + newtype Age = MkAge Int + [W] IO Int ~ IO Age - newtype Nt a = MkNt (Id a) - type family Id a where Id a = a +Conclusion: decompose newtypes (at role R) only as a last resort; but +if nothing else works, decompose in the hope of solving. - [W] Nt Int ~R Nt Age +Why last resort? Because the incompleteness is real. Here are two examples: -Because of its use of a type family, Nt's parameter will get inferred to have -a nominal role. Thus, decomposing the wanted will yield [W] Int ~N Age, which -is unsatisfiable. Unwrapping, though, leads to a solution. +* Incompleteness example (EX1) + newtype Nt a = MkNt (Id a) + type family Id a where Id a = a -Conclusion: - * Unwrap newtypes before attempting to decompose them. - This is done in can_eq_nc'. + [W] Nt Int ~R Nt Age + + Because of its use of a type family, Nt's parameter will get inferred to + have a nominal role. Thus, decomposing the wanted will yield [W] Int ~N + Age, which is unsatisfiable. Unwrapping, though, leads to a solution. -It all comes from the fact that newtypes aren't necessarily injective -w.r.t. representational equality. +* Incompleteness example (EX2) + newtype Nt a = Mk Bool -- NB: a is not used in the RHS, + type role Nt representational -- but the user gives it an R role anyway -Furthermore, as explained in Note [NthCo and newtypes] in GHC.Core.TyCo.Rep, we can't use -NthCo on representational coercions over newtypes. NthCo comes into play -only when decomposing givens. + If we have [W] Nt alpha ~R Nt beta, we *don't* want to decompose to + [W] alpha ~R beta, because it's possible that alpha and beta aren't + representationally equal. + + And maybe there is a Given (Nt t1 ~R Nt t2), just waiting to be used, if we + figure out (elsewhere) that alpha:=t1 and beta:=t2. This is somewhat + similar to the question of overlapping Givens for class constraints: see + Note [Instance and Given overlap] in GHC.Tc.Solver.Interact. Conclusion: - * Do not decompose [G] N s ~R N t + * To avoid (EX1): always unwrap newtypes before attempting to decompose + them. This is done in can_eq_nc'. Of course, we can't unwrap if the data + constructor isn't in scope. See See Note [Unwrap newtypes first]. -Is it sensible to decompose *Wanted* constraints over newtypes? Yes! -It's the only way we could ever prove (IO Int ~R IO Age), recalling -that IO is a newtype. + * To avoid (EX2): don't decompose [W] N s ~R N t, if there are any Given + equalities that could later solve it. -However we must be careful. Consider + But what does "any Given equalities that could later solve it" mean, precisely? + It must be a Given constraint that could turn into N s ~ N t. But that + could include [G] (a b) ~ (c d), or even just [G] c. But it'll definitely + be an CIrredCan. So we settle for having no CIrredCans at all, which is + conservative but safe. See noGivenIrreds and #22331. - type role Nt representational + Well not 100.0% safe. There could be a CDictCan with some un-expanded + superclasses; but only in some very obscure recursive-superclass + situations. - [G] Nt a ~R Nt b (1) - [W] NT alpha ~R Nt b (2) - [W] alpha ~ a (3) +NB: all of this applies equally to data families, which we treat like +newtype in case of 'newtype instance'. -If we focus on (3) first, we'll substitute in (2), and now it's -identical to the given (1), so we succeed. But if we focus on (2) -first, and decompose it, we'll get (alpha ~R b), which is not soluble. -This is exactly like the question of overlapping Givens for class -constraints: see Note [Instance and Given overlap] in GHC.Tc.Solver.Interact. +Note [Decomposing AppTy equalities] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For AppTy all the same questions arise as in +Note [Decomposing TyConApp equalities]. We have -Conclusion: - * Decompose [W] N s ~R N t iff there no given constraint that could - later solve it. + s1 ~X s2, t1 ~N t2 ==> s1 t1 ~X s2 t2 (rule CO_APP) + s1 t1 ~N s2 t2 ==> s1 ~N s2, t1 ~N t2 (CO_LEFT, CO_RIGHT) + +In the first of these, why do we need Nominal equality in (t1 ~N t2)? +See {2} below. -Note [Decomposing AppTy at representational role] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We never decompose AppTy at a representational role. For Givens, doing -so is simply unsound: the LRCo coercion former requires a nominal-roled -arguments. (See (1) for an example of why.) For Wanteds, decomposing -would be sound, but it would be a guess, and a non-confluent one at that. +For sound and complete solving, we need both directions to decompose. So: +* At nominal role, all is well: we have both directions. +* At representational role, decomposition of Givens is unsound (see {1} below; + and decomposition of Wanteds is incomplete. -Here is an example: +Here is an example of the incompleteness for Wanteds: [G] g1 :: a ~R b [W] w1 :: Maybe b ~R alpha a - [W] w2 :: alpha ~ Maybe + [W] w2 :: alpha ~N Maybe -Suppose we see w1 before w2. If we were to decompose, we would decompose -this to become +Suppose we see w1 before w2. If we decompose, using AppCo to prove w1, we get + w1 := AppCo w3 w4 [W] w3 :: Maybe ~R alpha - [W] w4 :: b ~ a + [W] w4 :: b ~N a Note that w4 is *nominal*. A nominal role here is necessary because AppCo -requires a nominal role on its second argument. (See (2) for an example of -why.) If we decomposed w1 to w3,w4, we would then get stuck, because w4 -is insoluble. On the other hand, if we see w2 first, setting alpha := Maybe, -all is well, as we can decompose Maybe b ~R Maybe a into b ~R a. +requires a nominal role on its second argument. (See {2} for an example of +why.) Now we are stuck, because w4 is insoluble. On the other hand, if we +see w2 first, setting alpha := Maybe, all is well, as we can decompose +Maybe b ~R Maybe a into b ~R a. Another example: - newtype Phant x = MkPhant Int - [W] w1 :: Phant Int ~R alpha Bool [W] w2 :: alpha ~ Phant If we see w1 first, decomposing would be disastrous, as we would then try to solve Int ~ Bool. Instead, spotting w2 allows us to simplify w1 to become - [W] w1' :: Phant Int ~R Phant Bool which can then (assuming MkPhant is in scope) be simplified to Int ~R Int, and all will be well. See also Note [Unwrap newtypes first]. -Bottom line: never decompose AppTy with representational roles. +Bottom line: +* Always decompose AppTy at nominal role: can_eq_app +* Never decompose AppTy at representational role (neither Given nor Wanted): + the lack of an equation in can_eq_nc' -(1) Decomposing a Given AppTy over a representational role is simply -unsound. For example, if we have co1 :: Phant Int ~R a Bool (for -the newtype Phant, above), then we surely don't want any relationship -between Int and Bool, lest we also have co2 :: Phant ~ a around. +Extra points +{1} Decomposing a Given AppTy over a representational role is simply + unsound. For example, if we have co1 :: Phant Int ~R a Bool (for + the newtype Phant, above), then we surely don't want any relationship + between Int and Bool, lest we also have co2 :: Phant ~ a around. -(2) The role on the AppCo coercion is a conservative choice, because we don't -know the role signature of the function. For example, let's assume we could -have a representational role on the second argument of AppCo. Then, consider +{2} The role on the AppCo coercion is a conservative choice, because we don't + know the role signature of the function. For example, let's assume we could + have a representational role on the second argument of AppCo. Then, consider data G a where -- G will have a nominal role, as G is a GADT MkG :: G Int @@ -1876,9 +1929,8 @@ have a representational role on the second argument of AppCo. Then, consider co2 :: Age ~R Int -- by newtype axiom co3 = AppCo co1 co2 :: G Age ~R a Int -- by our broken AppCo -and now co3 can be used to cast MkG to have type G Age, in violation of -the way GADTs are supposed to work (which is to use nominal equality). - + and now co3 can be used to cast MkG to have type G Age, in violation of + the way GADTs are supposed to work (which is to use nominal equality). -} canDecomposableTyConAppOK :: CtEvidence -> EqRel @@ -1895,6 +1947,7 @@ canDecomposableTyConAppOK ev eq_rel tc tys1 tys2 -- we are guaranteed that cos has the same length -- as tys1 and tys2 -> do { cos <- zipWith4M (unifyWanted rewriters) new_locs tc_roles tys1 tys2 + -- See Note [Fast path when decomposing TyConApps] ; setWantedEq dest (mkTyConAppCo role tc cos) } CtGiven { ctev_evar = evar } @@ -1910,11 +1963,11 @@ canDecomposableTyConAppOK ev eq_rel tc tys1 tys2 ; stopWith ev "Decomposed TyConApp" } where - loc = ctEvLoc ev - role = eqRelRole eq_rel + loc = ctEvLoc ev + role = eqRelRole eq_rel - -- infinite, as tyConRolesX returns an infinite tail of Nominal - tc_roles = tyConRolesX role tc + -- Infinite, as tyConRolesX returns an infinite tail of Nominal + tc_roles = tyConRolesX role tc -- Add nuances to the location during decomposition: -- * if the argument is a kind argument, remember this, so that error @@ -1966,19 +2019,6 @@ canEqHardFailure ev ty1 ty2 ; continueWith (mkIrredCt ShapeMismatchReason new_ev) } {- -Note [Decomposing TyConApps] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If we see (T s1 t1 ~ T s2 t2), then we can just decompose to - (s1 ~ s2, t1 ~ t2) -and push those back into the work list. But if - s1 = K k1 s2 = K k2 -then we will just decompose s1~s2, and it might be better to -do so on the spot. An important special case is where s1=s2, -and we get just Refl. - -So canDecomposableTyCon is a fast-path decomposition that uses -unifyWanted etc to short-cut that work. - Note [Canonicalising type applications] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given (s1 t1) ~ ty2, how should we proceed? @@ -2213,6 +2253,7 @@ canEqCanLHS2 ev eq_rel swapped lhs1 ps_xi1 lhs2 ps_xi2 mco | TyFamLHS fun_tc1 fun_args1 <- lhs1 , TyFamLHS fun_tc2 fun_args2 <- lhs2 + -- See Note [Decomposing type family applications] = do { traceTcS "canEqCanLHS2 two type families" (ppr lhs1 $$ ppr lhs2) -- emit wanted equalities for injective type families ===================================== compiler/GHC/Tc/Solver/InertSet.hs ===================================== @@ -20,7 +20,8 @@ module GHC.Tc.Solver.InertSet ( emptyInert, addInertItem, - matchableGivens, + noMatchableGivenDicts, + noGivenIrreds, mightEqualLater, prohibitedSuperClassSolve, @@ -53,6 +54,7 @@ import GHC.Core.Reduction import GHC.Core.Predicate import GHC.Core.TyCo.FVs import qualified GHC.Core.TyCo.Rep as Rep +import GHC.Core.Class( Class ) import GHC.Core.TyCon import GHC.Core.Unify @@ -1535,25 +1537,20 @@ isOuterTyVar tclvl tv -- becomes "outer" even though its level numbers says it isn't. | otherwise = False -- Coercion variables; doesn't much matter --- | Returns Given constraints that might, --- potentially, match the given pred. This is used when checking to see if a +noGivenIrreds :: InertSet -> Bool +noGivenIrreds (IS { inert_cans = inert_cans }) + = isEmptyBag (inert_irreds inert_cans) + +-- | Returns True iff there are no Given constraints that might, +-- potentially, match the given class consraint. This is used when checking to see if a -- Given might overlap with an instance. See Note [Instance and Given overlap] -- in "GHC.Tc.Solver.Interact" -matchableGivens :: CtLoc -> PredType -> InertSet -> Cts -matchableGivens loc_w pred_w inerts@(IS { inert_cans = inert_cans }) - = filterBag matchable_given all_relevant_givens +noMatchableGivenDicts :: InertSet -> CtLoc -> Class -> [TcType] -> Bool +noMatchableGivenDicts inerts@(IS { inert_cans = inert_cans }) loc_w clas tys + = not $ anyBag matchable_given $ + findDictsByClass (inert_dicts inert_cans) clas where - -- just look in class constraints and irreds. matchableGivens does get called - -- for ~R constraints, but we don't need to look through equalities, because - -- canonical equalities are used for rewriting. We'll only get caught by - -- non-canonical -- that is, irreducible -- equalities. - all_relevant_givens :: Cts - all_relevant_givens - | Just (clas, _) <- getClassPredTys_maybe pred_w - = findDictsByClass (inert_dicts inert_cans) clas - `unionBags` inert_irreds inert_cans - | otherwise - = inert_irreds inert_cans + pred_w = mkClassPred clas tys matchable_given :: Ct -> Bool matchable_given ct ===================================== compiler/GHC/Tc/Solver/Interact.hs ===================================== @@ -1385,7 +1385,7 @@ We generate these Wanteds in three places, depending on how we notice the injectivity. 1. When we have a [W] F tys1 ~ F tys2. This is handled in canEqCanLHS2, and -described in Note [Decomposing equality] in GHC.Tc.Solver.Canonical. +described in Note [Decomposing type family applications] in GHC.Tc.Solver.Canonical. 2. When we have [W] F tys1 ~ T and [W] F tys2 ~ T. Note that neither of these constraints rewrites the other, as they have different LHSs. This is done @@ -2277,11 +2277,9 @@ matchClassInst dflags inerts clas tys loc -- See Note [Instance and Given overlap] | not (xopt LangExt.IncoherentInstances dflags) , not (naturallyCoherentClass clas) - , let matchable_givens = matchableGivens loc pred inerts - , not (isEmptyBag matchable_givens) + , not (noMatchableGivenDicts inerts loc clas tys) = do { traceTcS "Delaying instance application" $ - vcat [ text "Work item=" <+> pprClassPred clas tys - , text "Potential matching givens:" <+> ppr matchable_givens ] + vcat [ text "Work item=" <+> pprClassPred clas tys ] ; return NotSure } | otherwise ===================================== testsuite/tests/typecheck/should_compile/T22331.hs ===================================== @@ -0,0 +1,15 @@ +{-# LANGUAGE TypeFamilies #-} + +module T22331 where + +import Data.Coerce + +data family Fool a + +-- This works +joe :: Coercible (Fool a) (Fool b) => Fool a -> Fool b +joe = coerce + +-- This does not +bob :: Coercible (Fool a) (Fool b) => Fool b -> Fool a +bob = coerce ===================================== testsuite/tests/typecheck/should_compile/all.T ===================================== @@ -850,3 +850,4 @@ test('T21951a', normal, compile, ['-Wredundant-strictness-flags']) test('T21951b', normal, compile, ['-Wredundant-strictness-flags']) test('T21550', normal, compile, ['']) test('T22310', normal, compile, ['']) +test('T22331', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2482b5aee0c6cc293fb9daa4a15e58f8bc36a9e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c2482b5aee0c6cc293fb9daa4a15e58f8bc36a9e You're receiving 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 Nov 3 20:19:48 2022 From: gitlab at gitlab.haskell.org (doyougnu (@doyougnu)) Date: Thu, 03 Nov 2022 16:19:48 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 3 commits: Hadrian: add perf_stage0 transformer Message-ID: <63642264d7b7c_11c7e24b820271919@gitlab.mail> doyougnu pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 9384b03f by doyougnu at 2022-11-03T16:19:36-04:00 Hadrian: add perf_stage0 transformer - - - - - cae4b93b by doyougnu at 2022-11-03T16:19:36-04:00 Hadrian: remove javascript specific flavours - - - - - 4a6dfe4a by doyougnu at 2022-11-03T16:19:36-04:00 Hadrian: update docs with new transformers Specifically: - ticky_ghc0 - perf_stage0 - no_dynamic_libs - - - - - 5 changed files: - hadrian/doc/flavours.md - hadrian/hadrian.cabal - hadrian/src/Flavour.hs - hadrian/src/Settings.hs - − hadrian/src/Settings/Flavours/JavaScript.hs Changes: ===================================== hadrian/doc/flavours.md ===================================== @@ -211,6 +211,15 @@ The supported transformers are listed below: ticky_ghc Compile the GHC executable with Ticky-Ticky profiler support. + + ticky_ghc0 + Compile the stage0 GHC executable with Ticky-Ticky profiler support. Useful for cross-compilers, which are always stage1 compilers + + + perf_stage0 + Ensure that the `-O2` flags are passed to the stage0 build thus yielding an optimised stage1 compiler. Useful for cross-compilers, which are always stage1 compilers + + split_sections Enable section splitting for all libraries (except for the GHC @@ -239,6 +248,11 @@ The supported transformers are listed below: default to loading static rather than dynamic library when, e.g., loading libraries during TemplateHaskell evaluations. + + no_dynamic_libs + Just like `no_dynamic_ghc`, this transformer ensures statically-linked libraries + + no_profiled_libs Disables building of libraries in profiled build ways. ===================================== hadrian/hadrian.cabal ===================================== @@ -125,7 +125,6 @@ executable hadrian , Settings.Flavours.Quickest , Settings.Flavours.Validate , Settings.Flavours.Release - , Settings.Flavours.JavaScript , Settings.Packages , Settings.Parser , Settings.Program ===================================== hadrian/src/Flavour.hs ===================================== @@ -10,7 +10,7 @@ module Flavour , enableDebugInfo, enableTickyGhc , viaLlvmBackend , enableProfiledGhc - , enableO2Stage0 + , perfStage0 , disableDynamicGhcPrograms , disableDynamicLibs , disableProfiledLibs @@ -39,6 +39,7 @@ import Control.Monad.Except import UserSettings import Oracles.Setting +import {-# SOURCE #-} Settings.Default flavourTransformers :: Map String (Flavour -> Flavour) flavourTransformers = M.fromList @@ -46,7 +47,7 @@ flavourTransformers = M.fromList , "debug_info" =: enableDebugInfo , "ticky_ghc" =: enableTickyGhc , "ticky_ghc0" =: enableTickyGhc0 - , "optimize_stage0" =: enableO2Stage0 + , "perf_stage0" =: perfStage0 , "split_sections" =: splitSections , "thread_sanitizer" =: enableThreadSanitizer , "llvm" =: viaLlvmBackend @@ -113,9 +114,6 @@ parseFlavour baseFlavours transformers str = addArgs :: Args -> Flavour -> Flavour addArgs args' fl = fl { args = args fl <> args' } -onArgs :: (Args -> Args) -> Flavour -> Flavour -onArgs f fl = fl { args = f $ args fl} - -- | Turn on -Werror for packages built with the stage1 compiler. -- It mimics the CI settings so is useful to turn on when developing. werror :: Flavour -> Flavour @@ -139,9 +137,20 @@ enableTickyGhc = ] -- | Enable the ticky-ticky profiler in stage1 GHC -enableO2Stage0 :: Flavour -> Flavour -enableO2Stage0 fl = onArgs ensureO2 fl - where ensureO2 as = (builder Ghc ? stage0 ? arg "-O2") <> remove ["-O"] as +perfStage0 :: Flavour -> Flavour +perfStage0 fl = addArgs args fl + -- This is a bit sloppy because it does not preclude any predicates that turn + -- on (or off) optimizations that were added be the flavor or by another + -- transformer. Luckily though if we're using this transformer then we want O2 + -- for each subsequent stage and ghc doesn't choke on the redundant flags + -- There is the remove in Hadrian.Expression but it doesn't handle predicates + where + args = sourceArgs SourceArgs + { hsDefault = mconcat [ arg "-O2", arg "-H64m"] + , hsLibrary = arg "-O2" + , hsCompiler = arg "-O2" + , hsGhc = arg "-O2" + } -- | Enable the ticky-ticky profiler in stage1 GHC enableTickyGhc0 :: Flavour -> Flavour ===================================== hadrian/src/Settings.hs ===================================== @@ -23,7 +23,6 @@ import Settings.Flavours.Quickest import Settings.Flavours.QuickCross import Settings.Flavours.Validate import Settings.Flavours.Release -import Settings.Flavours.JavaScript getArgs :: Args @@ -54,12 +53,10 @@ hadrianFlavours :: [Flavour] hadrianFlavours = [ benchmarkFlavour, defaultFlavour, developmentFlavour Stage1 , developmentFlavour Stage2, performanceFlavour - , releaseFlavour, releaseJsFlavour + , releaseFlavour , quickFlavour, quickValidateFlavour, quickDebugFlavour , quickestFlavour , quickCrossFlavour - , quickJsFlavour - , perfJsFlavour , ghcInGhciFlavour, validateFlavour, slowValidateFlavour ] ===================================== hadrian/src/Settings/Flavours/JavaScript.hs deleted ===================================== @@ -1,57 +0,0 @@ -module Settings.Flavours.JavaScript - ( quickJsFlavour - , perfJsFlavour - , releaseJsFlavour - ) where - -import qualified Data.Set as Set - -import Flavour -import Expression -import Settings.Flavours.Performance -import {-# SOURCE #-} Settings.Default - -releaseJsFlavour :: Flavour -releaseJsFlavour = disableDynamicLibs - . disableDynamicGhcPrograms - . disableProfiledLibs - . enableO2Stage0 - . useNativeBignum - $ performanceFlavour { name = "release-js" } - -quickJsFlavour :: Flavour -quickJsFlavour = defaultFlavour - { name = "quick-js" - , args = defaultBuilderArgs <> quickJsArgs <> defaultPackageArgs - , dynamicGhcPrograms = pure False - , libraryWays = pure $ Set.singleton vanilla - , rtsWays = pure $ Set.singleton vanilla - } - -perfJsFlavour :: Flavour -perfJsFlavour = defaultFlavour - { name = "perf-js" - , args = defaultBuilderArgs <> perfJsArgs <> defaultPackageArgs - , dynamicGhcPrograms = pure False - , libraryWays = pure $ Set.singleton vanilla - , rtsWays = pure $ Set.singleton vanilla - } - -quickJsArgs :: Args -quickJsArgs = sourceArgs SourceArgs - { hsDefault = mconcat $ - [ pure ["-O0", "-H64m"] - ] - , hsLibrary = notStage0 ? mconcat [ arg "-O" ] - , hsCompiler = stage0 ? arg "-O2" - , hsGhc = mconcat - [ stage0 ? arg "-O" - , stage1 ? mconcat [ arg "-O0" ] ] } - -perfJsArgs :: Args -perfJsArgs = sourceArgs SourceArgs - { hsDefault = mconcat [ arg "-O2", arg "-H64m"] - , hsLibrary = arg "-O2" - , hsCompiler = arg "-O2" - , hsGhc = arg "-O2" - } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/978f301075f3fa8505a2614aaaf3ec0486a912c3...4a6dfe4a83165977b43e996fda15cb7876d62b84 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/978f301075f3fa8505a2614aaaf3ec0486a912c3...4a6dfe4a83165977b43e996fda15cb7876d62b84 You're receiving 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 Nov 3 20:35:45 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Thu, 03 Nov 2022 16:35:45 -0400 Subject: [Git][ghc/ghc][ghc-9.2] 19 commits: Revert "Fix combination of ArityType in andArityType" Message-ID: <63642621e9164_11c7e2103b8778279889@gitlab.mail> Zubin pushed to branch ghc-9.2 at Glasgow Haskell Compiler / GHC Commits: 8b839c33 by Zubin Duggal at 2022-10-11T11:12:07+01:00 Revert "Fix combination of ArityType in andArityType" This reverts commit 74ef2853464255a86d88fda619eb68b08b52e689. - - - - - c45387ce by Simon Peyton Jones at 2022-10-26T15:39:08+05:30 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694 and #21755 * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * I realised that, now we have ae_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. And finally, it was the strange treatment of join-point Ids (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring * Rewrote Note [Combining case branches: optimistic one-shot-ness] Compile time improves slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- CoOpt_Read(normal) ghc/alloc 803,788,056 747,832,680 -7.1% GOOD T18223(normal) ghc/alloc 928,207,320 959,424,016 +3.1% BAD geo. mean -0.3% minimum -7.1% maximum +3.1% On Windows it's a bit better: geo mean is -0.6%, and three more benchmarks trip their compile-time bytes-allocated threshold (they were all close on the other build): T18698b(normal) ghc/alloc 235,619,776 233,219,008 -1.0% GOOD T6048(optasm) ghc/alloc 112,208,192 109,704,936 -2.2% GOOD T18140(normal) ghc/alloc 85,064,192 83,168,360 -2.2% GOOD I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3.4% increase in exchange for goodness elsewhere. Metric Decrease: CoOpt_Read T18140 T18698b T6048 Metric Increase: T18223 - - - - - 8a38c548 by Ben Gamari at 2022-10-26T15:39:08+05:30 rts: Don't clear cards of zero-length arrays Fix #21962, where attempting to clear the card table of a zero-length array resulted in an integer underflow. - - - - - 17552468 by Cheng Shao at 2022-10-26T15:39:08+05:30 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh (cherry picked from commit ee471dfb8a4a4bb5131a5baa61d1d0d22c933d5f) - - - - - 4d047b3c by Matthew Pickering at 2022-10-26T15:39:08+05:30 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 (cherry picked from commit 7f0decd5063a853fc8f38a8944b2c91995cd5e48) - - - - - 9e254001 by Ben Gamari at 2022-10-26T15:39:08+05:30 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. (cherry picked from commit 62a550010ed94e1969c96150f2781854a0802766) - - - - - 74e329d2 by Ben Gamari at 2022-10-26T15:39:08+05:30 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. (cherry picked from commit 8eff62a43cebbb21f00aeea138bcc343d8ac8f34) - - - - - 064371d3 by Douglas Wilson at 2022-10-26T15:39:09+05:30 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. (cherry picked from commit 76b52cf0c52ee05c20f7d1b80f5600eecab3c42a) - - - - - 2821391a by Douglas Wilson at 2022-10-26T15:39:09+05:30 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. (cherry picked from commit 7589ee7241d46b393979d98d4ded17a15ee974fb) - - - - - 7ad76d79 by Tamar Christina at 2022-10-26T15:39:09+05:30 winio: do not re-translate input when handle is uncooked (cherry picked from commit 626652f7c172f307bd87afaee59c7f0e2825c55d) - - - - - 63fe2ee2 by Sebastian Graf at 2022-11-03T14:21:10+05:30 Rubbish literals for all representations (#18983) This patch cleans up the complexity around WW's `mk_absent_let` by broadening the scope of `LitRubbish`. Rubbish literals now store the `PrimRep` they represent and are ultimately lowered in Cmm. This in turn allows absent literals of `VecRep` or `VoidRep`. The latter allows absent literals for unlifted coercions, as requested in #18983. I took the liberty to rewrite and clean up `Note [Absent fillers]` and `Note [Rubbish values]` to account for the new implementation and to make them more orthogonal in their description. I didn't add a new regression test, as `T18982` already contains the test in the ticket and its test output changes as expected. Fixes #18983. - - - - - 1fabaae4 by Dai at 2022-11-03T15:12:38+05:30 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 (cherry picked from commit 5b3a992f5d166007c3c5a22f120ed08e0a27f01a) - - - - - 9d469bff by sheaf at 2022-11-03T15:12:38+05:30 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. (cherry picked from commit 3be48877e204fca8e5d5ab984186e0d20d81f262) - - - - - 14e0442e by sheaf at 2022-11-03T15:12:38+05:30 Disable some SIMD tests on non-X86 architectures (cherry picked from commit f7b7a3122185222d5059e37315991afcf319e43c) - - - - - 45459cce by Zubin Duggal at 2022-11-03T15:12:38+05:30 Bump process to 1.6.16.0 - - - - - 5674eb8b by Zubin Duggal at 2022-11-03T15:12:38+05:30 Attemp fix for core lint failures For an expression: joinrec foo = ... in expr we compute the arityType as `foldr andArityType (arityType expr) [arityType foo]` which is the same as `andArityType (arityType expr) (arityType foo)`. However, this is incorrect: joinrec go x = ... in go 0 then the arity of go is 1 (\?. T), but the arity of the overall expression is 0 (_|_). `andArityType` however returns (\?. T) for these, which is wrong. (cherry picked from commit 53235edd478bd4c5e29e4f254ce02559af259dd5) - - - - - 36cfeb7c by Zubin Duggal at 2022-11-03T15:12:38+05:30 Bump base to 4.16.4.0 and add release notes - - - - - 3588c3a9 by Zubin Duggal at 2022-11-03T15:12:38+05:30 Fix bkpcabal02 - - - - - c35d3f80 by Zubin Duggal at 2022-11-03T17:15:22+05:30 Fix core lint errors to do with SIMD vector indexing in T22187_run. This patch was originally from 6d7d91817795d7ee7f45557411368a1738daa488, but all the changes in that commit can't make it because we don't want to change the interface of primops in a backport. - - - - - 30 changed files: - compiler/GHC/Builtin/Types/Prim.hs - compiler/GHC/Cmm/LayoutStack.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/Iface/Ext/Types.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/StgToCmm/ArgRep.hs - compiler/GHC/StgToCmm/Env.hs - compiler/GHC/StgToCmm/Expr.hs - + compiler/GHC/StgToCmm/Expr.hs-boot - compiler/GHC/StgToCmm/Foreign.hs - compiler/GHC/StgToCmm/Heap.hs - compiler/GHC/StgToCmm/Layout.hs - + compiler/GHC/StgToCmm/Lit.hs - compiler/GHC/StgToCmm/Monad.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/StgToCmm/Prof.hs - compiler/GHC/StgToCmm/Ticky.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a54827e0b48af33fa9cfde6ad131c6751c2fe321...c35d3f805da2f70cf76fca1d76d984c7a428f42b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a54827e0b48af33fa9cfde6ad131c6751c2fe321...c35d3f805da2f70cf76fca1d76d984c7a428f42b You're receiving 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 Nov 3 20:35:48 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Thu, 03 Nov 2022 16:35:48 -0400 Subject: [Git][ghc/ghc] Deleted branch wip/mp-9.2.5-backports Message-ID: <63642624a631a_11c7e25152c2800f1@gitlab.mail> Matthew Pickering deleted branch wip/mp-9.2.5-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 Thu Nov 3 20:47:40 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 03 Nov 2022 16:47:40 -0400 Subject: [Git][ghc/ghc] Pushed new tag ghc-9.4.3-release Message-ID: <636428ecdc480_11c7e2d48d6b02844a0@gitlab.mail> Ben Gamari pushed new tag ghc-9.4.3-release at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.4.3-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 Thu Nov 3 20:50:06 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 03 Nov 2022 16:50:06 -0400 Subject: [Git][ghc/ghc][wip/backports-9.4] 2 commits: Revert "base: Move CString, CStringLen to GHC.Foreign" Message-ID: <6364297e99e96_11c7e24b8202864f7@gitlab.mail> Ben Gamari pushed to branch wip/backports-9.4 at Glasgow Haskell Compiler / GHC Commits: 8f8dba01 by Ben Gamari at 2022-11-02T21:38:59-04:00 Revert "base: Move CString, CStringLen to GHC.Foreign" This reverts commit 5ec22f0135483ea8a8a543c53dcc7f9d7f6a8dea. - - - - - 20712855 by Ben Gamari at 2022-11-03T16:49:43-04:00 Set RELEASE=NO - - - - - 3 changed files: - configure.ac - libraries/base/Foreign/C/String.hs - libraries/base/GHC/Foreign.hs Changes: ===================================== configure.ac ===================================== @@ -13,7 +13,7 @@ dnl # see what flags are available. (Better yet, read the documentation!) # -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.3], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) +AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.4], [glasgow-haskell-bugs at haskell.org], [ghc-AC_PACKAGE_VERSION]) # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable # to be useful (cf #19058). However, the version must have three components # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are @@ -22,7 +22,7 @@ AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.4.3], [glasgow-has AC_CONFIG_MACRO_DIRS([m4]) # Set this to YES for a released version, otherwise NO -: ${RELEASE=YES} +: ${RELEASE=NO} # The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line # above. If this is not a released version, then we will append the ===================================== libraries/base/Foreign/C/String.hs ===================================== @@ -110,11 +110,20 @@ import GHC.Base import {-# SOURCE #-} GHC.IO.Encoding import qualified GHC.Foreign as GHC -import GHC.Foreign (CString, CStringLen) ----------------------------------------------------------------------------- -- Strings +-- representation of strings in C +-- ------------------------------ + +-- | A C string is a reference to an array of C characters terminated by NUL. +type CString = Ptr CChar + +-- | A string with explicit length information in bytes instead of a +-- terminating NUL (allowing NUL characters in the middle of the string). +type CStringLen = (Ptr CChar, Int) + -- exported functions -- ------------------ -- ===================================== libraries/base/GHC/Foreign.hs ===================================== @@ -19,7 +19,6 @@ module GHC.Foreign ( -- * C strings with a configurable encoding - CString, CStringLen, -- conversion of C strings into Haskell strings -- @@ -75,11 +74,8 @@ putDebugMsg | c_DEBUG_DUMP = debugLn | otherwise = const (return ()) --- | A C string is a reference to an array of C characters terminated by NUL. +-- These definitions are identical to those in Foreign.C.String, but copied in here to avoid a cycle: type CString = Ptr CChar - --- | A string with explicit length information in bytes instead of a --- terminating NUL (allowing NUL characters in the middle of the string). type CStringLen = (Ptr CChar, Int) -- exported functions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f4200e2219606e73d051f0e2de98cf75d72bd683...2071285563fc705917873704a52eb4f6dd337651 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f4200e2219606e73d051f0e2de98cf75d72bd683...2071285563fc705917873704a52eb4f6dd337651 You're receiving 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 Nov 3 23:22:43 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Thu, 03 Nov 2022 19:22:43 -0400 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve] GHC and check-exact compile Message-ID: <63644d4347ead_11c7e24b8202947eb@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve at Glasgow Haskell Compiler / GHC Commits: abbaa6d6 by Alan Zimmerman at 2022-11-03T23:22:30+00:00 GHC and check-exact compile - - - - - 30 changed files: - compiler/GHC/Hs/Dump.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Hs/Utils.hs - compiler/GHC/HsToCore/Arrows.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/HsToCore/Quote.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Iface/Ext/Utils.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Parser/PostProcess/Haddock.hs - compiler/GHC/Rename/Bind.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Rename/Splice.hs - compiler/GHC/Rename/Utils.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Tc/Deriv/Generate.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Expr.hs - compiler/GHC/Tc/Gen/Head.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Gen/Match.hs - compiler/GHC/Tc/Gen/Rule.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Module.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Class.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abbaa6d604ee79afebdd095e0486ae23a8aa0de6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/abbaa6d604ee79afebdd095e0486ae23a8aa0de6 You're receiving 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 Nov 4 00:37:36 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 03 Nov 2022 20:37:36 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: gen-dll: Drop it Message-ID: <63645ed0aa87_11c7e2103b877830152e@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 9c345b11 by Andreas Klebinger at 2022-11-03T20:37:21-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 30 changed files: - .gitignore - CODEOWNERS - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/List/SetOps.hs - compiler/GHC/Driver/Config/StgToCmm.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cca7280205f195900cf3fb9d3170cb832b359250...9c345b11c5f7b150b84bb4c90b1a3dfd4ac4b3ef -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cca7280205f195900cf3fb9d3170cb832b359250...9c345b11c5f7b150b84bb4c90b1a3dfd4ac4b3ef You're receiving 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 Nov 4 03:07:46 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 03 Nov 2022 23:07:46 -0400 Subject: [Git][ghc/ghc][master] Fix haddocks for GHC.IORef Message-ID: <63648202c34ea_11c7e2103b878c3176e9@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 1 changed file: - libraries/base/GHC/IORef.hs Changes: ===================================== libraries/base/GHC/IORef.hs ===================================== @@ -51,7 +51,7 @@ readIORef (IORef var) = stToIO (readSTRef var) writeIORef :: IORef a -> a -> IO () writeIORef (IORef var) v = stToIO (writeSTRef var v) --- Atomically apply a function to the contents of an 'IORef', +-- | Atomically apply a function to the contents of an 'IORef', -- installing its first component in the 'IORef' and returning -- the old contents and the result of applying the function. -- The result of the function application (the pair) is not forced. @@ -62,7 +62,7 @@ atomicModifyIORef2Lazy (IORef (STRef r#)) f = IO (\s -> case atomicModifyMutVar2# r# f s of (# s', old, res #) -> (# s', (old, res) #)) --- Atomically apply a function to the contents of an 'IORef', +-- | Atomically apply a function to the contents of an 'IORef', -- installing its first component in the 'IORef' and returning -- the old contents and the result of applying the function. -- The result of the function application (the pair) is forced, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/634da448dd9296297eeb98f9552bc256b373a6f5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/634da448dd9296297eeb98f9552bc256b373a6f5 You're receiving 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 Nov 4 03:08:26 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 03 Nov 2022 23:08:26 -0400 Subject: [Git][ghc/ghc][master] Export pprTrace and friends from GHC.Prelude. Message-ID: <6364822ad035b_11c7e2d43bcfc32133c@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 30 changed files: - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/List/SetOps.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Env.hs - compiler/GHC/HsToCore/Binds.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/311251543f2e37af4a121e58028bfc46267a7fc9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/311251543f2e37af4a121e58028bfc46267a7fc9 You're receiving 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 Nov 4 08:27:46 2022 From: gitlab at gitlab.haskell.org (Bryan R (@chreekat)) Date: Fri, 04 Nov 2022 04:27:46 -0400 Subject: [Git][ghc/ghc][wip/fix-nightly-22396] 17 commits: rts: introduce (and use) `STG_NORETURN` Message-ID: <6364cd02f02c3_11c7e2103b878c3415ce@gitlab.mail> Bryan R pushed to branch wip/fix-nightly-22396 at Glasgow Haskell Compiler / GHC Commits: 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - CODEOWNERS - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/List/SetOps.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d689d8ff98dc732a47dbe808541563d58ca53189...bdc8cbb3a0808632fc6b33a7e3c10212f5d8a5e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d689d8ff98dc732a47dbe808541563d58ca53189...bdc8cbb3a0808632fc6b33a7e3c10212f5d8a5e9 You're receiving 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 Nov 4 09:43:08 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 04 Nov 2022 05:43:08 -0400 Subject: [Git][ghc/ghc][wip/T21851] 80 commits: Allow configuration of error message printing Message-ID: <6364deac38cd6_11c7e2103b878c3605e5@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851 at Glasgow Haskell Compiler / GHC Commits: e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 06793236 by Simon Peyton Jones at 2022-11-04T09:44:51+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. - - - - - 12be4edd by Simon Peyton Jones at 2022-11-04T09:44:51+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - e9617b84 by Simon Peyton Jones at 2022-11-04T09:44:51+00:00 Fix error message The error message was just wrong; trivial fix - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/primops.txt.pp - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/Cmm/Info/Build.hs - compiler/GHC/Cmm/Lint.hs - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/Base.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Make.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd14412ffd83854091f534f7007ba43ca3d4137e...e9617b84aff7ad41e19d3d610af41adb0b48b744 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd14412ffd83854091f534f7007ba43ca3d4137e...e9617b84aff7ad41e19d3d610af41adb0b48b744 You're receiving 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 Nov 4 10:09:57 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Fri, 04 Nov 2022 06:09:57 -0400 Subject: [Git][ghc/ghc][ghc-9.2] Add notes for 9.2.5 Message-ID: <6364e4f57cf71_11c7e219fb71743728b@gitlab.mail> Zubin pushed to branch ghc-9.2 at Glasgow Haskell Compiler / GHC Commits: 784324bc by Zubin Duggal at 2022-11-04T15:39:38+05:30 Add notes for 9.2.5 - - - - - 1 changed file: - + docs/users_guide/9.2.5-notes.rst Changes: ===================================== docs/users_guide/9.2.5-notes.rst ===================================== @@ -0,0 +1,84 @@ +.. _release-9-2-5: + +Version 9.2.5 +============== + +The significant changes to the various parts of the compiler are listed in the +following sections. + +The :ghc-flag:`LLVM backend <-fllvm>` of this release is to be used with LLVM +9, 10, 11, or 12. + +Compiler +-------- + +- Fix a number of issues with the simplifier leading to core lint errors and suboptimal + performance (:ghc-ticket:`21694`, :ghc-ticket:`21755`, :ghc-ticket:`22114`). + +- Fix a sign extension bug resulting in incorrent runtime results on the native aarch64 backend (:ghc-ticket:`22282`). + +- Improve determinism by not inclusing build directories in interface files (:ghc-ticket:`22162`). + +- Fix a code generation panic when using SIMD types with unboxed sums (:ghc-ticket:`22187`). + +Runtime system +-------------- + +- Fix a bug where attempting to clear the card table of a zero-length + array resulted in an integer underflow (:ghc-ticket:`21962`). + +Core libraries +-------------- + +- Bump ``base`` to 4.16.3.0. + +- Bump ``process`` to 1.6.16.0 + +- base: Fix races in the IOManager to do with the ``setNumCapabilities`` and ``closeFdWith`` functions (:ghc-ticket:`21651`) + + +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 ``ghc`` and ``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 + + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/784324bce728e55e3f304822dff4ad23bbded807 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/784324bce728e55e3f304822dff4ad23bbded807 You're receiving 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 Nov 4 10:25:10 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 04 Nov 2022 06:25:10 -0400 Subject: [Git][ghc/ghc][wip/T21623] 53 commits: Drop a kludge for binutils<2.17, which is now over 10 years old. Message-ID: <6364e88612133_11c7e2d6d96443748be@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - a75727b5 by Simon Peyton Jones at 2022-11-04T10:26:51+00:00 Start work Not ready for review More progress Wibbles Stage1 compiles More wibbles More wibbles More -- almost working Comments Wibbles Wibbles Wibble inlineId Wibbles Infinite loop somewhere More wibbles. Maybe can build stage2 Make FuNCo a thing by itself Wibble Wibble Wibbles Fix OptCoercion Wibble Wibble to optCoercion Replace SORT with TYPE and CONSTRAINT Wibble Delete unused import Delete TypeOrConstraint from ghc-prim:GHC.Types Move from NthCo to SelCo Wibbles Wibbles in RepType Wibble Add mkWpEta Really add mkWpEta Wibble Typeable binds etc Improve error messages More wibbles, mainly to error messages Wibbles Wibbles to errors Wibbles But especially: treat Constraint as Typeable More wibbles More changes * Move role into SelTyCon * Get rid of mkTcSymCo and friends Unused variable Wibbles Wibble Accept error message changes Refactoring... Remove tc functions like tcKind, tcGetTyVar. Move tyConsOfType, occCheckExpand to TyCo.FVs. Introduce GHC.Core.TyCo.Compare Lots of import changes! Update haddock submodule (I hope) Wibbles (notably: actually add GHC.Core.TyCo.Compare) Wibbles Wibble output of T16575 Wibbles More wibbles Remove infinite loop in T1946 See Note [ForAllTy and type equality] Deal with rejigConRes Needs a Note to be written by Richard Some renaming AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag Update haddock submodule Rename TyCoBinder to ForAllTyBinder Wibbles Update haddock Wibble Update unix submodule I think I accidentally got it out of sync with HEAD; this puts it back. Rename TyCoBinder to PiTyBinder Update Haddock submodule Wrap dictionaries in tuples This fixes the kind bugs in arrow desugaring. Needs some Notes, but I want to try CI. More on boxing data cons Rebase and update GHC.Tc.Errors/GHC.Tc.Errors.Ppr Revert accidental changes in SameOccInfo fixes mod180, tcfail182 Wibbles in error messages ..plus eqType comes from GHC.Core.TyCo.Compare Wibbles More wibbles Reaedy for RAE review Fix fragile rule setup in GHC.Float See Note [realToFrac natural-to-float] Wibbles More wibbles Remove unused import Remove another unused import Wibbles Update haddock submodule Respond to Sam's suggestions Wibbles Wibbles - - - - - 6b0e7625 by Simon Peyton Jones at 2022-11-04T10:26:51+00:00 Wibbles - - - - - 55e4eb8f by Simon Peyton Jones at 2022-11-04T10:26:51+00:00 Unused import - - - - - 9844ee90 by Simon Peyton Jones at 2022-11-04T10:26:51+00:00 Better boxingCon_maybe - - - - - 0c3bc3bf by Richard Eisenberg at 2022-11-04T10:26:51+00:00 Improvements to comments, etc., from Richard - - - - - dbc126f4 by Simon Peyton Jones at 2022-11-04T10:26:51+00:00 Respond to Richard - - - - - 9150cae0 by Simon Peyton Jones at 2022-11-04T10:26:51+00:00 Improve boxing-data-con API - - - - - 48ba569e by Simon Peyton Jones at 2022-11-04T10:26:51+00:00 Update error messages - - - - - 6ba4e04e by Richard Eisenberg at 2022-11-04T10:26:51+00:00 Fix the equality constraint problem - - - - - b410415f by Simon Peyton Jones at 2022-11-04T10:26:51+00:00 Wibbles - - - - - 28949120 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Add isCovertGadtDataCon, fixing build - - - - - 2047d6c5 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Wibbles - - - - - dd835def by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Wibbles - - - - - ed5bda6a by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Move RoughMatch code out of Unify into RoughMatch - - - - - f8b48b99 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Wibble - - - - - 6be878b1 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Wibbles - - - - - 87b7c12e by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Update haddock submodule again - - - - - f341ffa0 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Wibbles, esp in RoughMap - - - - - ee015080 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Upate haddock submodule - - - - - 915aae7f by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Define eqType using tcEqType A one-line change - - - - - d00a186b by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Revert "Define eqType using tcEqType" This reverts commit eaf04c17c6a159ddb70eedd6fb8ab0b4fc180b7a. Performance got worse! T18223 was 60% worse T8095 75% T12227 9% T13386 6% T15703 7% T5030 8% - - - - - adf43518 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Refactor FunTyFlag Mostly just renaming stuff - - - - - 7c756700 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Wibbles - - - - - 5d5180c8 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Wibble - - - - - 482f8aed by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Add FunTyFlags to FunCo - - - - - a463d3ab by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 More improvements Hopefully perf improves a bit Plus rep-poly/T13105 and rep-poly/T17536b are fixed. - - - - - 43ee14d5 by Simon Peyton Jones at 2022-11-04T10:26:52+00:00 Add tests for #21530 - - - - - 19 changed files: - .gitignore - CODEOWNERS - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/073a65f42bb286dd46eab29a0287ea0bfd4d47cc...43ee14d598f1404d92e5ddbbb74ee265aca0733e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/073a65f42bb286dd46eab29a0287ea0bfd4d47cc...43ee14d598f1404d92e5ddbbb74ee265aca0733e You're receiving 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 Nov 4 11:41:25 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 04 Nov 2022 07:41:25 -0400 Subject: [Git][ghc/ghc][wip/T22331] 3 commits: Fix haddocks for GHC.IORef Message-ID: <6364fa657a22c_11c7e2d48d6b03909e7@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22331 at Glasgow Haskell Compiler / GHC Commits: 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 1834de0e by Simon Peyton Jones at 2022-11-04T11:43:10+00:00 Fix decomposition of TyConApps Ticket #22331 showed that we were being too eager to decompose a Wanted TyConApp, leading to incompleteness in the solver. To understand all this I ended up doing a substantial rewrite of the old Note [Decomposing equalities], now reborn as Note [Decomposing TyConApp equalities]. Plus rewrites of other related Notes. The actual fix is very minor and actually simplifies the code: in `can_decompose` in `GHC.Tc.Solver.Canonical.canTyConApp`, we now call `noMatchableIrreds`. A closely related refactor: we stop trying to use the same "no matchable givens" function here as in `matchClassInst`. Instead split into two much simpler functions. - - - - - 30 changed files: - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/List/SetOps.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Env.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2482b5aee0c6cc293fb9daa4a15e58f8bc36a9e...1834de0ed3fc4b8d2023c21e23463b16c9dbd17d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c2482b5aee0c6cc293fb9daa4a15e58f8bc36a9e...1834de0ed3fc4b8d2023c21e23463b16c9dbd17d You're receiving 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 Nov 4 12:07:01 2022 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Fri, 04 Nov 2022 08:07:01 -0400 Subject: [Git][ghc/ghc][wip/bump-boot-libraries] 6 commits: Fix haddocks for GHC.IORef Message-ID: <636500657cc22_11c7e2d6d9644401586@gitlab.mail> Cheng Shao pushed to branch wip/bump-boot-libraries at Glasgow Haskell Compiler / GHC Commits: 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 8780252a by Matthew Pickering at 2022-11-04T12:05:49+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - a22b76c6 by Matthew Pickering at 2022-11-04T12:06:43+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - 196fc779 by Cheng Shao at 2022-11-04T12:06:43+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - ab09b6fc by Cheng Shao at 2022-11-04T12:06:43+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 30 changed files: - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/CoreToStg.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Data/Bool.hs - compiler/GHC/Data/FastMutInt.hs - compiler/GHC/Data/FastString.hs - compiler/GHC/Data/List/SetOps.hs - compiler/GHC/Driver/Config/StgToCmm.hs - compiler/GHC/Driver/Env.hs - compiler/GHC/HsToCore/Binds.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e0113fa4d944a1b38038af12d34c200030e7a2dc...ab09b6fc12e33c016a06806c1c2ae47e7fc5935c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e0113fa4d944a1b38038af12d34c200030e7a2dc...ab09b6fc12e33c016a06806c1c2ae47e7fc5935c You're receiving 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 Nov 4 14:33:11 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Fri, 04 Nov 2022 10:33:11 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/T22388 Message-ID: <636522a794643_11c7e2d6d96444223a1@gitlab.mail> Sebastian Graf pushed new branch wip/T22388 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22388 You're receiving 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 Nov 4 14:54:48 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Fri, 04 Nov 2022 10:54:48 -0400 Subject: [Git][ghc/ghc][wip/strings-refactor3] 17 commits: rts: introduce (and use) `STG_NORETURN` Message-ID: <636527b874d35_11c7e219fb717442966e@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/strings-refactor3 at Glasgow Haskell Compiler / GHC Commits: 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 4dd9e74b by Krzysztof Gogolewski at 2022-11-04T15:54:25+01:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - 30 changed files: - .gitignore - CODEOWNERS - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.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/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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/113054aab5ab20e1b2bcebe84cc1c3b129760866...4dd9e74bb216244c77e973eca8047447dddd1509 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/113054aab5ab20e1b2bcebe84cc1c3b129760866...4dd9e74bb216244c77e973eca8047447dddd1509 You're receiving 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 Nov 4 16:34:17 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Fri, 04 Nov 2022 12:34:17 -0400 Subject: [Git][ghc/ghc][wip/js-staging] 2 commits: Enable more tests that were "unexpected passes" Message-ID: <63653f0994179_11c7e2d43bcfc44262a@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: bcb32644 by Sylvain Henry at 2022-11-04T17:37:00+01:00 Enable more tests that were "unexpected passes" - - - - - 69acf685 by Sylvain Henry at 2022-11-04T17:37:26+01:00 Take cross into account in perf and ticky flavours - - - - - 13 changed files: - hadrian/bindist/config.mk.in - hadrian/doc/flavours.md - hadrian/src/Expression.hs - hadrian/src/Flavour.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/Performance.hs - libraries/base/tests/all.T - libraries/stm - testsuite/tests/codeGen/should_run/all.T - testsuite/tests/driver/T20030/test1/all.T - testsuite/tests/primops/should_run/all.T - testsuite/tests/rts/pause-resume/all.T - testsuite/tests/rts/pause-resume/shouldfail/all.T Changes: ===================================== hadrian/bindist/config.mk.in ===================================== @@ -128,6 +128,8 @@ GhcUnregisterised = @Unregisterised@ ifeq "$(TargetArch_CPP)" "arm" # We don't support load/store barriers pre-ARMv7. See #10433. ArchSupportsSMP=$(if $(filter $(ARM_ISA),ARMv5 ARMv6),NO,YES) +else ifeq "$(TargetArch_CPP)" "js" +ArchSupportsSMP=NO else ArchSupportsSMP=$(strip $(patsubst $(TargetArch_CPP), YES, $(findstring $(TargetArch_CPP), i386 x86_64 sparc powerpc powerpc64 powerpc64le s390x aarch64 riscv64))) endif ===================================== hadrian/doc/flavours.md ===================================== @@ -211,15 +211,6 @@ The supported transformers are listed below: ticky_ghc Compile the GHC executable with Ticky-Ticky profiler support. - - ticky_ghc0 - Compile the stage0 GHC executable with Ticky-Ticky profiler support. Useful for cross-compilers, which are always stage1 compilers - - - perf_stage0 - Ensure that the `-O2` flags are passed to the stage0 build thus yielding an optimised stage1 compiler. Useful for cross-compilers, which are always stage1 compilers - - split_sections Enable section splitting for all libraries (except for the GHC ===================================== hadrian/src/Expression.hs ===================================== @@ -9,7 +9,7 @@ module Expression ( -- ** Predicates (?), stage, stage0, stage1, stage2, notStage0, threadedBootstrapper, - package, notPackage, packageOneOf, + package, notPackage, packageOneOf, cross, notCross, libraryPackage, builder, way, input, inputs, output, outputs, -- ** Evaluation @@ -151,3 +151,9 @@ cabalFlag pred flagName = do ifM (toPredicate pred) (arg flagName) (arg $ "-"<>flagName) infixr 3 `cabalFlag` + +cross :: Predicate +cross = expr (flag CrossCompiling) + +notCross :: Predicate +notCross = notM cross ===================================== hadrian/src/Flavour.hs ===================================== @@ -10,7 +10,6 @@ module Flavour , enableDebugInfo, enableTickyGhc , viaLlvmBackend , enableProfiledGhc - , perfStage0 , disableDynamicGhcPrograms , disableDynamicLibs , disableProfiledLibs @@ -39,15 +38,11 @@ import Control.Monad.Except import UserSettings import Oracles.Setting -import {-# SOURCE #-} Settings.Default - flavourTransformers :: Map String (Flavour -> Flavour) flavourTransformers = M.fromList [ "werror" =: werror , "debug_info" =: enableDebugInfo , "ticky_ghc" =: enableTickyGhc - , "ticky_ghc0" =: enableTickyGhc0 - , "perf_stage0" =: perfStage0 , "split_sections" =: splitSections , "thread_sanitizer" =: enableThreadSanitizer , "llvm" =: viaLlvmBackend @@ -131,31 +126,7 @@ enableDebugInfo = addArgs $ notStage0 ? mconcat -- | Enable the ticky-ticky profiler in stage2 GHC enableTickyGhc :: Flavour -> Flavour enableTickyGhc = - addArgs $ stage1 ? mconcat - [ builder (Ghc CompileHs) ? tickyArgs - , builder (Ghc LinkHs) ? tickyArgs - ] - --- | Enable the ticky-ticky profiler in stage1 GHC -perfStage0 :: Flavour -> Flavour -perfStage0 fl = addArgs args fl - -- This is a bit sloppy because it does not preclude any predicates that turn - -- on (or off) optimizations that were added be the flavor or by another - -- transformer. Luckily though if we're using this transformer then we want O2 - -- for each subsequent stage and ghc doesn't choke on the redundant flags - -- There is the remove in Hadrian.Expression but it doesn't handle predicates - where - args = sourceArgs SourceArgs - { hsDefault = mconcat [ arg "-O2", arg "-H64m"] - , hsLibrary = arg "-O2" - , hsCompiler = arg "-O2" - , hsGhc = arg "-O2" - } - --- | Enable the ticky-ticky profiler in stage1 GHC -enableTickyGhc0 :: Flavour -> Flavour -enableTickyGhc0 = - addArgs $ stage0 ? mconcat + addArgs $ orM [stage1, cross] ? mconcat [ builder (Ghc CompileHs) ? tickyArgs , builder (Ghc LinkHs) ? tickyArgs ] ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -176,10 +176,13 @@ defaultLibraryWays = Set.fromList <$> defaultRtsWays :: Ways defaultRtsWays = Set.fromList <$> mconcat - [ pure [vanilla, threaded] + [ pure [vanilla] + , targetSupportsSMP ? pure [threaded] , notStage0 ? pure - [ profiling, threadedProfiling, debugProfiling, threadedDebugProfiling - , debug, threadedDebug + [ profiling, debugProfiling, debug + ] + , notStage0 ? targetSupportsSMP ? pure + [ threadedProfiling, threadedDebugProfiling, threadedDebug ] , notStage0 ? platformSupportsSharedLibs ? pure [ dynamic, threadedDynamic, debugDynamic, threadedDebugDynamic ===================================== hadrian/src/Settings/Flavours/Performance.hs ===================================== @@ -13,6 +13,10 @@ performanceFlavour = defaultFlavour performanceArgs :: Args performanceArgs = sourceArgs SourceArgs { hsDefault = pure ["-O", "-H64m"] - , hsLibrary = notStage0 ? arg "-O2" + , hsLibrary = orM [notStage0, cross] ? arg "-O2" , hsCompiler = pure ["-O2"] - , hsGhc = mconcat [stage0 ? arg "-O", notStage0 ? arg "-O2"] } + , hsGhc = mconcat + [ andM [stage0, notCross] ? arg "-O" + , orM [notStage0, cross] ? arg "-O2" + ] + } ===================================== libraries/base/tests/all.T ===================================== @@ -240,7 +240,7 @@ test('T11555', normal, compile_and_run, ['']) test('T12494', normal, compile_and_run, ['']) test('T12852', [when(opsys('mingw32'), skip), js_broken(22374)], compile_and_run, ['']) test('lazySTexamples', normal, compile_and_run, ['']) -test('T11760', [req_smp, js_broken(22261)], compile_and_run, ['-threaded -with-rtsopts=-N2']) +test('T11760', req_smp, compile_and_run, ['-threaded -with-rtsopts=-N2']) test('T12874', normal, compile_and_run, ['']) test('T13191', [ collect_stats('bytes allocated', 5) ===================================== libraries/stm ===================================== @@ -1 +1 @@ -Subproject commit 41c9eca2351bb2fbbf0837f3a7569325f327be6a +Subproject commit 9bc0321c32f67888103a2b9a200f224ab408a79b ===================================== testsuite/tests/codeGen/should_run/all.T ===================================== @@ -156,7 +156,7 @@ test('T10246', normal, compile_and_run, ['']) test('T9533', normal, compile_and_run, ['']) test('T9533b', normal, compile_and_run, ['']) test('T9533c', normal, compile_and_run, ['']) -test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_smp, js_broken(22261)], +test('T10414', [only_ways(['threaded2']), extra_ways(['threaded2']), req_smp], compile_and_run, ['-feager-blackholing']) test('T10521', normal, compile_and_run, ['']) test('T10521b', normal, compile_and_run, ['']) ===================================== testsuite/tests/driver/T20030/test1/all.T ===================================== @@ -10,6 +10,5 @@ test('T20030_test1j', , 'D.hs' , 'E.hs-boot' , 'E.hs' , 'F.hs' , 'G.hs' , 'H.hs' , 'I.hs', 'J.hs-boot', 'J.hs', 'K.hs' ]) , req_smp - , js_broken(22261) ], multimod_compile, ['I.hs K.hs', '-v1 -j']) ===================================== testsuite/tests/primops/should_run/all.T ===================================== @@ -56,7 +56,7 @@ test('UnliftedSmallArray1', normal, compile_and_run, ['']) test('UnliftedSmallArray2', normal, compile_and_run, ['']) test('UnliftedStablePtr', normal, compile_and_run, ['']) test('UnliftedTVar1', normal, compile_and_run, ['']) -test('UnliftedTVar2', js_broken(22261), compile_and_run, ['']) +test('UnliftedTVar2', normal, compile_and_run, ['']) test('UnliftedWeakPtr', normal, compile_and_run, ['']) test('T21624', normal, compile_and_run, ['']) ===================================== testsuite/tests/rts/pause-resume/all.T ===================================== @@ -1,25 +1,30 @@ test('pause_resume_via_safe_ffi', [ only_ways(['threaded1', 'threaded2']) + , req_c , extra_files(['pause_resume.c','pause_resume.h']) ], multi_compile_and_run, ['pause_resume_via_safe_ffi', [('pause_resume.c','')], '']) test('pause_resume_via_pthread', [ only_ways(['threaded1', 'threaded2']) + , req_c , extra_files(['pause_resume.c','pause_resume.h']) ], multi_compile_and_run, ['pause_resume_via_pthread', [('pause_resume.c','')], '']) test('pause_resume_via_safe_ffi_concurrent', [ only_ways(['threaded1', 'threaded2']) + , req_c , extra_files(['pause_resume.c','pause_resume.h']) ], multi_compile_and_run, ['pause_resume_via_safe_ffi_concurrent', [('pause_resume.c','')], '']) test('pause_and_use_rts_api', [ only_ways(['threaded1', 'threaded2']) + , req_c , extra_files(['pause_resume.c','pause_resume.h']) ], multi_compile_and_run, ['pause_and_use_rts_api', [('pause_resume.c','')], '']) test('list_threads_and_misc_roots', [ only_ways(['threaded1', 'threaded2']) + , req_c , extra_files(['list_threads_and_misc_roots_c.c','list_threads_and_misc_roots_c.h']) ], - multi_compile_and_run, ['list_threads_and_misc_roots', [('list_threads_and_misc_roots_c.c','')], '']) \ No newline at end of file + multi_compile_and_run, ['list_threads_and_misc_roots', [('list_threads_and_misc_roots_c.c','')], '']) ===================================== testsuite/tests/rts/pause-resume/shouldfail/all.T ===================================== @@ -6,18 +6,21 @@ test('unsafe_rts_pause', test('rts_lock_when_paused', [ only_ways(['threaded1', 'threaded2']) , exit_code(1) + , req_c , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) ], multi_compile_and_run, ['rts_lock_when_paused', [('rts_pause_lock.c','')], '']) test('rts_pause_when_locked', [ only_ways(['threaded1', 'threaded2']) , exit_code(1) + , req_c , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) ], multi_compile_and_run, ['rts_pause_when_locked', [('rts_pause_lock.c','')], '']) test('rts_double_pause', [ only_ways(['threaded1', 'threaded2']) , exit_code(1) + , req_c , extra_files(['rts_pause_lock.c','rts_pause_lock.h']) ], multi_compile_and_run, ['rts_double_pause', [('rts_pause_lock.c','')], '']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4a6dfe4a83165977b43e996fda15cb7876d62b84...69acf685fd1a6b1edb1f8991e4c2df613fee9581 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4a6dfe4a83165977b43e996fda15cb7876d62b84...69acf685fd1a6b1edb1f8991e4c2df613fee9581 You're receiving 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 Nov 4 16:38:03 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Fri, 04 Nov 2022 12:38:03 -0400 Subject: [Git][ghc/ghc][wip/js-staging] Remove PerfJS mention in ci script Message-ID: <63653feb6d9d3_11c7e2103b8764442815@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 8467a528 by Sylvain Henry at 2022-11-04T17:41:34+01:00 Remove PerfJS mention in ci script - - - - - 2 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -147,7 +147,7 @@ data Flavour = Flavour BaseFlavour [FlavourTrans] data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser -data BaseFlavour = Release | Validate | SlowValidate | PerfJS +data BaseFlavour = Release | Validate | SlowValidate ----------------------------------------------------------------------------- -- Build Configs @@ -282,7 +282,6 @@ flavourString (Flavour base trans) = baseString base ++ concatMap (("+" ++) . fl baseString Release = "release" baseString Validate = "validate" baseString SlowValidate = "slow-validate" - baseString PerfJS = "perf-js" flavourString Llvm = "llvm" flavourString Dwarf = "debug_info" @@ -823,7 +822,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" Nothing (Just "emconfigure") ) { bignumBackend = Native - , buildFlavour = PerfJS + , buildFlavour = Release } ] ===================================== .gitlab/jobs.yaml ===================================== @@ -1328,7 +1328,7 @@ "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-perf-js": { + "nightly-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1338,7 +1338,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-perf-js.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release.tar.xz", "junit.xml" ], "reports": { @@ -1380,12 +1380,12 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-perf-js", - "BUILD_FLAVOUR": "perf-js", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", + "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", "CROSS_TARGET": "js-unknown-ghcjs", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-perf-js", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", "XZ_OPT": "-9" } }, @@ -3871,7 +3871,7 @@ "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" } }, - "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-perf-js": { + "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -3881,7 +3881,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-perf-js.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release.tar.xz", "junit.xml" ], "reports": { @@ -3923,12 +3923,12 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-perf-js", - "BUILD_FLAVOUR": "perf-js", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", + "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", "CROSS_TARGET": "js-unknown-ghcjs", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-perf-js" + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release" } }, "x86_64-linux-deb11-validate": { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8467a5284bde461e132812cd40242852e3ff7962 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8467a5284bde461e132812cd40242852e3ff7962 You're receiving 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 Nov 4 16:39:28 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Fri, 04 Nov 2022 12:39:28 -0400 Subject: [Git][ghc/ghc][wip/javascript-backend] 28 commits: Drop a kludge for binutils<2.17, which is now over 10 years old. Message-ID: <6365404032322_11c7e251504443061@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - 3cf6b6dd by Josh Meredith at 2022-11-04T17:42:04+01:00 Add ghcjs changes to deriveConstants: - change String targetOS option in deriveConstants to an enum - separate out getWantedGHSJS, removing generated c file in this path - - - - - 5a26a849 by doyougnu at 2022-11-04T17:42:55+01:00 Add JavaScript code generator Bump submodules - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToC.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/ConstantFold.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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Core/Tidy.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/CoreToIface.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1293c9968f3295ce5124e335ac93f73d9ad2c05e...5a26a8497fd7ff54da4c1fa982666127f5ff4731 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1293c9968f3295ce5124e335ac93f73d9ad2c05e...5a26a8497fd7ff54da4c1fa982666127f5ff4731 You're receiving 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 Nov 4 20:06:42 2022 From: gitlab at gitlab.haskell.org (Carter Schonwald (@carter)) Date: Fri, 04 Nov 2022 16:06:42 -0400 Subject: [Git][ghc/ghc] Pushed new branch wip/carter-llvm14-bump Message-ID: <636570d23f17f_11c7e25152c45391b@gitlab.mail> Carter Schonwald pushed new branch wip/carter-llvm14-bump at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/carter-llvm14-bump You're receiving 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 Nov 4 21:07:47 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 04 Nov 2022 17:07:47 -0400 Subject: [Git][ghc/ghc][wip/rts-configure-2] 2 commits: rts configure script Message-ID: <63657f233bde0_11c7e2103b878c4616c5@gitlab.mail> Ben Gamari pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: 4df6bff9 by Ben Gamari at 2022-10-31T11:25:40-04:00 rts configure script - - - - - a5daea9b by Ben Gamari at 2022-11-02T09:07:47-04:00 Stuff - - - - - 30 changed files: - boot - compiler/GHC/Linker/Dynamic.hs - compiler/GHC/Linker/Static.hs - compiler/GHC/Platform.hs - compiler/GHC/Settings/IO.hs - configure.ac - distrib/configure.ac.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cabal.project - hadrian/cfg/system.config.in - hadrian/hadrian.cabal - hadrian/src/Oracles/Flag.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Lint.hs - hadrian/src/Settings/Packages.hs - libraries/Cabal - rts/.gitignore - + rts/configure.ac - + rts/external-symbols.list.in - m4/fp_bfd_support.m4 → rts/m4/fp_bfd_support.m4 - m4/fp_cc_supports__atomics.m4 → rts/m4/fp_cc_supports__atomics.m4 - m4/fp_check_pthreads.m4 → rts/m4/fp_check_pthreads.m4 - m4/fp_find_libnuma.m4 → rts/m4/fp_find_libnuma.m4 - + rts/m4/fp_large_address_space.m4 - m4/fp_musttail.m4 → rts/m4/fp_musttail.m4 - m4/fp_visibility_hidden.m4 → rts/m4/fp_visibility_hidden.m4 - m4/ghc_adjustors_method.m4 → rts/m4/ghc_adjustors_method.m4 - rts/package.conf.in - rts/posix/OSThreads.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/645faebe32b3d9f76d3ab728b342834a16c0b7f5...a5daea9b84c144d4745630f22a9023d1b46ae6c4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/645faebe32b3d9f76d3ab728b342834a16c0b7f5...a5daea9b84c144d4745630f22a9023d1b46ae6c4 You're receiving 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 Nov 4 21:08:06 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 04 Nov 2022 17:08:06 -0400 Subject: [Git][ghc/ghc][wip/rts-configure-2] More stuff Message-ID: <63657f36ad4db_11c7e2103b8778462110@gitlab.mail> Ben Gamari pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: 31095b1e by Ben Gamari at 2022-11-04T17:07:59-04:00 More stuff - - - - - 5 changed files: - rts/configure.ac - rts/include/rts/PosixSource.h - rts/linker/Elf.c - rts/linker/elf_got.c - rts/posix/ticker/Pthread.c Changes: ===================================== rts/configure.ac ===================================== @@ -28,10 +28,13 @@ AC_CONFIG_HEADERS([include/ghcautoconf.h]) # results in the following code AC_CANONICAL_BUILD AC_CANONICAL_HOST +AC_CANONICAL_TARGET -dnl GHC_CONVERT_PLATFORM_PARTS([host], [Host]) -dnl FPTOOLS_SET_PLATFORM_VARS([host],[Host]) -dnl FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) +GHC_CONVERT_PLATFORM_PARTS([build], [Build]) +GHC_CONVERT_PLATFORM_PARTS([host], [Host]) +GHC_CONVERT_PLATFORM_PARTS([target], [Target]) +FPTOOLS_SET_PLATFORM_VARS +FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) AC_CHECK_HEADERS([ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/param.h sys/mman.h sys/resource.h sys/select.h sys/time.h sys/timeb.h sys/timerfd.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h utime.h windows.h winsock.h sched.h]) ===================================== rts/include/rts/PosixSource.h ===================================== @@ -37,6 +37,8 @@ #define _XOPEN_SOURCE 700 #endif +#define _GNU_SOURCE 1 + #if defined(mingw32_HOST_OS) # if defined(__USE_MINGW_ANSI_STDIO) # if __USE_MINGW_ANSI_STDIO != 1 ===================================== rts/linker/Elf.c ===================================== @@ -28,10 +28,10 @@ #include "linker/util.h" #include "linker/elf_util.h" -#include #include #include #include +#include #if defined(HAVE_DLFCN_H) #include #endif ===================================== rts/linker/elf_got.c ===================================== @@ -1,6 +1,7 @@ #include "Rts.h" #include "elf_got.h" #include "linker/MMap.h" +#include "sys/mman.h" #include ===================================== rts/posix/ticker/Pthread.c ===================================== @@ -55,6 +55,9 @@ #include +#if defined(linux_HOST_OS) +#define _GNU_SOURCE 1 +#endif #include #if defined(HAVE_PTHREAD_NP_H) #include View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31095b1ec650755799ad7bc8d70f97101946c5a1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31095b1ec650755799ad7bc8d70f97101946c5a1 You're receiving 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 Nov 4 21:08:24 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 04 Nov 2022 17:08:24 -0400 Subject: [Git][ghc/ghc][wip/rts-configure-2] file Message-ID: <63657f4819fbb_11c7e2103b878c4626db@gitlab.mail> Ben Gamari pushed to branch wip/rts-configure-2 at Glasgow Haskell Compiler / GHC Commits: 717bf847 by Ben Gamari at 2022-11-04T17:08:15-04:00 file - - - - - 1 changed file: - + m4/ghc_adjustors_method.m4 Changes: ===================================== m4/ghc_adjustors_method.m4 ===================================== @@ -0,0 +1,41 @@ +dnl GHC_ADJUSTORS_METHOD(Platform) +dnl -------------------------------------------------------------- +dnl Use libffi for adjustors? +AC_DEFUN([GHC_ADJUSTORS_METHOD], +[ + case [$]{$1[Arch]} in + i386|x86_64) + # We have native adjustor support on these platforms + HaveNativeAdjustor=yes + ;; + *) + HaveNativeAdjustor=no + ;; + esac + + AC_MSG_CHECKING([whether to use libffi for adjustors]) + if test "$CABAL_FLAG_force_libffi_adjustors" = "1" ; then + # Use libffi is the user explicitly requested it + AdjustorType="libffi" + elif test "$HaveNativeAdjustor" = "yes"; then + # Otherwise if we have a native adjustor implementation use that + AdjustorType="native" + else + # If we don't have a native adjustor implementation then default to libffi + AdjustorType="libffi" + fi + + case "$AdjustorType" in + libffi) + UseLibffiForAdjustors=YES + AC_MSG_RESULT([yes]) + ;; + native) + UseLibffiForAdjustors=NO + AC_MSG_RESULT([no]) + ;; + *) + AC_MSG_ERROR([Internal error: Invalid AdjustorType]) + exit 1 + esac +]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/717bf8474efbb1b1cf4b26675adaf5c42a20470a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/717bf8474efbb1b1cf4b26675adaf5c42a20470a You're receiving 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 Nov 4 21:29:16 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 04 Nov 2022 17:29:16 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Export pprTrace and friends from GHC.Prelude. Message-ID: <6365842cf3ce1_11c7e2103b8778467023@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 6b1daba3 by Krzysztof Gogolewski at 2022-11-04T17:29:04-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.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/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/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c345b11c5f7b150b84bb4c90b1a3dfd4ac4b3ef...6b1daba337112e16f17b23ed0c8e515b42c57342 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c345b11c5f7b150b84bb4c90b1a3dfd4ac4b3ef...6b1daba337112e16f17b23ed0c8e515b42c57342 You're receiving 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 Nov 4 21:29:29 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 04 Nov 2022 17:29:29 -0400 Subject: [Git][ghc/ghc][wip/tsan/cmm] 1552 commits: Regression test for renamer/typechecker performance (#20261) Message-ID: <6365843954269_11c7e2103b87644682dc@gitlab.mail> Ben Gamari pushed to branch wip/tsan/cmm at Glasgow Haskell Compiler / GHC Commits: 3c3e5c03 by Ben Gamari at 2021-12-17T21:20:57-05:00 Regression test for renamer/typechecker performance (#20261) We use the parser generated by stack to ensure reproducibility - - - - - 5d5620bc by Krzysztof Gogolewski at 2021-12-17T21:21:32-05:00 Change isUnliftedTyCon to marshalablePrimTyCon (#20401) isUnliftedTyCon was used in three places: Ticky, Template Haskell and FFI checks. It was straightforward to remove it from Ticky and Template Haskell. It is now used in FFI only and renamed to marshalablePrimTyCon. Previously, it was fetching information from a field in PrimTyCon called is_unlifted. Instead, I've changed the code to compute liftedness based on the kind. isFFITy and legalFFITyCon are removed. They were only referred from an old comment that I removed. There were three functions to define a PrimTyCon, but the only difference was that they were setting is_unlifted to True or False. Everything is now done in mkPrimTyCon. I also added missing integer types in Ticky.hs, I think it was an oversight. Fixes #20401 - - - - - 9d77976d by Matthew Pickering at 2021-12-17T21:22:08-05:00 testsuite: Format metric results with comma separator As noted in #20763 the way the stats were printed was quite hard for a human to compare. Therefore we now insert the comma separator so that they are easier to compare at a glance. Before: ``` Baseline Test Metric value New value Change ----------------------------------------------------------------------------- Conversions(normal) run/alloc 107088.0 107088.0 +0.0% DeriveNull(normal) run/alloc 112050656.0 112050656.0 +0.0% InlineArrayAlloc(normal) run/alloc 1600040712.0 1600040712.0 +0.0% InlineByteArrayAlloc(normal) run/alloc 1440040712.0 1440040712.0 +0.0% InlineCloneArrayAlloc(normal) run/alloc 1600040872.0 1600040872.0 +0.0% MethSharing(normal) run/alloc 480097864.0 480097864.0 +0.0% T10359(normal) run/alloc 354344.0 354344.0 +0.0% ``` After ``` Baseline Test Metric value New value Change ---------------------------------------------------------------------------------- Conversions(normal) run/alloc 107,088 107,088 +0.0% DeriveNull(normal) run/alloc 112,050,656 112,050,656 +0.0% InlineArrayAlloc(normal) run/alloc 1,600,040,712 1,600,040,712 +0.0% InlineByteArrayAlloc(normal) run/alloc 1,440,040,712 1,440,040,712 +0.0% InlineCloneArrayAlloc(normal) run/alloc 1,600,040,872 1,600,040,872 +0.0% MethSharing(normal) run/alloc 480,097,864 480,097,864 +0.0% T10359(normal) run/alloc 354,344 354,344 +0.0% ``` Closes #20763 - - - - - 3f31bfe8 by Sylvain Henry at 2021-12-17T21:22:48-05:00 Perf: inline exprIsCheapX Allow specialization for the ok_app predicate. Perf improvements: Baseline Test Metric value New value Change ----------------------------------------------------------------------------- ManyAlternatives(normal) ghc/alloc 747317244.0 746444024.0 -0.1% ManyConstructors(normal) ghc/alloc 4005046448.0 4001548792.0 -0.1% MultiLayerModules(normal) ghc/alloc 3063361000.0 3063178472.0 -0.0% MultiLayerModulesRecomp(normal) ghc/alloc 894208428.0 894252496.0 +0.0% PmSeriesG(normal) ghc/alloc 48021692.0 47901592.0 -0.3% PmSeriesS(normal) ghc/alloc 61322504.0 61149008.0 -0.3% PmSeriesT(normal) ghc/alloc 90879364.0 90609048.0 -0.3% PmSeriesV(normal) ghc/alloc 60155376.0 59983632.0 -0.3% T10421(normal) ghc/alloc 112820720.0 112517208.0 -0.3% T10421a(normal) ghc/alloc 78783696.0 78557896.0 -0.3% T10547(normal) ghc/alloc 28331984.0 28354160.0 +0.1% T10858(normal) ghc/alloc 180715296.0 180226720.0 -0.3% T11195(normal) ghc/alloc 284139184.0 283981048.0 -0.1% T11276(normal) ghc/alloc 137830804.0 137688912.0 -0.1% T11303b(normal) ghc/alloc 44080856.0 43956152.0 -0.3% T11374(normal) ghc/alloc 249319644.0 249059288.0 -0.1% T11545(normal) ghc/alloc 971507488.0 971146136.0 -0.0% T11822(normal) ghc/alloc 131410208.0 131269664.0 -0.1% T12150(optasm) ghc/alloc 78866860.0 78762296.0 -0.1% T12227(normal) ghc/alloc 494467900.0 494138112.0 -0.1% T12234(optasm) ghc/alloc 56781044.0 56588256.0 -0.3% T12425(optasm) ghc/alloc 90462264.0 90240272.0 -0.2% T12545(normal) ghc/alloc 1694316588.0 1694128448.0 -0.0% T12707(normal) ghc/alloc 955665168.0 955005336.0 -0.1% T13035(normal) ghc/alloc 101875160.0 101713312.0 -0.2% T13056(optasm) ghc/alloc 366370168.0 365347632.0 -0.3% T13253(normal) ghc/alloc 333741472.0 332612920.0 -0.3% T13253-spj(normal) ghc/alloc 124947560.0 124427552.0 -0.4% T13379(normal) ghc/alloc 358997996.0 358879840.0 -0.0% T13701(normal) ghc/alloc 2400391456.0 2399956840.0 -0.0% T13719(normal) ghc/alloc 4193179228.0 4192476392.0 -0.0% T14052(ghci) ghc/alloc 2734741552.0 2735731808.0 +0.0% T14052Type(ghci) ghc/alloc 7323235724.0 7323042264.0 -0.0% T14683(normal) ghc/alloc 2990457260.0 2988899144.0 -0.1% T14697(normal) ghc/alloc 363606476.0 363452952.0 -0.0% T15164(normal) ghc/alloc 1291321780.0 1289491968.0 -0.1% T15304(normal) ghc/alloc 1277838020.0 1276208304.0 -0.1% T15630(normal) ghc/alloc 161074632.0 160388136.0 -0.4% T16190(normal) ghc/alloc 276567192.0 276235216.0 -0.1% T16577(normal) ghc/alloc 7564318656.0 7535598656.0 -0.4% T16875(normal) ghc/alloc 34867720.0 34752440.0 -0.3% T17096(normal) ghc/alloc 288477360.0 288156960.0 -0.1% T17516(normal) ghc/alloc 1712777224.0 1704655496.0 -0.5% T17836(normal) ghc/alloc 1092127336.0 1091709880.0 -0.0% T17836b(normal) ghc/alloc 52083516.0 51954056.0 -0.2% T17977(normal) ghc/alloc 44552228.0 44425448.0 -0.3% T17977b(normal) ghc/alloc 40540252.0 40416856.0 -0.3% T18140(normal) ghc/alloc 81908200.0 81678928.0 -0.3% T18223(normal) ghc/alloc 1166459176.0 1164418104.0 -0.2% T18282(normal) ghc/alloc 131123648.0 130740432.0 -0.3% T18304(normal) ghc/alloc 86486796.0 86223088.0 -0.3% T18478(normal) ghc/alloc 746029440.0 745619968.0 -0.1% T18698a(normal) ghc/alloc 337037580.0 336533824.0 -0.1% T18698b(normal) ghc/alloc 398324600.0 397696400.0 -0.2% T18923(normal) ghc/alloc 68496432.0 68286264.0 -0.3% T1969(normal) ghc/alloc 760424696.0 759641664.0 -0.1% T19695(normal) ghc/alloc 1421672472.0 1413682104.0 -0.6% T20049(normal) ghc/alloc 88601524.0 88336560.0 -0.3% T3064(normal) ghc/alloc 190808832.0 190659328.0 -0.1% T3294(normal) ghc/alloc 1604483120.0 1604339080.0 -0.0% T4801(normal) ghc/alloc 296501624.0 296388448.0 -0.0% T5030(normal) ghc/alloc 364336308.0 364206240.0 -0.0% T5321FD(normal) ghc/alloc 270688492.0 270386832.0 -0.1% T5321Fun(normal) ghc/alloc 300860396.0 300559200.0 -0.1% T5631(normal) ghc/alloc 575822760.0 575579160.0 -0.0% T5642(normal) ghc/alloc 470243356.0 468988784.0 -0.3% T5837(normal) ghc/alloc 35936468.0 35821360.0 -0.3% T6048(optasm) ghc/alloc 102587024.0 102222000.0 -0.4% T783(normal) ghc/alloc 386539204.0 386003344.0 -0.1% T9020(optasm) ghc/alloc 247435312.0 247324184.0 -0.0% T9198(normal) ghc/alloc 47170036.0 47054840.0 -0.2% T9233(normal) ghc/alloc 677186820.0 676550032.0 -0.1% T9630(normal) ghc/alloc 1456411516.0 1451045736.0 -0.4% T9675(optasm) ghc/alloc 427190224.0 426812568.0 -0.1% T9872a(normal) ghc/alloc 1704660040.0 1704681856.0 +0.0% T9872b(normal) ghc/alloc 2180109488.0 2180130856.0 +0.0% T9872c(normal) ghc/alloc 1760209640.0 1760231456.0 +0.0% T9872d(normal) ghc/alloc 501126052.0 500973488.0 -0.0% T9961(normal) ghc/alloc 353244688.0 353063104.0 -0.1% TcPlugin_RewritePerf(normal) ghc/alloc 2387276808.0 2387254168.0 -0.0% WWRec(normal) ghc/alloc 588651140.0 587684704.0 -0.2% hard_hole_fits(normal) ghc/alloc 492063812.0 491798360.0 -0.1% hie002(normal) ghc/alloc 9334355960.0 9334396872.0 +0.0% parsing001(normal) ghc/alloc 537410584.0 537421736.0 +0.0% geo. mean -0.2% - - - - - e04878b0 by Matthew Pickering at 2021-12-17T21:23:23-05:00 ci: Use correct metrics baseline It turns out there was already a function in the CI script to correctly set the baseline for performance tests but it was just never called. I now call it during the initialisation to set the correct baseline. I also made the make testsuite driver take into account the PERF_BASELINE_COMMIT environment variable Fixes #20811 - - - - - 1327c176 by Matthew Pickering at 2021-12-17T21:23:58-05:00 Add regression test for T20189 Closes #20189 - - - - - fc9b1755 by Matthew Pickering at 2021-12-17T21:24:33-05:00 Fix documentation formatting in Language.Haskell.TH.CodeDo Fixes #20543 - - - - - abef93f3 by Matthew Pickering at 2021-12-17T21:24:33-05:00 Expand documentation for MulArrowT constructor Fixes #20812 - - - - - 94c3ff66 by Cheng Shao at 2021-12-17T21:25:09-05:00 Binary: make withBinBuffer safe With this patch, withBinBuffer will construct a ByteString that properly captures the reference to the BinHandle internal MutableByteArray#, making it safe to convert a BinHandle to ByteString and use that ByteString outside the continuation. - - - - - a3552934 by Sebastian Graf at 2021-12-17T21:25:45-05:00 Demand: `Eq DmdType` modulo `defaultFvDmd` (#20827) Fixes #20827 by filtering out any default free variable demands (as per `defaultFvDmd`) prior to comparing the assocs of the `DmdEnv`. The details are in `Note [Demand type Equality]`. - - - - - 9529d859 by Sylvain Henry at 2021-12-17T21:26:24-05:00 Perf: avoid using (replicateM . length) when possible Extracted from !6622 - - - - - 887d8b4c by Matthew Pickering at 2021-12-17T21:26:59-05:00 testsuite: Ensure that -dcore-lint is not set for compiler performance tests This place ensures that the default -dcore-lint option is disabled by default when collect_compiler_stats is used but you can still pass -dcore-lint as an additional option (see T1969 which tests core lint performance). Fixes #20830 ------------------------- Metric Decrease: PmSeriesS PmSeriesT PmSeriesV T10858 T11195 T11276 T11374 T11822 T14052 T14052Type T17096 T17836 T17836b T18478 T18698a T18698b ------------------------- - - - - - 5ff47ff5 by Ben Gamari at 2021-12-21T01:46:00-05:00 codeGen: Introduce flag to bounds-check array accesses Here we introduce code generator support for instrument array primops with bounds checking, enabled with the `-fcheck-prim-bounds` flag. Introduced to debug #20769. - - - - - d47bb109 by Ben Gamari at 2021-12-21T01:46:00-05:00 rts: Add optional bounds checking in out-of-line primops - - - - - 8ea79a16 by Ben Gamari at 2021-12-21T01:46:00-05:00 Rename -fcatch-bottoms to -fcatch-nonexhaustive-cases As noted in #20601, the previous name was rather misleading. - - - - - 00b55bfc by Ben Gamari at 2021-12-21T01:46:00-05:00 Introduce -dlint flag As suggested in #20601, this is a short-hand for enabling the usual GHC-internal sanity checks one typically leans on when debugging runtime crashes. - - - - - 9728d6c2 by Sylvain Henry at 2021-12-21T01:46:39-05:00 Give plugins a better interface (#17957) Plugins were directly fetched from HscEnv (hsc_static_plugins and hsc_plugins). The tight coupling of plugins and of HscEnv is undesirable and it's better to store them in a new Plugins datatype and to use it in the plugins' API (e.g. withPlugins, mapPlugins...). In the process, the interactive context (used by GHCi) got proper support for different static plugins than those used for loaded modules. Bump haddock submodule - - - - - 9bc5ab64 by Greg Steuck at 2021-12-21T01:47:17-05:00 Use libc++ instead of libstdc++ on openbsd in addition to freebsd This is not entirely accurate because some openbsd architectures use gcc. Yet we don't have ghc ported to them and thus the approximation is good enough. Fixes ghcilink006 test - - - - - f92c9c0d by Greg Steuck at 2021-12-21T01:47:55-05:00 Only use -ldl conditionally to fix T3807 OpenBSD doesn't have this library and so the linker complains: ld.lld: error: unable to find library -ldl - - - - - ff657a81 by Greg Steuck at 2021-12-21T01:48:32-05:00 Mark `linkwhole` test as expected broken on OpenBSD per #20841 - - - - - 1a596d06 by doyougnu at 2021-12-22T00:12:27-05:00 Cmm: DynFlags to CmmConfig refactor add files GHC.Cmm.Config, GHC.Driver.Config.Cmm Cmm: DynFlag references --> CmmConfig Cmm.Pipeline: reorder imports, add handshake Cmm: DynFlag references --> CmmConfig Cmm.Pipeline: DynFlag references --> CmmConfig Cmm.LayoutStack: DynFlag references -> CmmConfig Cmm.Info.Build: DynFlag references -> CmmConfig Cmm.Config: use profile to retrieve platform Cmm.CLabel: unpack NCGConfig in labelDynamic Cmm.Config: reduce CmmConfig surface area Cmm.Config: add cmmDoCmmSwitchPlans field Cmm.Config: correct cmmDoCmmSwitchPlans flag The original implementation dispatches work in cmmImplementSwitchPlans in an `otherwise` branch, hence we must add a not to correctly dispatch Cmm.Config: add cmmSplitProcPoints simplify Config remove cmmBackend, and cmmPosInd Cmm.CmmToAsm: move ncgLabelDynamic to CmmToAsm Cmm.CLabel: remove cmmLabelDynamic function Cmm.Config: rename cmmOptDoLinting -> cmmDoLinting testsuite: update CountDepsAst CountDepsParser - - - - - d7cc8f19 by Matthew Pickering at 2021-12-22T00:13:02-05:00 ci: Fix master CI I made a mistake in the bash script so there were errors about "$CI_MERGE_REQUEST_DIFF_BASE_SHA" not existing. - - - - - 09b6cb45 by Alan Zimmerman at 2021-12-22T00:13:38-05:00 Fix panic trying to -ddump-parsed-ast for implicit fixity A declaration such as infixr ++++ is supplied with an implicit fixity of 9 in the parser, but uses an invalid SrcSpan to capture this. Use of this span triggers a panic. Fix the problem by not recording an exact print annotation for the non-existent fixity source. Closes #20846 - - - - - 3ed90911 by Matthew Pickering at 2021-12-22T14:47:40-05:00 testsuite: Remove reqlib modifier The reqlib modifer was supposed to indicate that a test needed a certain library in order to work. If the library happened to be installed then the test would run as normal. However, CI has never run these tests as the packages have not been installed and we don't want out tests to depend on things which might get externally broken by updating the compiler. The new strategy is to run these tests in head.hackage, where the tests have been cabalised as well as possible. Some tests couldn't be transferred into the normal style testsuite but it's better than never running any of the reqlib tests. https://gitlab.haskell.org/ghc/head.hackage/-/merge_requests/169 A few submodules also had reqlib tests and have been updated to remove it. Closes #16264 #20032 #17764 #16561 - - - - - ac3e8c52 by Matthew Pickering at 2021-12-22T14:48:16-05:00 perf ci: Start searching form the performance baseline If you specify PERF_BASELINE_COMMIT then this can fail if the specific commit you selected didn't have perf test metrics. (This can happen in CI for example if a build fails on master). Therefore instead of just reporting all tests as new, we start searching downwards from this point to try and find a good commit to report numbers from. - - - - - 9552781a by Matthew Pickering at 2021-12-22T14:48:51-05:00 Mark T16525b as fragile on windows See ticket #20852 - - - - - 13a6d85a by Andreas Klebinger at 2021-12-23T10:55:36-05:00 Make callerCC profiling mode represent entry counter flag. Fixes #20854 - - - - - 80daefce by Matthew Pickering at 2021-12-23T10:56:11-05:00 Properly filter for module visibility in resolvePackageImport This completes the fix for #20779 / !7123. Beforehand, the program worked by accident because the two versions of the library happened to be ordered properly (due to how the hashes were computed). In the real world I observed them being the other way around which meant the final lookup failed because we weren't filtering for visibility. I modified the test so that it failed (and it's fixed by this patch). - - - - - e6191d39 by Krzysztof Gogolewski at 2021-12-25T18:26:44+01:00 Fix typos - - - - - 3219610e by Greg Steuck at 2021-12-26T22:12:43-05:00 Use POSIX-compliant egrep expression to fix T8832 on OpenBSD - - - - - fd42ab5f by Matthew Pickering at 2021-12-28T09:47:53+00:00 Multiple Home Units Multiple home units allows you to load different packages which may depend on each other into one GHC session. This will allow both GHCi and HLS to support multi component projects more naturally. Public Interface ~~~~~~~~~~~~~~~~ In order to specify multiple units, the -unit @⟨filename⟩ flag is given multiple times with a response file containing the arguments for each unit. The response file contains a newline separated list of arguments. ``` ghc -unit @unitLibCore -unit @unitLib ``` where the `unitLibCore` response file contains the normal arguments that cabal would pass to `--make` mode. ``` -this-unit-id lib-core-0.1.0.0 -i -isrc LibCore.Utils LibCore.Types ``` The response file for lib, can specify a dependency on lib-core, so then modules in lib can use modules from lib-core. ``` -this-unit-id lib-0.1.0.0 -package-id lib-core-0.1.0.0 -i -isrc Lib.Parse Lib.Render ``` Then when the compiler starts in --make mode it will compile both units lib and lib-core. There is also very basic support for multiple home units in GHCi, at the moment you can start a GHCi session with multiple units but only the :reload is supported. Most commands in GHCi assume a single home unit, and so it is additional work to work out how to modify the interface to support multiple loaded home units. Options used when working with Multiple Home Units There are a few extra flags which have been introduced specifically for working with multiple home units. The flags allow a home unit to pretend it’s more like an installed package, for example, specifying the package name, module visibility and reexported modules. -working-dir ⟨dir⟩ It is common to assume that a package is compiled in the directory where its cabal file resides. Thus, all paths used in the compiler are assumed to be relative to this directory. When there are multiple home units the compiler is often not operating in the standard directory and instead where the cabal.project file is located. In this case the -working-dir option can be passed which specifies the path from the current directory to the directory the unit assumes to be it’s root, normally the directory which contains the cabal file. When the flag is passed, any relative paths used by the compiler are offset by the working directory. Notably this includes -i and -I⟨dir⟩ flags. -this-package-name ⟨name⟩ This flag papers over the awkward interaction of the PackageImports and multiple home units. When using PackageImports you can specify the name of the package in an import to disambiguate between modules which appear in multiple packages with the same name. This flag allows a home unit to be given a package name so that you can also disambiguate between multiple home units which provide modules with the same name. -hidden-module ⟨module name⟩ This flag can be supplied multiple times in order to specify which modules in a home unit should not be visible outside of the unit it belongs to. The main use of this flag is to be able to recreate the difference between an exposed and hidden module for installed packages. -reexported-module ⟨module name⟩ This flag can be supplied multiple times in order to specify which modules are not defined in a unit but should be reexported. The effect is that other units will see this module as if it was defined in this unit. The use of this flag is to be able to replicate the reexported modules feature of packages with multiple home units. Offsetting Paths in Template Haskell splices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When using Template Haskell to embed files into your program, traditionally the paths have been interpreted relative to the directory where the .cabal file resides. This causes problems for multiple home units as we are compiling many different libraries at once which have .cabal files in different directories. For this purpose we have introduced a way to query the value of the -working-dir flag to the Template Haskell API. By using this function we can implement a makeRelativeToProject function which offsets a path which is relative to the original project root by the value of -working-dir. ``` import Language.Haskell.TH.Syntax ( makeRelativeToProject ) foo = $(makeRelativeToProject "./relative/path" >>= embedFile) ``` > If you write a relative path in a Template Haskell splice you should use the makeRelativeToProject function so that your library works correctly with multiple home units. A similar function already exists in the file-embed library. The function in template-haskell implements this function in a more robust manner by honouring the -working-dir flag rather than searching the file system. Closure Property for Home Units ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For tools or libraries using the API there is one very important closure property which must be adhered to: > Any dependency which is not a home unit must not (transitively) depend on a home unit. For example, if you have three packages p, q and r, then if p depends on q which depends on r then it is illegal to load both p and r as home units but not q, because q is a dependency of the home unit p which depends on another home unit r. If you are using GHC by the command line then this property is checked, but if you are using the API then you need to check this property yourself. If you get it wrong you will probably get some very confusing errors about overlapping instances. Limitations of Multiple Home Units ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are a few limitations of the initial implementation which will be smoothed out on user demand. * Package thinning/renaming syntax is not supported * More complicated reexports/renaming are not yet supported. * It’s more common to run into existing linker bugs when loading a large number of packages in a session (for example #20674, #20689) * Backpack is not yet supported when using multiple home units. * Dependency chasing can be quite slow with a large number of modules and packages. * Loading wired-in packages as home units is currently not supported (this only really affects GHC developers attempting to load template-haskell). * Barely any normal GHCi features are supported, it would be good to support enough for ghcid to work correctly. Despite these limitations, the implementation works already for nearly all packages. It has been testing on large dependency closures, including the whole of head.hackage which is a total of 4784 modules from 452 packages. Internal Changes ~~~~~~~~~~~~~~~~ * The biggest change is that the HomePackageTable is replaced with the HomeUnitGraph. The HomeUnitGraph is a map from UnitId to HomeUnitEnv, which contains information specific to each home unit. * The HomeUnitEnv contains: - A unit state, each home unit can have different package db flags - A set of dynflags, each home unit can have different flags - A HomePackageTable * LinkNode: A new node type is added to the ModuleGraph, this is used to place the linking step into the build plan so linking can proceed in parralel with other packages being built. * New invariant: Dependencies of a ModuleGraphNode can be completely determined by looking at the value of the node. In order to achieve this, downsweep now performs a more complete job of downsweeping and then the dependenices are recorded forever in the node rather than being computed again from the ModSummary. * Some transitive module calculations are rewritten to use the ModuleGraph which is more efficient. * There is always an active home unit, which simplifies modifying a lot of the existing API code which is unit agnostic (for example, in the driver). The road may be bumpy for a little while after this change but the basics are well-tested. One small metric increase, which we accept and also submodule update to haddock which removes ExtendedModSummary. Closes #10827 ------------------------- Metric Increase: MultiLayerModules ------------------------- Co-authored-by: Fendor <power.walross at gmail.com> - - - - - 72824c63 by Richard Eisenberg at 2021-12-28T10:09:28-05:00 Skip computing superclass origins for equalities This yields a small, but measurable, performance improvement. - - - - - 8b6aafb2 by Matthew Pickering at 2021-12-29T14:09:47-05:00 Cabal: Update submodule Closes #20874 - - - - - 44a5507f by Peter Trommler at 2021-12-29T14:10:22-05:00 RTS: Fix CloneStack.c when no table next to code Function `lookupIPE` does not modify its argument. Reflect this in the type. Module `CloneStack.c` relies on this for RTS without tables next to code. Fixes #20879 - - - - - 246d2782 by sheaf at 2022-01-02T04:20:09-05:00 User's guide: newtype decls can use GADTSyntax The user's guide failed to explicitly mention that GADTSyntax can be used to declare newtypes, so we add an example and a couple of explanations. Also explains that `-XGADTs` generalises `-XExistentialQuantification`. Fixes #20848 and #20865. - - - - - f212cece by Hécate Moonlight at 2022-01-02T04:20:47-05:00 Add a source-repository stanza to rts/rts.cabal - - - - - d9e49195 by Greg Steuck at 2022-01-03T05:18:24+00:00 Replace `seq` with POSIX-standard printf(1) in ManyAlternatives test The test now passes on OpenBSD instead of generating broken source which was rejected by GHC with ManyAlternatives.hs:5:1: error: The type signature for ‘f’ lacks an accompanying binding - - - - - 80e416ae by Greg Steuck at 2022-01-03T05:18:24+00:00 Replace `seq` with POSIX-standard in PmSeriesG test - - - - - 8fa52f5c by Eric Lindblad at 2022-01-03T16:48:51-05:00 fix typo - - - - - a49f5889 by Roland Senn at 2022-01-03T16:49:29-05:00 Add regressiontest for #18045 Issue #18045 got fixed by !6971. - - - - - 7f10686e by sheaf at 2022-01-03T16:50:07-05:00 Add test for #20894 - - - - - 5111028e by sheaf at 2022-01-04T19:56:13-05:00 Check quoted TH names are in the correct namespace When quoting (using a TH single or double quote) a built-in name such as the list constructor (:), we didn't always check that the resulting 'Name' was in the correct namespace. This patch adds a check in GHC.Rename.Splice to ensure we get a Name that is in the term-level/type-level namespace, when using a single/double tick, respectively. Fixes #20884. - - - - - 1de94daa by George Thomas at 2022-01-04T19:56:51-05:00 Fix Haddock parse error in GHC.Exts.Heap.FFIClosures.hs - - - - - e59bd46a by nineonine at 2022-01-05T18:07:18+00:00 Add regression test (#13997) - - - - - c080b443 by Sylvain Henry at 2022-01-06T02:24:54-05:00 Perf: use SmallArray for primops' Ids cache (#20857) SmallArray doesn't perform bounds check (faster). Make primop tags start at 0 to avoid index arithmetic. - - - - - ec26c38b by Sylvain Henry at 2022-01-06T02:24:54-05:00 Use primOpIds cache more often (#20857) Use primOpId instead of mkPrimOpId in a few places to benefit from Id caching. I had to mess a little bit with the module hierarchy to fix cycles and to avoid adding too many new dependencies to count-deps tests. - - - - - f7fc62e2 by Greg Steuck at 2022-01-06T07:56:22-05:00 Disable T2615 on OpenBSD, close #20869 - - - - - 978ea35e by Greg Steuck at 2022-01-06T07:57:00-05:00 Change ulimit -n in openFile008 back to 1024 The test only wants 1000 descriptors, so changing the limit to double that *in the context of just this test* makes no sense. This is a manual revert of 8f7194fae23bdc6db72fc5784933f50310ce51f9. The justification given in the description doesn't instill confidence. As of HEAD, the test fails on OpenBSD where ulimit -n is hard-limited to 1024. The test suite attempts to change it to 2048, which fails. The test proceeds with the unchanged default of 512 and naturally the test program fails due to the low ulimit. The fixed test now passes. - - - - - 7b783c9d by Matthew Pickering at 2022-01-07T18:25:06-05:00 Thoughtful forcing in CoreUnfolding We noticed that the structure of CoreUnfolding could leave double the amount of CoreExprs which were retained in the situation where the template but not all the predicates were forced. This observation was then confirmed using ghc-debug: ``` (["ghc:GHC.Core:App","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 237) (["ghc:GHC.Core:App","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 1) (["ghc:GHC.Core:Case","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 12) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","BLACKHOLE"],Count 1) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 78) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","ghc-prim:GHC.Types:False","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","THUNK_1_0","THUNK_1_0"],Count 3) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","BLACKHOLE"],Count 31) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 4307) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 6) (["ghc:GHC.Core:Let","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 29) (["ghc:GHC.Core:Lit","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 1) (["ghc:GHC.Core:Tick","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 36) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","THUNK_1_0","THUNK_1_0"],Count 6) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","ghc-prim:GHC.Types:True","THUNK_1_0"],Count 2) ``` Where we can see that the first argument is forced but there are still thunks remaining which retain the old expr. For my test case (a very big module, peak of 3 000 000 core terms) this reduced peak memory usage by 1G (12G -> 11G). Fixes #20905 - - - - - f583eb8e by Joachim Breitner at 2022-01-07T18:25:41-05:00 Remove dangling references to Note [Type-checking overloaded labels] that note was removed in 4196969c53c55191e644d9eb258c14c2bc8467da - - - - - 2b6c2179 by Matthew Pickering at 2022-01-11T19:37:45-05:00 hadrian: Add bootstrap scripts for building without cabal-install These scripts are originally from the cabal-install repo with a few small tweaks. This utility allows you to build hadrian without cabal-install, which can be useful for packagers. If you are a developer then build hadrian using cabal-install. If you want to bootstrap with ghc-8.10.5 then run the ./bootstrap script with the `plan-bootstrap-8.10.5.json` file. bootstrap.py -d plan-bootstrap-8.10.5.json -w /path/to-ghc The result of the bootstrap script will be a hadrian binary in `_build/bin/hadrian`. There is a script (using nix) which can be used to generate the bootstrap plans for the range of supported GHC versions using nix. generate_bootstrap_plans Otherwise you can run the commands in ./generate_bootstrap_plans directly. Fixes #17103 - - - - - a8fb4251 by Zubin Duggal at 2022-01-11T19:37:45-05:00 hadrian: allow offline bootstrapping This patch adds the ability to fetch and store dependencies needed for boostrapping hadrian. By default the script will download the dependencies from the network but some package managers disallow network access so there are also options to build given a supplied tarball. The -s option allos you to provide the tarball bootstrap.py -d plan-bootstrap-8.10.5.json -w /path/to-ghc -s sources-tarball.tar.gz Which dependencies you need can be queried using the `list-sources` option. bootstrap.py list-sources -d plan-bootstrap-8.10.5.json This produces `fetch_plan.json` which tells you where to get each source from. You can instruct the script to create the tarball using the `fetch` option. bootstrap.py fetch -d plan-bootstrap-8.10.5.json -o sources-tarball.tar.gz Together these commands mean you can build GHC without needing cabal-install. Fixes #17103 - - - - - 02cf4bc6 by Zubin Duggal at 2022-01-11T19:37:45-05:00 hadrian: Fully implement source distributions (#19317) We use `git ls-files` to get the list of files to include in the source distribution. Also implements the `-testsuite` and `-extra-tarballs` distributions. - - - - - 85473a09 by Zubin Duggal at 2022-01-11T19:37:45-05:00 ci: test bootstrapping and use hadrian for source dists - - - - - 759f3421 by Matthew Pickering at 2022-01-11T19:38:21-05:00 ci: Nightly, run one head.hackage job with core-lint and one without This fixes serious skew in the performance numbers because the packages were build with core-lint. Fixes #20826 - - - - - 6737c8e1 by Ben Gamari at 2022-01-11T19:38:56-05:00 rts: Depend explicitly on libc As noted in #19029, currently `ghc-prim` explicitly lists `libc` in `extra-libraries`, resulting in incorrect link ordering with the `extra-libraries: pthread` in `libHSrts`. Fix this by adding an explicit dependency on `libc` to `libHSrts`. Closes #19029. - - - - - 247cd336 by Ben Gamari at 2022-01-11T19:39:32-05:00 rts: Only declare environ when necessary Previously we would unconditionally provide a declaration for `environ`, even if `<unistd.h>` already provided one. This would result in `-Werror` builds failing on some platforms. Also `#include <unistd.h>` to ensure that the declaration is visible. Fixes #20861. - - - - - b65e7274 by Greg Steuck at 2022-01-11T19:40:10-05:00 Skip T18623 on OpenBSD The bug it regresses didn't happen on this OS (no RLIMIT_AS) and the regression doesn't work (ulimit: -v: unknown option) - - - - - c6300cb3 by Greg Steuck at 2022-01-11T19:40:50-05:00 Skip T16180 on OpenBSD due to bug #14012 - - - - - addf8e54 by sheaf at 2022-01-11T19:41:28-05:00 Kind TyCons: require KindSignatures, not DataKinds Uses of a TyCon in a kind signature required users to enable DataKinds, which didn't make much sense, e.g. in type U = Type type MyMaybe (a :: U) = MyNothing | MyJust a Now the DataKinds error is restricted to data constructors; the use of kind-level type constructors is instead gated behind -XKindSignatures. This patch also adds a convenience pattern synonym for patching on both a TyCon or a TcTyCon stored in a TcTyThing, used in tcTyVar and tc_infer_id. fixes #20873 - - - - - 34d8bc24 by sheaf at 2022-01-11T19:42:07-05:00 Fix parsing & printing of unboxed sums The pretty-printing of partially applied unboxed sums was incorrect, as we incorrectly dropped the first half of the arguments, even for a partial application such as (# | #) @IntRep @DoubleRep Int# which lead to the nonsensical (# DoubleRep | Int# #). This patch also allows users to write unboxed sum type constructors such as (# | #) :: TYPE r1 -> TYPE r2 -> TYPE (SumRep '[r1,r2]). Fixes #20858 and #20859. - - - - - 49731fed by sheaf at 2022-01-11T19:42:46-05:00 TcPlugins: `newWanted` uses the provided `CtLoc` The `GHC.Tc.Plugin.newWanted` function takes a `CtLoc` as an argument, but it used to discard the location information, keeping only the `CtOrigin`. It would then retrieve the source location from the `TcM` environment using `getCtLocM`. This patch changes this so that `GHC.Tc.Plugin.newWanted` passes on the full `CtLoc`. This means that authors of type-checking plugins no longer need to manually set the `CtLoc` environment in the `TcM` monad if they want to create a new Wanted constraint with the given `CtLoc` (in particular, for setting the `SrcSpan` of an emitted constraint). This makes the `newWanted` function consistent with `newGiven`, which always used the full `CtLoc` instead of using the environment. Fixes #20895 - - - - - 23d215fc by Krzysztof Gogolewski at 2022-01-11T19:43:22-05:00 warnPprTrace: pass separately the reason This makes it more similar to pprTrace, pprPanic etc. - - - - - 833216a3 by Matthew Pickering at 2022-01-11T19:43:57-05:00 Use interactive flags when printing expressions in GHCi The documentation states that the interactive flags should be use for any interactive expressions. The interactive flags are used when typechecking these expressions but not when printing. The session flags (modified by :set) are only used when loading a module. Fixes #20909 - - - - - 19b13698 by Matthew Pickering at 2022-01-11T19:43:57-05:00 Enable :seti in a multi component repl Part of #20889 - - - - - 7ca43a3f by Matthew Pickering at 2022-01-11T19:44:33-05:00 Change assertions in Stats.c to warnings (and introduce WARN macro) ASSERT should be used in situations where something very bad will happen later on if a certain invariant doesn't hold. The idea is that IF we catch the assertion earlier then it will be easier to work out what's going on at that point rather than at some indeterminate point in the future of the program. The assertions in Stats.c do not obey this philsophy and it is quite annoying if you are running a debug build (or a ticky compiler) and one of these assertions fails right at the end of your program, before the ticky report is printed out so you don't get any profiling information. Given that nothing terrible happens if these assertions are not true, or at least the terrible thing will happen in very close proximity to the assertion failure, these assertions use the new WARN macro which prints the assertion failure to stdout but does not exit the program. Of course, it would be better to fix these metrics to not trigger the assertion in the first place but if they did fail again in the future it is frustrating to be bamboozled in this manner. Fixes #20899 - - - - - e505dbd3 by Greg Steuck at 2022-01-11T19:45:11-05:00 Remove from error the parenthesized amount of memory requested Diagnostics for outofmem test on OpenBSD includes the amount of memory that it failed to allocate. This seems like an irrelevant detail that could change over time and isn't required for determining if test passed. Typical elided text is '(requested 2148532224 bytes)' - - - - - 7911aaa9 by Greg Steuck at 2022-01-11T19:45:50-05:00 Feed /dev/null into cgrun025 The test currently times out waiting for end of stdin in getContents. The expected output indicates that nothing should come for the test to pass as written. It is unclear how the test was supposed to pass, but this looks like a sufficient hack to make it work. - - - - - ed39d15c by Greg Steuck at 2022-01-11T19:46:28-05:00 Disable keep-cafs{,-fail} tests on OpenBSD They are likely broken for the same reason as FreeBSD where the tests are already disabled. - - - - - 35bea01b by Peter Trommler at 2022-01-11T19:47:04-05:00 RTS: Remove unused file xxhash.c - - - - - c2099059 by Matthew Pickering at 2022-01-11T19:47:39-05:00 RTTI: Substitute the [rk] skolems into kinds (Fixes #10616 and #10617) Co-authored-by: Roland Senn <rsx at bluewin.ch> - - - - - 92f3e6e4 by Matthew Pickering at 2022-01-11T19:48:15-05:00 docs: MonadComprehension desugar using Alternative rather than MonadPlus Fixes #20928 - - - - - 7b0c9384 by Sylvain Henry at 2022-01-12T23:25:49-05:00 Abstract BangOpts Avoid requiring to pass DynFlags to mkDataConRep/buildDataCon. When we load an interface file, these functions don't use the flags. This is preliminary work to decouple the loader from the type-checker for #14335. - - - - - a31ace56 by Sylvain Henry at 2022-01-12T23:25:49-05:00 Untangled GHC.Types.Id.Make from the driver - - - - - 81a8f7a7 by Zubin Duggal at 2022-01-12T23:26:24-05:00 testsuite: Fix import on python 3.10 - - - - - 66831b94 by Ben Gamari at 2022-01-13T14:50:13-05:00 hadrian: Include bash completion script in bindist See #20802. - - - - - be33d61a by Sebastian Graf at 2022-01-13T14:50:49-05:00 release notes: Changes to CPR analysis - - - - - c2a6c3eb by Sebastian Graf at 2022-01-13T14:50:49-05:00 release notes: Changes to Demand analysis - - - - - 9ccc445a by Eric Lindblad at 2022-01-14T10:35:46-05:00 add NUMJOBS - - - - - 564b89ae by Eric Lindblad at 2022-01-14T10:35:46-05:00 Revert "add NUMJOBS" This reverts commit c0b854e929f82c680530e944e12fad24f9e14f8e - - - - - 2dfc268c by Eric Lindblad at 2022-01-14T10:35:46-05:00 update URLs - - - - - 1aace894 by Eric Lindblad at 2022-01-14T10:35:46-05:00 reinsert target - - - - - 52a4f5ab by Andreas Klebinger at 2022-01-14T10:36:21-05:00 Add test for #20938. - - - - - e2b60be8 by Ben Gamari at 2022-01-15T03:41:16-05:00 rts: Consolidate RtsSymbols from libc Previously (9ebda74ec5331911881d734b21fbb31c00a0a22f) `environ` was added to `RtsSymbols` to ensure that environment was correctly propagated when statically linking. However, this introduced #20577 since platforms are inconsistent in whether they provide a prototype for `environ`. I fixed this by providing a prototype but while doing so dropped symbol-table entry, presumably thinking that it was redundant due to the entry in the mingw-specific table. Here I reintroduce the symbol table entry for `environ` and move libc symbols shared by Windows and Linux into a new macro, `RTS_LIBC_SYMBOLS`, avoiding this potential confusion. - - - - - 0dc72395 by Tamar Christina at 2022-01-15T03:41:55-05:00 winio: fix heap corruption and various leaks. - - - - - 4031ef62 by Eric Lindblad at 2022-01-15T20:11:55+00:00 wikipedia link - - - - - a13aff98 by Eric Lindblad at 2022-01-17T08:25:51-05:00 ms link - - - - - f161e890 by sheaf at 2022-01-17T14:52:50+00:00 Use diagnostic infrastructure in GHC.Tc.Errors - - - - - 18c797b8 by Jens Petersen at 2022-01-18T16:12:14-05:00 hadrian BinaryDist: version ghc in ghciScriptWrapper like we do for the non-Hadrian wrapper script. Otherwise if $bindir/ghc is a different ghc version then versioned ghci will incorrectly run the other ghc version instead. (Normally this would only happen if there are parallel ghc versions installed in bindir.) All the other wrapper scripts already have versioned executablename - - - - - 310424d0 by Matthew Pickering at 2022-01-18T16:12:50-05:00 Correct type of static forms in hsExprType The simplest way to do this seemed to be to persist the whole type in the extension field from the typechecker so that the few relevant places * Desugaring can work out the return type by splitting this type rather than calling `dsExpr` (slightly more efficient). * hsExprType can just return the correct type. * Zonking has to now zonk the type as well The other option we considered was wiring in StaticPtr but that is actually quite tricky because StaticPtr refers to StaticPtrInfo which has field selectors (which we can't easily wire in). Fixes #20150 - - - - - 7ec783de by Matthew Pickering at 2022-01-18T16:12:50-05:00 Add test for using type families with static pointers Issue was reported on #13306 - - - - - 2d205154 by Sebastian Graf at 2022-01-18T16:13:25-05:00 Stricten the Strict State monad I found it weird that most of the combinators weren't actually strict. Making `pure` strict in the state should hopefully give Nested CPR an easier time to unbox the nested state. - - - - - 5a6efd21 by Ben Gamari at 2022-01-18T16:14:01-05:00 rts/winio: Fix #18382 Here we refactor WinIO's IO completion scheme, squashing a memory leak and fixing #18382. To fix #18382 we drop the special thread status introduced for IoPort blocking, BlockedOnIoCompletion, as well as drop the non-threaded RTS's special dead-lock detection logic (which is redundant to the GC's deadlock detection logic), as proposed in #20947. Previously WinIO relied on foreign import ccall "wrapper" to create an adjustor thunk which can be attached to the OVERLAPPED structure passed to the operating system. It would then use foreign import ccall "dynamic" to back out the original continuation from the adjustor. This roundtrip is significantly more expensive than the alternative, using a StablePtr. Furthermore, the implementation let the adjustor leak, meaning that every IO request would leak a page of memory. Fixes T18382. - - - - - 01254ceb by Matthew Pickering at 2022-01-18T16:14:37-05:00 Add note about heap invariant Closed #20904 - - - - - 21510698 by Sergey Vinokurov at 2022-01-18T16:15:12-05:00 Improve detection of lld linker Newer lld versions may include vendor info in --version output and thus the version string may not start with ‘LLD’. Fixes #20907 - - - - - 95e7964b by Peter Trommler at 2022-01-18T20:46:08-05:00 Fix T20638 on big-endian architectures The test reads a 16 bit value from an array of 8 bit values. Naturally, that leads to different values read on big-endian architectures than on little-endian. In this case the value read is 0x8081 on big-endian and 0x8180 on little endian. This patch changes the argument of the `and` machop to mask bit 7 which is the only bit different. The test still checks that bit 15 is zero, which was the original issue in #20638. Fixes #20906. - - - - - fd0019a0 by Eric Lindblad at 2022-01-18T20:46:48-05:00 ms and gh links - - - - - 85dc61ee by Zubin Duggal at 2022-01-18T20:47:23-05:00 ci: Fix subtlety with not taking effect because of time_it (#20898) - - - - - 592e4113 by Anselm Schüler at 2022-01-19T13:31:49-05:00 Note that ImpredicativeTypes doesn’t allow polymorphic instances See #20939 - - - - - 3b009e1a by Ben Gamari at 2022-01-19T13:32:25-05:00 base: Add CTYPE pragmas to all foreign types Fixes #15531 by ensuring that we know the corresponding C type for all marshalling wrappers. Closes #15531. - - - - - 516eeb9e by Robert Hensing at 2022-01-24T21:28:24-05:00 Add -fcompact-unwind This gives users the choice to enable __compact_unwind sections when linking. These were previously hardcoded to be removed. This can be used to solved the problem "C++ does not catch exceptions when used with Haskell-main and linked by ghc", https://gitlab.haskell.org/ghc/ghc/-/issues/11829 It does not change the default behavior, because I can not estimate the impact this would have. When Apple first introduced the compact unwind ABI, a number of open source projects have taken the easy route of disabling it, avoiding errors or even just warnings shortly after its introduction. Since then, about a decade has passed, so it seems quite possible that Apple itself, and presumably many programs with it, have successfully switched to the new format, to the point where the old __eh_frame section support is in disrepair. Perhaps we should get along with the program, but for now we can test the waters with this flag, and use it to fix packages that need it. - - - - - 5262b1e5 by Robert Hensing at 2022-01-24T21:28:24-05:00 Add test case for C++ exception handling - - - - - a5c94092 by Sebastian Graf at 2022-01-24T21:29:00-05:00 Write Note [Strict State monad] to explain what G.U.M.State.Strict does As requested by Simon after review of !7342. I also took liberty to define the `Functor` instance by hand, as the derived one subverts the invariants maintained by the pattern synonym (as already stated in `Note [The one-shot state monad trick]`). - - - - - 9b0d56d3 by Eric Lindblad at 2022-01-24T21:29:38-05:00 links - - - - - 4eac8e72 by Ben Gamari at 2022-01-24T21:30:13-05:00 ghc-heap: Drop mention of BlockedOnIOCompletion Fixes bootstrap with GHC 9.0 after 5a6efd218734dbb5c1350531680cd3f4177690f1 - - - - - 7d7b9a01 by Ryan Scott at 2022-01-24T21:30:49-05:00 Hadrian: update the index-state to allow building with GHC 9.0.2 Fixes #20984. - - - - - aa50e118 by Peter Trommler at 2022-01-24T21:31:25-05:00 testsuite: Mark test that require RTS linker - - - - - 871ce2a3 by Matthew Pickering at 2022-01-25T17:27:30-05:00 ci: Move (most) deb9 jobs to deb10 deb9 is now end-of-life so we are dropping support for producing bindists. - - - - - 9d478d51 by Ryan Scott at 2022-01-25T17:28:06-05:00 DeriveGeneric: look up datacon fixities using getDataConFixityFun Previously, `DeriveGeneric` would look up the fixity of a data constructor using `getFixityEnv`, but this is subtly incorrect for data constructors defined in external modules. This sort of situation can happen with `StandaloneDeriving`, as noticed in #20994. In fact, the same bug has occurred in the past in #9830, and while that bug was fixed for `deriving Read` and `deriving Show`, the fix was never extended to `DeriveGeneric` due to an oversight. This patch corrects that oversight. Fixes #20994. - - - - - 112e9e9e by Zubin Duggal at 2022-01-25T17:28:41-05:00 Fix Werror on alpine - - - - - 781323a3 by Matthew Pickering at 2022-01-25T17:29:17-05:00 Widen T12545 acceptance window This test has been the scourge of contributors for a long time. It has caused many failed CI runs and wasted hours debugging a test which barely does anything. The fact is does nothing is the reason for the flakiness and it's very sensitive to small changes in initialisation costs, in particular adding wired-in things can cause this test to fluctuate quite a bit. Therefore we admit defeat and just bump the threshold up to 10% to catch very large regressions but otherwise don't care what this test does. Fixes #19414 - - - - - e471a680 by sheaf at 2022-01-26T12:01:45-05:00 Levity-polymorphic arrays and mutable variables This patch makes the following types levity-polymorphic in their last argument: - Array# a, SmallArray# a, Weak# b, StablePtr# a, StableName# a - MutableArray# s a, SmallMutableArray# s a, MutVar# s a, TVar# s a, MVar# s a, IOPort# s a The corresponding primops are also made levity-polymorphic, e.g. `newArray#`, `readArray#`, `writeMutVar#`, `writeIOPort#`, etc. Additionally, exception handling functions such as `catch#`, `raise#`, `maskAsyncExceptions#`,... are made levity/representation-polymorphic. Now that Array# and MutableArray# also work with unlifted types, we can simply re-define ArrayArray# and MutableArrayArray# in terms of them. This means that ArrayArray# and MutableArrayArray# are no longer primitive types, but simply unlifted newtypes around Array# and MutableArrayArray#. This completes the implementation of the Pointer Rep proposal https://github.com/ghc-proposals/ghc-proposals/pull/203 Fixes #20911 ------------------------- Metric Increase: T12545 ------------------------- ------------------------- Metric Decrease: T12545 ------------------------- - - - - - 6e94ba54 by Andreas Klebinger at 2022-01-26T12:02:21-05:00 CorePrep: Don't try to wrap partial applications of primops in profiling ticks. This fixes #20938. - - - - - b55d7db3 by sheaf at 2022-01-26T12:03:01-05:00 Ensure that order of instances doesn't matter The insert_overlapping used in lookupInstEnv used to return different results depending on the order in which instances were processed. The problem was that we could end up discarding an overlapping instance in favour of a more specific non-overlapping instance. This is a problem because, even though we won't choose the less-specific instance for matching, it is still useful for pruning away other instances, because it has the overlapping flag set while the new instance doesn't. In insert_overlapping, we now keep a list of "guard" instances, which are instances which are less-specific that one that matches (and hence which we will discard in the end), but want to keep around solely for the purpose of eliminating other instances. Fixes #20946 - - - - - 61f62062 by sheaf at 2022-01-26T12:03:40-05:00 Remove redundant SOURCE import in FitTypes Fixes #20995 - - - - - e8405829 by sheaf at 2022-01-26T12:04:15-05:00 Fix haddock markup in GHC.Tc.Errors.Types - - - - - 590a2918 by Simon Peyton Jones at 2022-01-26T19:45:22-05:00 Make RULE matching insensitive to eta-expansion This patch fixes #19790 by making the rule matcher do on-the-fly eta reduction. See Note [Eta reduction the target] in GHC.Core.Rules I found I also had to careful about casts when matching; see Note [Casts in the target] and Note [Casts in the template] Lots more comments and Notes in the rule matcher - - - - - c61ac4d8 by Matthew Pickering at 2022-01-26T19:45:58-05:00 alwaysRerun generation of ghcconfig This file needs to match exactly what is passed as the testCompiler. Before this change the settings for the first compiler to be tested woudl be stored and not regenerated if --test-compiler changed. - - - - - b5132f86 by Matthew Pickering at 2022-01-26T19:45:58-05:00 Pass config.stage argument to testsuite - - - - - 83d3ad31 by Zubin Duggal at 2022-01-26T19:45:58-05:00 hadrian: Allow testing of the stage1 compiler (#20755) - - - - - a5924b38 by Joachim Breitner at 2022-01-26T19:46:34-05:00 Simplifier: Do the right thing if doFloatFromRhs = False If `doFloatFromRhs` is `False` then the result from `prepareBinding` should not be used. Previously it was in ways that are silly (but not completly wrong, as the simplifier would clean that up again, so no test case). This was spotted by Simon during a phone call. Fixes #20976 - - - - - ce488c2b by Simon Peyton Jones at 2022-01-26T19:47:09-05:00 Better occurrence analysis with casts This patch addresses #20988 by refactoring the way the occurrence analyser deals with lambdas. Previously it used collectBinders to split off a group of binders, and deal with them together. Now I deal with them one at a time in occAnalLam, which allows me to skip casts easily. See Note [Occurrence analysis for lambda binders] about "lambda-groups" This avoidance of splitting out a list of binders has some good consequences. Less code, more efficient, and I think, more clear. The Simplifier needed a similar change, now that lambda-groups can inlude casts. It turned out that I could simplify the code here too, in particular elminating the sm_bndrs field of StrictBind. Simpler, more efficient. Compile-time metrics improve slightly; here are the ones that are +/- 0.5% or greater: Baseline Test Metric value New value Change -------------------------------------------------------------------- T11303b(normal) ghc/alloc 40,736,702 40,543,992 -0.5% T12425(optasm) ghc/alloc 90,443,459 90,034,104 -0.5% T14683(normal) ghc/alloc 2,991,496,696 2,956,277,288 -1.2% T16875(normal) ghc/alloc 34,937,866 34,739,328 -0.6% T17977b(normal) ghc/alloc 37,908,550 37,709,096 -0.5% T20261(normal) ghc/alloc 621,154,237 618,312,480 -0.5% T3064(normal) ghc/alloc 190,832,320 189,952,312 -0.5% T3294(normal) ghc/alloc 1,604,674,178 1,604,608,264 -0.0% T5321FD(normal) ghc/alloc 270,540,489 251,888,480 -6.9% GOOD T5321Fun(normal) ghc/alloc 300,707,814 281,856,200 -6.3% GOOD WWRec(normal) ghc/alloc 588,460,916 585,536,400 -0.5% geo. mean -0.3% Metric Decrease: T5321FD T5321Fun - - - - - 4007905d by Roland Senn at 2022-01-26T19:47:47-05:00 Cleanup tests in directory ghci.debugger. Fixes #21009 * Remove wrong comment about panic in `break003.script`. * Improve test `break008`. * Add test `break028` to `all.T` * Fix wrong comments in `print019.script`, `print026.script` and `result001.script`. * Remove wrong comments from `print024.script` and `print031.script`. * Replace old module name with current name in `print035.script`. - - - - - 3577defb by Matthew Pickering at 2022-01-26T19:48:22-05:00 ci: Move source-tarball and test-bootstrap into full-build - - - - - 6e09b3cf by Matthew Pickering at 2022-01-27T02:39:35-05:00 ci: Add ENABLE_NUMA flag to explicitly turn on libnuma dependency In recent releases a libnuma dependency has snuck into our bindists because the images have started to contain libnuma. We now explicitly pass `--disable-numa` to configure unless explicitly told not to by using the `ENABLE_NUMA` environment variable. So this is tested, there is one random validate job which builds with --enable-numa so that the code in the RTS is still built. Fixes #20957 and #15444 - - - - - f4ce4186 by Simon Peyton Jones at 2022-01-27T02:40:11-05:00 Improve partial signatures As #20921 showed, with partial signatures, it is helpful to use the same algorithm (namely findInferredDiff) for * picking the constraints to retain for the /group/ in Solver.decideQuantification * picking the contraints to retain for the /individual function/ in Bind.chooseInferredQuantifiers This is still regrettably declicate, but it's a step forward. - - - - - 0573aeab by Simon Peyton Jones at 2022-01-27T02:40:11-05:00 Add an Outputable instance for RecTcChecker - - - - - f0adea14 by Ryan Scott at 2022-01-27T02:40:47-05:00 Expand type synonyms in markNominal `markNominal` is repsonsible for setting the roles of type variables that appear underneath an `AppTy` to be nominal. However, `markNominal` previously did not expand type synonyms, so in a data type like this: ```hs data M f a = MkM (f (T a)) type T a = Int ``` The `a` in `M f a` would be marked nominal, even though `T a` would simply expand to `Int`. The fix is simple: call `coreView` as appropriate in `markNominal`. This is much like the fix for #14101, but in a different spot. Fixes #20999. - - - - - 18df4013 by Simon Peyton Jones at 2022-01-27T08:22:30-05:00 Define and use restoreLclEnv This fixes #20981. See Note [restoreLclEnv vs setLclEnv] in GHC.Tc.Utils.Monad. I also use updLclEnv rather than get/set when I can, because it's then much clearer that it's an update rather than an entirely new TcLclEnv coming from who-knows-where. - - - - - 31088dd3 by David Feuer at 2022-01-27T08:23:05-05:00 Add test supplied in T20996 which uses data family result kind polymorphism David (@treeowl) writes: > Following @kcsongor, I've used ridiculous data family result kind > polymorphism in `linear-generics`, and am currently working on getting > it into `staged-gg`. If it should be removed, I'd appreciate a heads up, > and I imagine Csongor would too. > > What do I need by ridiculous polymorphic result kinds? Currently, data > families are allowed to have result kinds that end in `Type` (or maybe > `TYPE r`? I'm not sure), but not in concrete data kinds. However, they > *are* allowed to have polymorphic result kinds. This leads to things I > think most of us find at least quite *weird*. For example, I can write > > ```haskell > data family Silly :: k > data SBool :: Bool -> Type where > SFalse :: SBool False > STrue :: SBool True > SSSilly :: SBool Silly > type KnownBool b where > kb :: SBool b > instance KnownBool False where kb = SFalse > instance KnownBool True where kb = STrue > instance KnownBool Silly where kb = Silly > ``` > > Basically, every kind now has potentially infinitely many "legit" inhabitants. > > As horrible as that is, it's rather useful for GHC's current native > generics system. It's possible to use these absurdly polymorphic result > kinds to probe the structure of generic representations in a relatively > pleasant manner. It's a sort of "formal type application" reminiscent of > the notion of a formal power series (see the test case below). I suspect > a system more like `kind-generics` wouldn't need this extra probing > power, but nothing like that is natively available as yet. > > If the ridiculous result kind polymorphism is banished, we'll still be > able to do what we need as long as we have stuck type families. It's > just rather less ergonomical: a stuck type family has to be used with a > concrete marker type argument. Closes #20996 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 8fd2ac25 by Andreas Abel at 2022-01-27T18:34:54-05:00 Whitespace only - - - - - 7a854743 by Andreas Abel at 2022-01-27T18:34:54-05:00 Ctd. #18087: complete :since: info for all warnings in users guide Some warnings have been there "forever" and I could not trace back the exact genesis, so I wrote "since at least 5.04". The flag `helpful-errors` could have been added in 7.2 already. I wrote 7.4 since I have no 7.2 available and it is not recognized by 7.0. - - - - - f75411e8 by Andreas Abel at 2022-01-27T18:34:54-05:00 Re #18087 user's guide: add a note that -Wxxx used to be -fwarn-xxx The warning option syntax -W was introduced in GHC 8. The note should clarify what e.g. "since 7.6" means in connection with "-Wxxx": That "-fwarn-xxx" was introduced in 7.6.1. [ci skip] - - - - - 3cae7fde by Peter Trommler at 2022-01-27T18:35:30-05:00 testsuite: Fix AtomicPrimops test on big endian - - - - - 6cc6080c by Ben Gamari at 2022-01-27T18:36:05-05:00 users-guide: Document GHC_CHARENC environment variable As noted in #20963, this was introduced in 1b56c40578374a15b4a2593895710c68b0e2a717 but was no documentation was added at that point. Closes #20963. - - - - - ee21e2de by Ben Gamari at 2022-01-27T18:36:41-05:00 rts: Clean up RTS flags usage message Align flag descriptions and acknowledge that some flags may not be available unless the user linked with `-rtsopts` (as noted in #20961). Fixes #20961. - - - - - 7f8ce19e by Simon Peyton Jones at 2022-01-27T18:37:17-05:00 Fix getHasGivenEqs The second component is supposed to be "insoluble equalities arising from givens". But we were getting wanteds too; and that led to an outright duplication of constraints. It's not harmful, but it's not right either. I came across this when debugging something else. Easily fixed. - - - - - f9ef2d26 by Simon Peyton Jones at 2022-01-27T18:37:17-05:00 Set the TcLclEnv when solving a ForAll constraint Fix a simple omission in GHC.Tc.Solver.Canonical.solveForAll, where we ended up with the wrong TcLclEnv captured in an implication. Result: unhelpful error message (#21006) - - - - - bc6ba8ef by Sylvain Henry at 2022-01-28T12:14:41-05:00 Make most shifts branchless - - - - - 62a6d037 by Simon Peyton Jones at 2022-01-28T12:15:17-05:00 Improve boxity in deferAfterPreciseException As #20746 showed, the demand analyser behaved badly in a key I/O library (`GHC.IO.Handle.Text`), by unnessarily boxing and reboxing. This patch adjusts the subtle function deferAfterPreciseException; it's quite easy, just a bit subtle. See the new Note [deferAfterPreciseException] And this MR deals only with Problem 2 in #20746. Problem 1 is still open. - - - - - 42c47cd6 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/trace: Shrink tracing flags - - - - - cee66e71 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/EventLog: Mark various internal globals as static - - - - - 6b0cea29 by Ben Gamari at 2022-01-29T02:40:45-05:00 Propagate PythonCmd to make build system - - - - - 2e29edb7 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts: Refactor event types Previously we would build the eventTypes array at runtime during RTS initialization. However, this is completely unnecessary; it is completely static data. - - - - - bb15c347 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/eventlog: Ensure that flushCount is initialized - - - - - 268efcc9 by Matthew Pickering at 2022-01-29T02:41:21-05:00 Rework the handling of SkolemInfo The main purpose of this patch is to attach a SkolemInfo directly to each SkolemTv. This fixes the large number of bugs which have accumulated over the years where we failed to report errors due to having "no skolem info" for particular type variables. Now the origin of each type varible is stored on the type variable we can always report accurately where it cames from. Fixes #20969 #20732 #20680 #19482 #20232 #19752 #10946 #19760 #20063 #13499 #14040 The main changes of this patch are: * SkolemTv now contains a SkolemInfo field which tells us how the SkolemTv was created. Used when reporting errors. * Enforce invariants relating the SkolemInfoAnon and level of an implication (ic_info, ic_tclvl) to the SkolemInfo and level of the type variables in ic_skols. * All ic_skols are TcTyVars -- Check is currently disabled * All ic_skols are SkolemTv * The tv_lvl of the ic_skols agrees with the ic_tclvl * The ic_info agrees with the SkolInfo of the implication. These invariants are checked by a debug compiler by checkImplicationInvariants. * Completely refactor kcCheckDeclHeader_sig which kept doing my head in. Plus, it wasn't right because it wasn't skolemising the binders as it decomposed the kind signature. The new story is described in Note [kcCheckDeclHeader_sig]. The code is considerably shorter than before (roughly 240 lines turns into 150 lines). It still has the same awkward complexity around computing arity as before, but that is a language design issue. See Note [Arity inference in kcCheckDeclHeader_sig] * I added new type synonyms MonoTcTyCon and PolyTcTyCon, and used them to be clear which TcTyCons have "finished" kinds etc, and which are monomorphic. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] * I renamed etaExpandAlgTyCon to splitTyConKind, becuase that's a better name, and it is very useful in kcCheckDeclHeader_sig, where eta-expansion isn't an issue. * Kill off the nasty `ClassScopedTvEnv` entirely. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 0a1d0944 by Ben Gamari at 2022-01-29T14:52:55-05:00 Drop SPARC NCG - - - - - 313afb3d by Ben Gamari at 2022-01-29T14:52:56-05:00 A few comment cleanups - - - - - d85a527f by Ben Gamari at 2022-01-29T14:52:56-05:00 Rip out SPARC register support - - - - - c6bede69 by Ben Gamari at 2022-01-29T14:52:56-05:00 rts: Rip out SPARC support - - - - - a67c2471 by Ben Gamari at 2022-01-29T14:52:56-05:00 Rip out remaining SPARC support - - - - - 5771b690 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Drop RegPair SPARC was its last and only user. - - - - - 512ed3f1 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Make RealReg a newtype Now that RegPair is gone we no longer need to pay for the additional box. - - - - - 88fea6aa by Ben Gamari at 2022-01-29T14:52:56-05:00 rts: Drop redundant #include <Arena.h> - - - - - ea2a4034 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Drop ncgExpandTop This was only needed for SPARC's synthetic instructions. - - - - - 88fce740 by Ben Gamari at 2022-01-29T14:54:04-05:00 rel-notes: Note dropping of SPARC support - - - - - eb956cf1 by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite: Force-enable caret diagnostics in T17786 Otherwise GHC realizes that it's not attached to a proper tty and will disable caret diagnostics. - - - - - d07799ab by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite: Make T7275 more robust against CCid changes The cost-center numbers are somewhat unstable; normalise them out. - - - - - c76c8050 by Ben Gamari at 2022-01-30T06:27:19-05:00 rts: Don't allocate closurePtrs# pointers on C stack Previously `closurePtrs#` would allocate an aray of the size of the closure being decoded on the C stack. This was ripe for overflowing the C stack overflow. This resulted in `T12492` failing on Windows. - - - - - 3af95f7a by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite/T4029: Don't depend on echo On Windows the `cmd.exe` shell may be used to execute the command, which will print `ECHO is on.` instead of a newline if you give it no argument. Avoid this by rather using `printf`. - - - - - 3531c478 by Ben Gamari at 2022-01-30T06:27:19-05:00 Use PATH_FMT instead of %s to format `pathchar *` A few %s occurrences have snuck in over the past months. - - - - - ee5c4f9d by Zubin Duggal at 2022-01-31T16:51:55+05:30 Improve migration strategy for the XDG compliance change to the GHC application directory. We want to always use the old path (~/.ghc/..) if it exists. But we never want to create the old path. This ensures that the migration can eventually be completed once older GHC versions are no longer in circulation. Fixes #20684, #20669, #20660 - - - - - 60a54a8f by doyougnu at 2022-01-31T18:46:11-05:00 StgToCmm: decouple DynFlags, add StgToCmmConfig StgToCmm: add Config, remove CgInfoDownwards StgToCmm: runC api change to take StgToCmmConfig StgToCmm: CgInfoDownad -> StgToCmmConfig StgToCmm.Monad: update getters/setters/withers StgToCmm: remove CallOpts in StgToCmm.Closure StgToCmm: remove dynflag references StgToCmm: PtrOpts removed StgToCmm: add TMap to config, Prof - dynflags StgToCmm: add omit yields to config StgToCmm.ExtCode: remove redundant import StgToCmm.Heap: remove references to dynflags StgToCmm: codeGen api change, DynFlags -> Config StgToCmm: remove dynflags in Env and StgToCmm StgToCmm.DataCon: remove dynflags references StgToCmm: remove dynflag references in DataCon StgToCmm: add backend avx flags to config StgToCmm.Prim: remove dynflag references StgToCmm.Expr: remove dynflag references StgToCmm.Bind: remove references to dynflags StgToCmm: move DoAlignSanitisation to Cmm.Type StgToCmm: remove PtrOpts in Cmm.Parser.y DynFlags: update ipInitCode api StgToCmm: Config Module is single source of truth StgToCmm: Lazy config breaks IORef deadlock testsuite: bump countdeps threshold StgToCmm.Config: strictify fields except UpdFrame Strictifying UpdFrameOffset causes the RTS build with stage1 to deadlock. Additionally, before the deadlock performance of the RTS is noticeably slower. StgToCmm.Config: add field descriptions StgToCmm: revert strictify on Module in config testsuite: update CountDeps tests StgToCmm: update comment, fix exports Specifically update comment about loopification passed into dynflags then stored into stgToCmmConfig. And remove getDynFlags from Monad.hs exports Types.Name: add pprFullName function StgToCmm.Ticky: use pprFullname, fixup ExtCode imports Cmm.Info: revert cmmGetClosureType removal StgToCmm.Bind: use pprFullName, Config update comments StgToCmm: update closureDescription api StgToCmm: SAT altHeapCheck StgToCmm: default render for Info table, ticky Use default rendering contexts for info table and ticky ticky, which should be independent of command line input. testsuite: bump count deps pprFullName: flag for ticky vs normal style output convertInfoProvMap: remove unused parameter StgToCmm.Config: add backend flags to config StgToCmm.Config: remove Backend from Config StgToCmm.Prim: refactor Backend call sites StgToCmm.Prim: remove redundant imports StgToCmm.Config: refactor vec compatibility check StgToCmm.Config: add allowQuotRem2 flag StgToCmm.Ticky: print internal names with parens StgToCmm.Bind: dispatch ppr based on externality StgToCmm: Add pprTickyname, Fix ticky naming Accidently removed the ctx for ticky SDoc output. The only relevant flag is sdocPprDebug which was accidental set to False due to using defaultSDocContext without altering the flag. StgToCmm: remove stateful fields in config fixup: config: remove redundant imports StgToCmm: move Sequel type to its own module StgToCmm: proliferate getCallMethod updated api StgToCmm.Monad: add FCodeState to Monad Api StgToCmm: add second reader monad to FCode fixup: Prim.hs: missed a merge conflict fixup: Match countDeps tests to HEAD StgToCmm.Monad: withState -> withCgState To disambiguate it from mtl withState. This withState shouldn't be returning the new state as a value. However, fixing this means tackling the knot tying in CgState and so is very difficult since it changes when the thunk of the knot is forced which either leads to deadlock or to compiler panic. - - - - - 58eccdbc by Ben Gamari at 2022-01-31T18:46:47-05:00 codeGen: Fix two buglets in -fbounds-check logic @Bodigrim noticed that the `compareByteArray#` bounds-checking logic had flipped arguments and an off-by-one. For the sake of clarity I also refactored occurrences of `cmmOffset` to rather use `cmmOffsetB`. I suspect the former should be retired. - - - - - 584f03fa by Simon Peyton Jones at 2022-01-31T18:47:23-05:00 Make typechecker trace less strict Fixes #21011 - - - - - 60ac7300 by Elton at 2022-02-01T12:28:49-05:00 Use braces in TH case pprint (fixes #20893) This patch ensures that the pretty printer formats `case` statements using braces (instead of layout) to remain consistent with the formatting of other statements (like `do`) - - - - - fdda93b0 by Elton at 2022-02-01T12:28:49-05:00 Use braces in TH LambdaCase and where clauses This patch ensures that the pretty printer formats LambdaCase and where clauses using braces (instead of layout) to remain consistent with the formatting of other statements (like `do` and `case`) - - - - - 06185102 by Ben Gamari at 2022-02-01T12:29:26-05:00 Consistently upper-case "Note [" This was achieved with git ls-tree --name-only HEAD -r | xargs sed -i -e 's/note \[/Note \[/g' - - - - - 88fba8a4 by Ben Gamari at 2022-02-01T12:29:26-05:00 Fix a few Note inconsistencies - - - - - 05548a22 by Douglas Wilson at 2022-02-02T19:26:06-05:00 rts: Address failures to inline - - - - - 074945de by Simon Peyton Jones at 2022-02-02T19:26:41-05:00 Two small improvements in the Simplifier As #20941 describes, this patch implements a couple of small fixes to the Simplifier. They make a difference principally with -O0, so few people will notice. But with -O0 they can reduce the number of Simplifer iterations. * In occurrence analysis we avoid making x = (a,b) into a loop breaker because we want to be able to inline x, or (more likely) do case-elimination. But HEAD does not treat x = let y = blah in (a,b) in the same way. We should though, because we are going to float that y=blah out of the x-binding. A one-line fix in OccurAnal. * The crucial function exprIsConApp_maybe uses getUnfoldingInRuleMatch (rightly) but the latter was deeply strange. In HEAD, if rule-rewriting was off (-O0) we only looked inside stable unfoldings. Very stupid. The patch simplifies. * I also noticed that in simplStableUnfolding we were failing to delete the DFun binders from the usage. So I added that. Practically zero perf change across the board, except that we get more compiler allocation in T3064 (which is compiled with -O0). There's a good reason: we get better code. But there are lots of other small compiler allocation decreases: Metrics: compile_time/bytes allocated --------------------- Baseline Test Metric value New value Change ----------------------------------------------------------------- PmSeriesG(normal) ghc/alloc 44,260,817 44,184,920 -0.2% PmSeriesS(normal) ghc/alloc 52,967,392 52,891,632 -0.1% PmSeriesT(normal) ghc/alloc 75,498,220 75,421,968 -0.1% PmSeriesV(normal) ghc/alloc 52,341,849 52,265,768 -0.1% T10421(normal) ghc/alloc 109,702,291 109,626,024 -0.1% T10421a(normal) ghc/alloc 76,888,308 76,809,896 -0.1% T10858(normal) ghc/alloc 125,149,038 125,073,648 -0.1% T11276(normal) ghc/alloc 94,159,364 94,081,640 -0.1% T11303b(normal) ghc/alloc 40,230,059 40,154,368 -0.2% T11822(normal) ghc/alloc 107,424,540 107,346,088 -0.1% T12150(optasm) ghc/alloc 76,486,339 76,426,152 -0.1% T12234(optasm) ghc/alloc 55,585,046 55,507,352 -0.1% T12425(optasm) ghc/alloc 88,343,288 88,265,312 -0.1% T13035(normal) ghc/alloc 98,919,768 98,845,600 -0.1% T13253-spj(normal) ghc/alloc 121,002,153 120,851,040 -0.1% T16190(normal) ghc/alloc 290,313,131 290,074,152 -0.1% T16875(normal) ghc/alloc 34,756,121 34,681,440 -0.2% T17836b(normal) ghc/alloc 45,198,100 45,120,288 -0.2% T17977(normal) ghc/alloc 39,479,952 39,404,112 -0.2% T17977b(normal) ghc/alloc 37,213,035 37,137,728 -0.2% T18140(normal) ghc/alloc 79,430,588 79,350,680 -0.1% T18282(normal) ghc/alloc 128,303,182 128,225,384 -0.1% T18304(normal) ghc/alloc 84,904,713 84,831,952 -0.1% T18923(normal) ghc/alloc 66,817,241 66,731,984 -0.1% T20049(normal) ghc/alloc 86,188,024 86,107,920 -0.1% T5837(normal) ghc/alloc 35,540,598 35,464,568 -0.2% T6048(optasm) ghc/alloc 99,812,171 99,736,032 -0.1% T9198(normal) ghc/alloc 46,380,270 46,304,984 -0.2% geo. mean -0.0% Metric Increase: T3064 - - - - - d2cce453 by Morrow at 2022-02-02T19:27:21-05:00 Fix @since annotation on Nat - - - - - 6438fed9 by Simon Peyton Jones at 2022-02-02T19:27:56-05:00 Refactor the escaping kind check for data constructors As #20929 pointed out, we were in-elegantly checking for escaping kinds in `checkValidType`, even though that check was guaranteed to succeed for type signatures -- it's part of kind-checking a type. But for /data constructors/ we kind-check the pieces separately, so we still need the check. This MR is a pure refactor, moving the test from `checkValidType` to `checkValidDataCon`. No new tests; external behaviour doesn't change. - - - - - fb05e5ac by Andreas Klebinger at 2022-02-02T19:28:31-05:00 Replace sndOfTriple with sndOf3 I also cleaned up the imports slightly while I was at it. - - - - - fbc77d3a by Matthew Pickering at 2022-02-02T19:29:07-05:00 testsuite: Honour PERF_BASELINE_COMMIT when computing allowed metric changes We now get all the commits between the PERF_BASELINE_COMMIT and HEAD and check any of them for metric changes. Fixes #20882 - - - - - 0a82ae0d by Simon Peyton Jones at 2022-02-02T23:49:58-05:00 More accurate unboxing This patch implements a fix for #20817. It ensures that * The final strictness signature for a function accurately reflects the unboxing done by the wrapper See Note [Finalising boxity for demand signatures] and Note [Finalising boxity for let-bound Ids] * A much better "layer-at-a-time" implementation of the budget for how many worker arguments we can have See Note [Worker argument budget] Generally this leads to a bit more worker/wrapper generation, because instead of aborting entirely if the budget is exceeded (and then lying about boxity), we unbox a bit. Binary sizes in increase slightly (around 1.8%) because of the increase in worker/wrapper generation. The big effects are to GHC.Ix, GHC.Show, GHC.IO.Handle.Internals. If we did a better job of dropping dead code, this effect might go away. Some nofib perf improvements: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VSD +1.8% -0.5% 0.017 0.017 0.0% awards +1.8% -0.1% +2.3% +2.3% 0.0% banner +1.7% -0.2% +0.3% +0.3% 0.0% bspt +1.8% -0.1% +3.1% +3.1% 0.0% eliza +1.8% -0.1% +1.2% +1.2% 0.0% expert +1.7% -0.1% +9.6% +9.6% 0.0% fannkuch-redux +1.8% -0.4% -9.3% -9.3% 0.0% kahan +1.8% -0.1% +22.7% +22.7% 0.0% maillist +1.8% -0.9% +21.2% +21.6% 0.0% nucleic2 +1.7% -5.1% +7.5% +7.6% 0.0% pretty +1.8% -0.2% 0.000 0.000 0.0% reverse-complem +1.8% -2.5% +12.2% +12.2% 0.0% rfib +1.8% -0.2% +2.5% +2.5% 0.0% scc +1.8% -0.4% 0.000 0.000 0.0% simple +1.7% -1.3% +17.0% +17.0% +7.4% spectral-norm +1.8% -0.1% +6.8% +6.7% 0.0% sphere +1.7% -2.0% +13.3% +13.3% 0.0% tak +1.8% -0.2% +3.3% +3.3% 0.0% x2n1 +1.8% -0.4% +8.1% +8.1% 0.0% -------------------------------------------------------------------------------- Min +1.1% -5.1% -23.6% -23.6% 0.0% Max +1.8% +0.0% +36.2% +36.2% +7.4% Geometric Mean +1.7% -0.1% +6.8% +6.8% +0.1% Compiler allocations in CI have a geometric mean of +0.1%; many small decreases but there are three bigger increases (7%), all because we do more worker/wrapper than before, so there is simply more code to compile. That's OK. Perf benchmarks in perf/should_run improve in allocation by a geo mean of -0.2%, which is good. None get worse. T12996 improves by -5.8% Metric Decrease: T12996 Metric Increase: T18282 T18923 T9630 - - - - - d1ef6288 by Peter Trommler at 2022-02-02T23:50:34-05:00 Cmm: fix equality of expressions Compare expressions and types when comparing `CmmLoad`s. Fixes #21016 - - - - - e59446c6 by Peter Trommler at 2022-02-02T23:50:34-05:00 Check type first then expression - - - - - b0e1ef4a by Matthew Pickering at 2022-02-03T14:44:17-05:00 Add failing test for #20791 The test produces different output on static vs dynamic GHC builds. - - - - - cae1fb17 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Frontend01 passes with static GHC - - - - - e343526b by Matthew Pickering at 2022-02-03T14:44:17-05:00 Don't initialise plugins when there are no pipelines to run - - - - - abac45fc by Matthew Pickering at 2022-02-03T14:44:17-05:00 Mark prog003 as expected_broken on static way #20704 - - - - - 13300dfd by Matthew Pickering at 2022-02-03T14:44:17-05:00 Filter out -rtsopts in T16219 to make static/dynamic ways agree - - - - - d89439f2 by Matthew Pickering at 2022-02-03T14:44:17-05:00 T13168: Filter out rtsopts for consistency between dynamic and static ways - - - - - 00180cdf by Matthew Pickering at 2022-02-03T14:44:17-05:00 Accept new output for T14335 test This test was previously not run due to #20960 - - - - - 1accdcff by Matthew Pickering at 2022-02-03T14:44:17-05:00 Add flushes to plugin tests which print to stdout Due to #20791 you need to explicitly flush as otherwise the output from these tests doesn't make it to stdout. - - - - - d820f2e8 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Remove ghc_plugin_way Using ghc_plugin_way had the unintended effect of meaning certain tests weren't run at all when ghc_dynamic=true, if you delete this modifier then the tests work in both the static and dynamic cases. - - - - - aa5ef340 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Unbreak T13168 on windows Fixes #14276 - - - - - 84ab0153 by Matthew Pickering at 2022-02-03T14:44:53-05:00 Rewrite CallerCC parser using ReadP This allows us to remove the dependency on parsec and hence transitively on text. Also added some simple unit tests for the parser and fixed two small issues in the documentation. Fixes #21033 - - - - - 4e6780bb by Matthew Pickering at 2022-02-03T14:45:28-05:00 ci: Add debian 11 jobs (validate/release/nightly) Fixes #21002 - - - - - eddaa591 by Ben Gamari at 2022-02-04T10:01:59-05:00 compiler: Introduce and use RoughMap for instance environments Here we introduce a new data structure, RoughMap, inspired by the previous `RoughTc` matching mechanism for checking instance matches. This allows [Fam]InstEnv to be implemented as a trie indexed by these RoughTc signatures, reducing the complexity of instance lookup and FamInstEnv merging (done during the family instance conflict test) from O(n) to O(log n). The critical performance improvement currently realised by this patch is in instance matching. In particular the RoughMap mechanism allows us to discount many potential instances which will never match for constraints involving type variables (see Note [Matching a RoughMap]). In realistic code bases matchInstEnv was accounting for 50% of typechecker time due to redundant work checking instances when simplifying instance contexts when deriving instances. With this patch the cost is significantly reduced. The larger constants in InstEnv creation do mean that a few small tests regress in allocations slightly. However, the runtime of T19703 is reduced by a factor of 4. Moreover, the compilation time of the Cabal library is slightly improved. A couple of test cases are included which demonstrate significant improvements in compile time with this patch. This unfortunately does not fix the testcase provided in #19703 but does fix #20933 ------------------------- Metric Decrease: T12425 Metric Increase: T13719 T9872a T9872d hard_hole_fits ------------------------- Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 62d670eb by Matthew Pickering at 2022-02-04T10:02:35-05:00 testsuite: Run testsuite dependency calculation before GHC is built The main motivation for this patch is to allow tests to be added to the testsuite which test things about the source tree without needing to build GHC. In particular the notes linter can easily start failing and by integrating it into the testsuite the process of observing these changes is caught by normal validation procedures rather than having to run the linter specially. With this patch I can run ``` ./hadrian/build test --flavour=devel2 --only="uniques" ``` In a clean tree to run the checkUniques linter without having to build GHC. Fixes #21029 - - - - - 4bd52410 by Hécate Moonlight at 2022-02-04T16:14:10-05:00 Add the Ix class to Foreign C integral types Related CLC proposal is here: https://github.com/haskell/core-libraries-committee/issues/30 - - - - - de6d7692 by Ben Gamari at 2022-02-04T16:14:47-05:00 Drop dead code - - - - - b79206f1 by Ben Gamari at 2022-02-04T16:14:47-05:00 Add comments - - - - - 58d7faac by Ben Gamari at 2022-02-04T16:14:47-05:00 cmm: Introduce cmmLoadBWord and cmmLoadGCWord - - - - - 7217156c by Ben Gamari at 2022-02-04T16:14:47-05:00 Introduce alignment in CmmLoad - - - - - 99ea5f2c by Ben Gamari at 2022-02-04T16:14:47-05:00 Introduce alignment to CmmStore - - - - - 606b59a5 by Ben Gamari at 2022-02-04T16:14:47-05:00 Fix array primop alignment - - - - - 1cf9616a by Ben Gamari at 2022-02-04T16:14:47-05:00 llvmGen: Handle unaligned loads/stores This allows us to produce valid code for indexWord8ArrayAs*# on platforms that lack unaligned memory access. - - - - - 8c18feba by Ben Gamari at 2022-02-04T16:14:47-05:00 primops: Fix documentation of setByteArray# Previously the documentation was subtly incorrect regarding the bounds of the operation. Fix this and add a test asserting that a zero-length operation is in fact a no-op. - - - - - 88480e55 by nineonine at 2022-02-04T20:35:45-05:00 Fix unsound behavior of unlifted datatypes in ghci (#20194) Previously, directly calling a function that pattern matches on an unlifted data type which has at least two constructors in GHCi resulted in a segfault. This happened due to unaccounted return frame info table pointer. The fix is to pop the above mentioned frame info table pointer when unlifted things are returned. See Note [Popping return frame for unlifted things] authors: bgamari, nineonine - - - - - a5c7068c by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Add Outputable instance for Messages c.f. #20980 - - - - - bf495f72 by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Add a missing restoreLclEnv The commit commit 18df4013f6eaee0e1de8ebd533f7e96c4ee0ff04 Date: Sat Jan 22 01:12:30 2022 +0000 Define and use restoreLclEnv omitted to change one setLclEnv to restoreLclEnv, namely the one in GHC.Tc.Errors.warnRedundantConstraints. This new commit fixes the omission. - - - - - 6af8e71e by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Improve errors for non-existent labels This patch fixes #17469, by improving matters when you use non-existent field names in a record construction: data T = MkT { x :: Int } f v = MkT { y = 3 } The check is now made in the renamer, in GHC.Rename.Env.lookupRecFieldOcc. That in turn led to a spurious error in T9975a, which is fixed by making GHC.Rename.Names.extendGlobalRdrEnvRn fail fast if it finds duplicate bindings. See Note [Fail fast on duplicate definitions] in that module for more details. This patch was originated and worked on by Alex D (@nineonine) - - - - - 299acff0 by nineonine at 2022-02-05T19:21:49-05:00 Exit with failure when -e fails (fixes #18411 #9916 #17560) - - - - - 549292eb by Matthew Pickering at 2022-02-05T19:22:25-05:00 Make implication tidying agree with Note [Tidying multiple names at once] Note [Tidying multiple names at once] indicates that if multiple variables have the same name then we shouldn't prioritise one of them and instead rename them all to a1, a2, a3... etc This patch implements that change, some error message changes as expected. Closes #20932 - - - - - 2e9248b7 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts/m32: Accept any address within 4GB of program text Previously m32 would assume that the program image was located near the start of the address space and therefore assume that it wanted pages in the bottom 4GB of address space. Instead we now check whether they are within 4GB of whereever the program is loaded. This is necessary on Windows, which now tends to place the image in high memory. The eventual goal is to use m32 to allocate memory for linker sections on Windows. - - - - - 86589b89 by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts: Generalize mmapForLinkerMarkExecutable Renamed to mprotectForLinker and allowed setting of arbitrary protection modes. - - - - - 88ef270a by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts/m32: Add consistency-checking infrastructure This adds logic, enabled in the `-debug` RTS for checking the internal consistency of the m32 allocator. This area has always made me a bit nervous so this should help me sleep better at night in exchange for very little overhead. - - - - - 2d6f0b17 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts/m32: Free large objects back to the free page pool Not entirely convinced that this is worth doing. - - - - - e96f50be by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts/m32: Increase size of free page pool to 256 pages - - - - - fc083b48 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts: Dump memory map on memory mapping failures Fixes #20992. - - - - - 633296bc by Ben Gamari at 2022-02-06T01:43:56-05:00 Fix macro redefinition warnings for PRINTF * Move `PRINTF` macro from `Stats.h` to `Stats.c` as it's only needed in the latter. * Undefine `PRINTF` at the end of `Messages.h` to avoid leaking it. - - - - - 37d435d2 by John Ericson at 2022-02-06T01:44:32-05:00 Purge DynFlags from GHC.Stg Also derive some more instances. GHC doesn't need them, but downstream consumers may need to e.g. put stuff in maps. - - - - - 886baa34 by Peter Trommler at 2022-02-06T10:58:18+01:00 RTS: Fix cabal specification In 35bea01b xxhash.c was removed. Remove the extra-source-files stanza referring to it. - - - - - 27581d77 by Alex D at 2022-02-06T20:50:44-05:00 hadrian: remove redundant import - - - - - 4ff19981 by John Ericson at 2022-02-07T11:04:43-05:00 GHC.HsToCore.Coverage: No more HscEnv, less DynFlags Progress towards #20730 - - - - - b09389a6 by John Ericson at 2022-02-07T11:04:43-05:00 Create `CoverageConfig` As requested by @mpickering to collect the information we project from `HscEnv` - - - - - ff867c46 by Greg Steuck at 2022-02-07T11:05:24-05:00 Avoid using removed utils/checkUniques in validate Asked the question: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7460/diffs#4061f4d17546e239dd10d78c6b48668c2a288e02_1_0 - - - - - a9355e84 by sheaf at 2022-02-08T05:27:25-05:00 Allow HasField in quantified constraints We perform validity checking on user-written HasField instances, for example to disallow: data Foo a = Foo { fld :: Int } instance HasField "fld" (Foo a) Bool However, these checks were also being made on quantified constraints, e.g. data Bar where Bar :: (forall a. HasField s (Foo a) Int) => Proxy s -> Bar This patch simply skips validity checking for quantified constraints, in line with what we already do for equality constraints such as Coercible. Fixes #20989 - - - - - 6d77d3d8 by sheaf at 2022-02-08T05:28:05-05:00 Relax TyEq:N: allow out-of-scope newtype DataCon The 'bad_newtype' assertion in GHC.Tc.Solver.Canonical.canEqCanLHSFinish failed to account for the possibility that the newtype constructor might not be in scope, in which case we don't provide any guarantees about canonicalising away a newtype on the RHS of a representational equality. Fixes #21010 - - - - - a893d2f3 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Remove linter dependency on lint-submods - - - - - 457a5b9c by Ben Gamari at 2022-02-08T05:28:42-05:00 notes-util: initial commit - - - - - 1a943859 by Ben Gamari at 2022-02-08T05:28:42-05:00 gitlab-ci: Add lint-notes job - - - - - bc5cbce6 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Add notes linter to testsuite - - - - - 38c6e301 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Fix some notes - - - - - c3aac0f8 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Add suggestion mode to notes-util - - - - - 5dd29aea by Cale Gibbard at 2022-02-08T05:29:18-05:00 `hscSimpleIface` drop fingerprint param and ret `hscSimpleIface` does not depend on or modify the `Maybe Fingerprint` it is given, only passes it through, so get rid of the extraneous passing. Perhaps the intent was that there would be an iface fingerprint check of some sort? but this was never done. If/when we we want to do that, we can add it back then. - - - - - 4bcbd731 by Cale Gibbard at 2022-02-08T05:29:54-05:00 Document `hscIncrementalFrontend` and flip bool - - - - - b713db1e by John Ericson at 2022-02-08T05:30:29-05:00 StgToCmm: Get rid of GHC.Driver.Session imports `DynFlags` is gone, but let's move a few trivial things around to get rid of its module too. - - - - - f115c382 by Gleb Popov at 2022-02-08T05:31:05-05:00 Fix build on recent FreeBSD. Recent FreeBSD versions gained the sched_getaffinity function, which made two mutually exclusive #ifdef blocks to be enabled. - - - - - 3320ab40 by Ben Gamari at 2022-02-08T10:42:04-05:00 rts/MemoryMap: Use mach_-prefixed type names There appears to be some inconsistency in system-call type naming across Darwin toolchains. Specifically: * the `address` argument to `mach_vm_region` apparently wants to be a `mach_vm_address_t *`, not a `vm_address_t *` * the `vmsize` argument to `mach_vm_region` wants to be a `mach_vm_size_t`, not a `vm_size_t` - - - - - b33f0cfa by Richard Eisenberg at 2022-02-08T10:42:41-05:00 Document that reifyRoles includes kind parameters Close #21056 - - - - - bd493ed6 by PHO at 2022-02-08T10:43:19-05:00 Don't try to build stage1 with -eventlog if stage0 doesn't provide it Like -threaded, stage0 isn't guaranteed to have an event-logging RTS. - - - - - 03c2de0f by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Use absolute paths for config.libdir Fixes #21052 - - - - - ef294525 by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Clean up old/redundant predicates - - - - - a39ed908 by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Add missing dependency on ghcconfig - - - - - a172be07 by PHO at 2022-02-09T03:56:59-05:00 Implement System.Environment.getExecutablePath for NetBSD and also use it from GHC.BaseDir.getBaseDir - - - - - 62fa126d by PHO at 2022-02-09T03:57:37-05:00 Fix a portability issue in m4/find_llvm_prog.m4 `test A == B' is a Bash extension, which doesn't work on platforms where /bin/sh is not Bash. - - - - - fd9981e3 by Ryan Scott at 2022-02-09T03:58:13-05:00 Look through untyped TH splices in tcInferAppHead_maybe Previously, surrounding a head expression with a TH splice would defeat `tcInferAppHead_maybe`, preventing some expressions from typechecking that used to typecheck in previous GHC versions (see #21038 for examples). This is simple enough to fix: just look through `HsSpliceE`s in `tcInferAppHead_maybe`. I've added some additional prose to `Note [Application chains and heads]` in `GHC.Tc.Gen.App` to accompany this change. Fixes #21038. - - - - - 00975981 by sheaf at 2022-02-09T03:58:53-05:00 Add test for #21037 This program was rejected by GHC 9.2, but is accepted on newer versions of GHC. This patch adds a regression test. Closes #21037 - - - - - fad0b2b0 by Ben Gamari at 2022-02-09T08:29:46-05:00 Rename -merge-objs flag to --merge-objs For consistency with --make and friends. - - - - - 1dbe5b2a by Matthew Pickering at 2022-02-09T08:30:22-05:00 driver: Filter out our own boot module in hptSomeThingsBelow hptSomeThingsBelow would return a list of modules which contain the .hs-boot file for a particular module. This caused some problems because we would try and find the module in the HPT (but it's not there when we're compiling the module itself). Fixes #21058 - - - - - 2b1cced1 by Sylvain Henry at 2022-02-09T20:42:23-05:00 NCG: minor code factorization - - - - - e01ffec2 by Sylvain Henry at 2022-02-09T20:42:23-05:00 ByteCode: avoid out-of-bound read Cf https://gitlab.haskell.org/ghc/ghc/-/issues/18431#note_287139 - - - - - 53c26e79 by Ziyang Liu at 2022-02-09T20:43:02-05:00 Include ru_name in toHsRule message See #18147 - - - - - 3df06922 by Ben Gamari at 2022-02-09T20:43:39-05:00 rts: Rename MemoryMap.[ch] -> ReportMemoryMap.[ch] - - - - - e219ac82 by Ben Gamari at 2022-02-09T20:43:39-05:00 rts: Move mmapForLinker and friends to linker/MMap.c They are not particularly related to linking. - - - - - 30e205ca by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/linker: Drop dead IA64 code - - - - - 4d3a306d by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/linker/MMap: Use MemoryAccess in mmapForLinker - - - - - 1db4f1fe by Ben Gamari at 2022-02-09T20:43:39-05:00 linker: Don't use MAP_FIXED As noted in #21057, we really shouldn't be using MAP_FIXED. I would much rather have the process crash with a "failed to map" error than randomly overwrite existing mappings. Closes #21057. - - - - - 1eeae25c by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/mmap: Refactor mmapForLinker Here we try to separate the policy decisions of where to place mappings from the mechanism of creating the mappings. This makes things significantly easier to follow. - - - - - ac2d18a7 by sheaf at 2022-02-09T20:44:18-05:00 Add some perf tests for coercions This patch adds some performance tests for programs that create large coercions. This is useful because the existing test coverage is not very representative of real-world situations. In particular, this adds a test involving an extensible records library, a common pain-point for users. - - - - - 48f25715 by Andreas Klebinger at 2022-02-10T04:35:35-05:00 Add late cost centre support This allows cost centres to be inserted after the core optimization pipeline has run. - - - - - 0ff70427 by Andreas Klebinger at 2022-02-10T04:36:11-05:00 Docs:Mention that safe calls don't keep their arguments alive. - - - - - 1d3ed168 by Ben Gamari at 2022-02-10T04:36:46-05:00 PEi386: Drop Windows Vista fallback in addLibrarySearchPath We no longer support Windows Vista. - - - - - 2a6f2681 by Ben Gamari at 2022-02-10T04:36:46-05:00 linker/PEi386: Make addLibrarySearchPath long-path aware Previously `addLibrarySearchPath` failed to normalise the added path to UNC form before passing it to `AddDllDirectory`. Consequently, the call was subject to the MAX_PATH restriction, leading to the failure of `test-defaulting-plugin-fail`, among others. Happily, this also nicely simplifies the implementation. Closes #21059. - - - - - 2a47ee9c by Daniel Gröber at 2022-02-10T19:18:58-05:00 ghc-boot: Simplify writePackageDb permissions handling Commit ef8a3fbf1 ("ghc-boot: Fix metadata handling of writeFileAtomic") introduced a somewhat over-engineered fix for #14017 by trying to preserve the current permissions if the target file already exists. The problem in the issue is simply that the package db cache file should be world readable but isn't if umask is too restrictive. In fact the previous fix only handles part of this problem. If the file isn't already there in a readable configuration it wont make it so which isn't really ideal either. Rather than all that we now simply always force all the read access bits to allow access while leaving the owner at the system default as it's just not our business to mess with it. - - - - - a1d97968 by Ben Gamari at 2022-02-10T19:19:34-05:00 Bump Cabal submodule Adapts GHC to the factoring-out of `Cabal-syntax`. Fixes #20991. Metric Decrease: haddock.Cabal - - - - - 89cf8caa by Morrow at 2022-02-10T19:20:13-05:00 Add metadata to integer-gmp.cabal - - - - - c995b7e7 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix event type of EVENT_IPE This leads to corrupted eventlogs because the size of EVENT_IPE is completely wrong. Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de - - - - - 59ba8fb3 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix event type of MEM_RETURN This leads to corrupted eventlogs because the size of EVENT_MEM_RETURN is completely wrong. Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de - - - - - 19413d09 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Delete misleading comment in gen_event_types.py Not all events start with CapNo and there's not logic I could see which adds this to the length. - - - - - e06f49c0 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix size of TICKY_COUNTER_BEGIN_SAMPLE - - - - - 2f99255b by Matthew Pickering at 2022-02-10T19:21:24-05:00 Fix copy-pasto in prof-late-ccs docs - - - - - 19deb002 by Matthew Pickering at 2022-02-10T19:21:59-05:00 Refine tcSemigroupWarnings to work in ghc-prim ghc-prim doesn't depend on base so can't have any Monoid or Semigroup instances. However, attempting to load these definitions ran into issues when the interface for `GHC.Base` did exist as that would try and load the interface for `GHC.Types` (which is the module we are trying to compile and has no interface). The fix is to just not do this check when we are compiling a module in ghc-prim. Fixes #21069 - - - - - 34dec6b7 by sheaf at 2022-02-11T17:55:34-05:00 Decrease the size of the LargeRecord test This test was taking too long to run, so this patch makes it smaller. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 9cab90d9 by Matthew Pickering at 2022-02-11T22:27:19-05:00 Make sure all platforms have a release job The release bindists are currently a mixture of validate and release builds. This is bad because the validate builds don't have profiling libraries. The fix is to make sure there is a release job for each platform we want to produce a release for.t Fixes #21066 - - - - - 4bce3575 by Matthew Pickering at 2022-02-11T22:27:54-05:00 testsuite: Make sure all tests trigger ghc rebuild I made a mistake when implementing #21029 which meant that certain tests didn't trigger a GHC recompilation. By adding the `test:ghc` target to the default settings all tests will now depend on this target unless explicitly opting out via the no_deps modifier. - - - - - 90a26f8b by Sylvain Henry at 2022-02-11T22:28:34-05:00 Fix documentation about Word64Rep/Int64Rep (#16964) - - - - - 0e93023e by Andreas Klebinger at 2022-02-12T13:59:41+00:00 Tag inference work. This does three major things: * Enforce the invariant that all strict fields must contain tagged pointers. * Try to predict the tag on bindings in order to omit tag checks. * Allows functions to pass arguments unlifted (call-by-value). The former is "simply" achieved by wrapping any constructor allocations with a case which will evaluate the respective strict bindings. The prediction is done by a new data flow analysis based on the STG representation of a program. This also helps us to avoid generating redudant cases for the above invariant. StrictWorkers are created by W/W directly and SpecConstr indirectly. See the Note [Strict Worker Ids] Other minor changes: * Add StgUtil module containing a few functions needed by, but not specific to the tag analysis. ------------------------- Metric Decrease: T12545 T18698b T18140 T18923 LargeRecord Metric Increase: LargeRecord ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T15164 T18282 T18304 T18698a T1969 T20049 T3294 T4801 T5321FD T5321Fun T783 T9233 T9675 T9961 T19695 WWRec ------------------------- - - - - - 744f8a11 by Greg Steuck at 2022-02-12T17:13:55-05:00 Only check the exit code in derefnull & divbyzero tests on OpenBSD - - - - - eeead9fc by Ben Gamari at 2022-02-13T03:26:14-05:00 rts/Adjustor: Ensure that allocateExecPage succeeded Previously we failed to handle the case that `allocateExecPage` failed. - - - - - afdfaff0 by Ben Gamari at 2022-02-13T03:26:14-05:00 rts: Drop DEC Alpha adjustor implementation The last Alpha chip was produced in 2004. - - - - - 191dfd2d by Ben Gamari at 2022-02-13T03:26:14-05:00 rts/adjustor: Split Windows path out of NativeAmd64 - - - - - be591e27 by Ben Gamari at 2022-02-13T03:26:14-05:00 rts: Initial commit of AdjustorPool - - - - - d6d48b16 by Ben Gamari at 2022-02-13T03:26:14-05:00 Introduce initAdjustors - - - - - eab37902 by Ben Gamari at 2022-02-13T03:26:14-05:00 adjustors/NativeAmd64: Use AdjustorPool - - - - - 974e73af by Ben Gamari at 2022-02-13T03:26:14-05:00 adjustors/NativeAmd64Mingw: Use AdjustorPool - - - - - 95fab83f by Ben Gamari at 2022-02-13T03:26:14-05:00 configure: Fix result reporting of adjustors method check - - - - - ef5cf55d by nikshalark at 2022-02-13T03:26:16-05:00 (#21044) Documented arithmetic functions in base. Didn't get it right the ninth time. Now everything's formatted correctly. - - - - - acb482cc by Takenobu Tani at 2022-02-16T05:27:17-05:00 Relax load_load_barrier for aarch64 This patch relaxes the instruction for load_load_barrier(). Current load_load_barrier() implements full-barrier with `dmb sy`. It's too strong to order load-load instructions. We can relax it by using `dmb ld`. If current load_load_barrier() is used for full-barriers (load/store - load/store barrier), this patch is not suitable. See also linux-kernel's smp_rmb() implementation: https://github.com/torvalds/linux/blob/v5.14/arch/arm64/include/asm/barrier.h#L90 Hopefully, it's better to use `dmb ishld` rather than `dmb ld` to improve performance. However, I can't validate effects on a real many-core Arm machine. - - - - - 84eaa26f by Oleg Grenrus at 2022-02-16T05:27:56-05:00 Add test for #20562 - - - - - 2c28620d by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00 rts: remove struct StgRetry, it is never used - - - - - 74bf9bb5 by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00 rts: document some closure types - - - - - 316312ec by nineonine at 2022-02-16T05:29:08-05:00 ghci: fix -ddump-stg-cg (#21052) The pre-codegen Stg AST dump was not available in ghci because it was performed in 'doCodeGen'. This was now moved to 'coreToStg' area. - - - - - a6411d74 by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00 docs: mention -fprof-late-ccs in the release notes And note which compiler version it was added in. - - - - - 4127e86d by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00 docs: fix release notes formatting - - - - - 4e6c8019 by Matthew Pickering at 2022-02-17T05:25:28-05:00 Always define __GLASGOW_HASKELL_PATCHLEVEL1/2__ macros As #21076 reports if you are using `-Wcpp-undef` then you get warnings when using the `MIN_VERSION_GLASGOW_HASKELL` macro because __GLASGOW_HASKELL_PATCHLEVEL2__ is very rarely explicitliy set (as version numbers are not 4 components long). This macro was introduced in 3549c952b535803270872adaf87262f2df0295a4 and it seems the bug has existed ever since. Fixes #21076 - - - - - 67dd5724 by Ben Gamari at 2022-02-17T05:26:03-05:00 rts/AdjustorPool: Silence unused function warning bitmap_get is only used in the DEBUG RTS configuration. Fixes #21079. - - - - - 4b04f7e1 by Zubin Duggal at 2022-02-20T13:56:15-05:00 Track object file dependencies for TH accurately (#20604) `hscCompileCoreExprHook` is changed to return a list of `Module`s required by a splice. These modules are accumulated in the TcGblEnv (tcg_th_needed_mods). Dependencies on the object files of these modules are recording in the interface. The data structures in `LoaderState` are replaced with more efficient versions to keep track of all the information required. The MultiLayerModulesTH_Make allocations increase slightly but runtime is faster. Fixes #20604 ------------------------- Metric Increase: MultiLayerModulesTH_Make ------------------------- - - - - - 92ab3ff2 by sheaf at 2022-02-20T13:56:55-05:00 Use diagnostics for "missing signature" errors This patch makes the "missing signature" errors from "GHC.Rename.Names" use the diagnostic infrastructure. This encompasses missing type signatures for top-level bindings and pattern synonyms, as well as missing kind signatures for type constructors. This patch also renames TcReportMsg to TcSolverReportMsg, and adds a few convenience functions to compute whether such a TcSolverReportMsg is an expected/actual message. - - - - - 845284a5 by sheaf at 2022-02-20T13:57:34-05:00 Generically: remove redundant Semigroup constraint This patch removes a redundant Semigroup constraint on the Monoid instance for Generically. This constraint can cause trouble when one wants to derive a Monoid instance via Generically through a type that doesn't itself have a Semigroup instance, for example: data Point2D a = Point2D !a !a newtype Vector2D a = Vector2D { tip :: Point2D a } deriving ( Semigroup, Monoid ) via Generically ( Point2D ( Sum a ) ) In this case, we should not require there to be an instance Semigroup ( Point2D ( Sum a ) ) as all we need is an instance for the generic representation of Point2D ( Sum a ), i.e. Semigroup ( Rep ( Point2D ( Sum a) ) () ). - - - - - 6b468f7f by Ben Gamari at 2022-02-20T13:58:10-05:00 Bump time submodule to 1.12.1 - - - - - 2f0ceecc by Zubin Duggal at 2022-02-20T19:06:19+00:00 hadrian: detect if 'main' is not a haskell file and add it to appropriate list of sources - - - - - 7ce1b694 by Zubin Duggal at 2022-02-21T11:18:58+00:00 Reinstallable GHC This patch allows ghc and its dependencies to be built using a normal invocation of cabal-install. Each componenent which relied on generated files or additional configuration now has a Setup.hs file. There are also various fixes to the cabal files to satisfy cabal-install. There is a new hadrian command which will build a stage2 compiler and then a stage3 compiler by using cabal. ``` ./hadrian/build build-cabal ``` There is also a new CI job which tests running this command. For the 9.4 release we will upload all the dependent executables to hackage and then end users will be free to build GHC and GHC executables via cabal. There are still some unresolved questions about how to ensure soundness when loading plugins into a reinstalled GHC (#20742) which will be tighted up in due course. Fixes #19896 - - - - - 78fbc3a3 by Matthew Pickering at 2022-02-21T15:14:28-05:00 hadrian: Enable late-ccs when building profiled_ghc - - - - - 2b890c89 by Matthew Pickering at 2022-02-22T15:59:33-05:00 testsuite: Don't print names of all fragile tests on all runs This information about fragile tests is pretty useless but annoying on CI where you have to scroll up a long way to see the actual issues. - - - - - 0b36801f by sheaf at 2022-02-22T16:00:14-05:00 Forbid standalone instances for built-in classes `check_special_inst_head` includes logic that disallows hand-written instances for built-in classes such as Typeable, KnownNat and KnownSymbol. However, it also allowed standalone deriving declarations. This was because we do want to allow standalone deriving instances with Typeable as they are harmless, but we certainly don't want to allow instances for e.g. KnownNat. This patch ensures that we don't allow derived instances for KnownNat, KnownSymbol (and also KnownChar, which was previously omitted entirely). Fixes #21087 - - - - - ace66dec by Krzysztof Gogolewski at 2022-02-22T16:30:59-05:00 Remove -Wunticked-promoted-constructors from -Wall Update manual; explain ticks as optional disambiguation rather than the preferred default. This is a part of #20531. - - - - - 558c7d55 by Hugo at 2022-02-22T16:31:01-05:00 docs: fix error in annotation guide code snippet - - - - - a599abba by Richard Eisenberg at 2022-02-23T08:16:07-05:00 Kill derived constraints Co-authored by: Sam Derbyshire Previously, GHC had three flavours of constraint: Wanted, Given, and Derived. This removes Derived constraints. Though serving a number of purposes, the most important role of Derived constraints was to enable better error messages. This job has been taken over by the new RewriterSets, as explained in Note [Wanteds rewrite wanteds] in GHC.Tc.Types.Constraint. Other knock-on effects: - Various new Notes as I learned about under-described bits of GHC - A reshuffling around the AST for implicit-parameter bindings, with better integration with TTG. - Various improvements around fundeps. These were caused by the fact that, previously, fundep constraints were all Derived, and Derived constraints would get dropped. Thus, an unsolved Derived didn't stop compilation. Without Derived, this is no longer possible, and so we have to be considerably more careful around fundeps. - A nice little refactoring in GHC.Tc.Errors to center the work on a new datatype called ErrorItem. Constraints are converted into ErrorItems at the start of processing, and this allows for a little preprocessing before the main classification. - This commit also cleans up the behavior in generalisation around functional dependencies. Now, if a variable is determined by functional dependencies, it will not be quantified. This change is user facing, but it should trim down GHC's strange behavior around fundeps. - Previously, reportWanteds did quite a bit of work, even on an empty WantedConstraints. This commit adds a fast path. - Now, GHC will unconditionally re-simplify constraints during quantification. See Note [Unconditionally resimplify constraints when quantifying], in GHC.Tc.Solver. Close #18398. Close #18406. Solve the fundep-related non-confluence in #18851. Close #19131. Close #19137. Close #20922. Close #20668. Close #19665. ------------------------- Metric Decrease: LargeRecord T9872b T9872b_defer T9872d TcPlugin_RewritePerf ------------------------- - - - - - 2ed22ba1 by Matthew Pickering at 2022-02-23T08:16:43-05:00 Introduce predicate for when to enable source notes (needSourceNotes) There were situations where we were using debugLevel == 0 as a proxy for whether to retain source notes but -finfo-table-map also enables and needs source notes so we should act consistently in both cases. Ticket #20847 - - - - - 37deb893 by Matthew Pickering at 2022-02-23T08:16:43-05:00 Use SrcSpan from the binder as initial source estimate There are some situations where we end up with no source notes in useful positions in an expression. In this case we currently fail to provide any source information about where an expression came from. This patch improves the initial estimate by using the position from the top-binder as the guess for the location of the whole inner expression. It provides quite a course estimate but it's better than nothing. Ticket #20847 - - - - - 59b7f764 by Cheng Shao at 2022-02-23T08:17:24-05:00 Don't emit foreign exports initialiser code for empty CAF list - - - - - c7f32f76 by John Ericson at 2022-02-23T13:58:36-05:00 Prepare rechecking logic for new type in a few ways Combine `MustCompile and `NeedsCompile` into a single case. `CompileReason` is put inside to destinguish the two. This makes a number of things easier. `Semigroup RecompileRequired` is no longer used, to make sure we skip doing work where possible. `recompThen` is very similar, but helps remember. `checkList` is rewritten with `recompThen`. - - - - - e60d8df8 by John Ericson at 2022-02-23T13:58:36-05:00 Introduce `MaybeValidated` type to remove invalid states The old return type `(RecompRequired, Maybe _)`, was confusing because it was inhabited by values like `(UpToDate, Nothing)` that made no sense. The new type ensures: - you must provide a value if it is up to date. - you must provide a reason if you don't provide a value. it is used as the return value of: - `checkOldIface` - `checkByteCode` - `checkObjects` - - - - - f07b13e3 by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: refactor X86 codegen Preliminary work done to make working on #5444 easier. Mostly make make control-flow easier to follow: * renamed genCCall into genForeignCall * split genForeignCall into the part dispatching on PrimTarget (genPrim) and the one really generating code for a C call (cf ForeignTarget and genCCall) * made genPrim/genSimplePrim only dispatch on MachOp: each MachOp now has its own code generation function. * out-of-line primops are not handled in a partial `outOfLineCmmOp` anymore but in the code generation functions directly. Helper functions have been introduced (e.g. genLibCCall) for code sharing. * the latter two bullets make code generated for primops that are only sometimes out-of-line (e.g. Pdep or Memcpy) and the logic to select between inline/out-of-line much more localized * avoided passing is32bit as an argument as we can easily get it from NatM state when we really need it * changed genCCall type to avoid it being partial (it can't handle PrimTarget) * globally removed 12 calls to `panic` thanks to better control flow and types ("parse, don't validate" ftw!). - - - - - 6fa7591e by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: refactor the way registers are handled * add getLocalRegReg to avoid allocating a CmmLocal just to call getRegisterReg * 64-bit registers: in the general case we must always use the virtual higher part of the register, so we might as well always return it with the lower part. The only exception is to implement 64-bit to 32-bit conversions. We now have to explicitly discard the higher part when matching on Reg64/RegCode64 datatypes instead of explicitly fetching the higher part from the lower part: much safer default. - - - - - bc8de322 by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: inline some 64-bit primops on x86/32-bit (#5444) Several 64-bit operation were implemented with FFI calls on 32-bit architectures but we can easily implement them with inline assembly code. Also remove unused hs_int64ToWord64 and hs_word64ToInt64 C functions. - - - - - 7b7c6b95 by Matthew Pickering at 2022-02-23T14:00:00-05:00 Simplify/correct implementation of getModuleInfo - - - - - 6215b04c by Matthew Pickering at 2022-02-23T14:00:00-05:00 Remove mg_boot field from ModuleGraph It was unused in the compiler so I have removed it to streamline ModuleGraph. - - - - - 818ff2ef by Matthew Pickering at 2022-02-23T14:00:01-05:00 driver: Remove needsTemplateHaskellOrQQ from ModuleGraph The idea of the needsTemplateHaskellOrQQ query is to check if any of the modules in a module graph need Template Haskell then enable -dynamic-too if necessary. This is quite imprecise though as it will enable -dynamic-too for all modules in the module graph even if only one module uses template haskell, with multiple home units, this is obviously even worse. With -fno-code we already have similar logic to enable code generation just for the modules which are dependeded on my TemplateHaskell modules so we use the same code path to decide whether to enable -dynamic-too rather than using this big hammer. This is part of the larger overall goal of moving as much statically known configuration into the downsweep as possible in order to have fully decided the build plan and all the options before starting to build anything. I also included a fix to #21095, a long standing bug with with the logic which is supposed to enable the external interpreter if we don't have the internal interpreter. Fixes #20696 #21095 - - - - - b6670af6 by Matthew Pickering at 2022-02-23T14:00:40-05:00 testsuite: Normalise output of ghci011 and T7627 The outputs of these tests vary on the order interface files are loaded so we normalise the output to correct for these inconsequential differences. Fixes #21121 - - - - - 9ed3bc6e by Peter Trommler at 2022-02-23T14:01:16-05:00 testsuite: Fix ipeMap test Pointers to closures must be untagged before use. Produce closures of different types so we get different info tables. Fixes #21112 - - - - - 7d426148 by Ziyang Liu at 2022-02-24T04:53:34-05:00 Allow `return` in more cases in ApplicativeDo The doc says that the last statement of an ado-block can be one of `return E`, `return $ E`, `pure E` and `pure $ E`. But `return` is not accepted in a few cases such as: ```haskell -- The ado-block only has one statement x :: F () x = do return () -- The ado-block only has let-statements besides the `return` y :: F () y = do let a = True return () ``` These currently require `Monad` instances. This MR fixes it. Normally `return` is accepted as the last statement because it is stripped in constructing an `ApplicativeStmt`, but this cannot be done in the above cases, so instead we replace `return` by `pure`. A similar but different issue (when the ado-block contains `BindStmt` or `BodyStmt`, the second last statement cannot be `LetStmt`, even if the last statement uses `pure`) is fixed in !6786. - - - - - a5ea7867 by John Ericson at 2022-02-24T20:23:49-05:00 Clarify laws of TestEquality It is unclear what `TestEquality` is for. There are 3 possible choices. Assuming ```haskell data Tag a where TagInt1 :: Tag Int TagInt2 :: Tag Int ``` Weakest -- type param equality semi-decidable --------------------------------------------- `Just Refl` merely means the type params are equal, the values being compared might not be. `Nothing` means the type params may or may not be not equal. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Nothing -- oopsie is allowed testEquality TagInt1 TagInt2 = Just Refl testEquality TagInt2 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl ``` This option is better demonstrated with a different type: ```haskell data Tag' a where TagInt1 :: Tag Int TagInt2 :: Tag a ``` ```haskell instance TestEquality Tag' where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt1 TagInt2 = Nothing -- can't be sure testEquality TagInt2 TagInt1 = Nothing -- can't be sure testEquality TagInt2 TagInt2 = Nothing -- can't be sure ``` Weaker -- type param equality decidable --------------------------------------- `Just Refl` merely means the type params are equal, the values being compared might not be. `Nothing` means the type params are not equal. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt1 TagInt2 = Just Refl testEquality TagInt2 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl ``` Strong -- Like `Eq` ------------------- `Just Refl` means the type params are equal, and the values are equal according to `Eq`. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl testEquality _ _ = Nothing ``` Strongest -- unique value concrete type --------------------------------------- `Just Refl` means the type params are equal, and the values are equal, and the class assume if the type params are equal the values must also be equal. In other words, the type is a singleton type when the type parameter is a closed term. ```haskell -- instance TestEquality -- invalid instance because two variants for `Int` ``` ------ The discussion in https://github.com/haskell/core-libraries-committee/issues/21 has decided on the "Weaker" option (confusingly formerly called the "Weakest" option). So that is what is implemented. - - - - - 06c18990 by Zubin Duggal at 2022-02-24T20:24:25-05:00 TH: fix pretty printing of GADTs with multiple constuctors (#20842) - - - - - 6555b68c by Matthew Pickering at 2022-02-24T20:25:06-05:00 Move linters into the tree This MR moves the GHC linters into the tree, so that they can be run directly using Hadrian. * Query all files tracked by Git instead of using changed files, so that we can run the exact same linting step locally and in a merge request. * Only check that the changelogs don't contain TBA when RELEASE=YES. * Add hadrian/lint script, which runs all the linting steps. * Ensure the hlint job exits with a failure if hlint is not installed (otherwise we were ignoring the failure). Given that hlint doesn't seem to be available in CI at the moment, I've temporarily allowed failure in the hlint job. * Run all linting tests in CI using hadrian. - - - - - b99646ed by Matthew Pickering at 2022-02-24T20:25:06-05:00 Add rule for generating HsBaseConfig.h If you are running the `lint:{base/compiler}` command locally then this improves the responsiveness because we don't re-run configure everytime if the header file already exists. - - - - - d0deaaf4 by Matthew Pickering at 2022-02-24T20:25:06-05:00 Suggestions due to hlint It turns out this job hasn't been running for quite a while (perhaps ever) so there are quite a few failures when running the linter locally. - - - - - 70bafefb by nineonine at 2022-02-24T20:25:42-05:00 ghci: show helpful error message when loading module with SIMD vector operations (#20214) Previously, when trying to load module with SIMD vector operations, ghci would panic in 'GHC.StgToByteCode.findPushSeq'. Now, a more helpful message is displayed. - - - - - 8ed3d5fd by Matthew Pickering at 2022-02-25T10:24:12+00:00 Remove test-bootstrap and cabal-reinstall jobs from fast-ci [skip ci] - - - - - 8387dfbe by Mario Blažević at 2022-02-25T21:09:41-05:00 template-haskell: Fix two prettyprinter issues Fix two issues regarding printing numeric literals. Fixing #20454. - - - - - 4ad8ce0b by sheaf at 2022-02-25T21:10:22-05:00 GHCi: don't normalise partially instantiated types This patch skips performing type normalisation when we haven't fully instantiated the type. That is, in tcRnExpr (used only for :type in GHCi), skip normalisation if the result type responds True to isSigmaTy. Fixes #20974 - - - - - f35aca4d by Ben Gamari at 2022-02-25T21:10:57-05:00 rts/adjustor: Always place adjustor templates in data section @nrnrnr points out that on his machine ld.lld rejects text relocations. Generalize the Darwin text-relocation avoidance logic to account for this. - - - - - cddb040a by Andreas Klebinger at 2022-02-25T21:11:33-05:00 Ticky: Gate tag-inference dummy ticky-counters behind a flag. Tag inference included a way to collect stats about avoided tag-checks. This was dony by emitting "dummy" ticky entries with counts corresponding to predicted/unpredicated tag checks. This behaviour for ticky is now gated behind -fticky-tag-checks. I also documented ticky-LNE in the process. - - - - - 948bf2d0 by Ben Gamari at 2022-02-25T21:12:09-05:00 Fix comment reference to T4818 - - - - - 9c3edeb8 by Ben Gamari at 2022-02-25T21:12:09-05:00 simplCore: Correctly extend in-scope set in rule matching Note [Matching lets] in GHC.Core.Rules claims the following: > We use GHC.Core.Subst.substBind to freshen the binding, using an > in-scope set that is the original in-scope variables plus the > rs_bndrs (currently floated let-bindings). However, previously the implementation didn't actually do extend the in-scope set with rs_bndrs. This appears to be a regression which was introduced by 4ff4d434e9a90623afce00b43e2a5a1ccbdb4c05. Moreover, the originally reasoning was subtly wrong: we must rather use the in-scope set from rv_lcl, extended with rs_bndrs, not that of `rv_fltR` Fixes #21122. - - - - - 7f9f49c3 by sheaf at 2022-02-25T21:12:47-05:00 Derive some stock instances for OverridingBool This patch adds some derived instances to `GHC.Data.Bool.OverridingBool`. It also changes the order of the constructors, so that the derived `Ord` instance matches the behaviour for `Maybe Bool`. Fixes #20326 - - - - - 140438a8 by nineonine at 2022-02-25T21:13:23-05:00 Add test for #19271 - - - - - ac9f4606 by sheaf at 2022-02-25T21:14:04-05:00 Allow qualified names in COMPLETE pragmas The parser didn't allow qualified constructor names to appear in COMPLETE pragmas. This patch fixes that. Fixes #20551 - - - - - 677c6c91 by Sylvain Henry at 2022-02-25T21:14:44-05:00 Testsuite: remove arch conditional in T8832 Taken from !3658 - - - - - ad04953b by Sylvain Henry at 2022-02-25T21:15:23-05:00 Allow hscGenHardCode to not return CgInfos This is a minor change in preparation for the JS backend: CgInfos aren't mandatory and the JS backend won't return them. - - - - - 929c280f by Sylvain Henry at 2022-02-25T21:15:24-05:00 Derive Enum instances for CCallConv and Safety This is used by the JS backend for serialization. - - - - - 75e4e090 by Sebastian Graf at 2022-02-25T21:15:59-05:00 base: Improve documentation of `throwIO` (#19854) Now it takes a better account of precise vs. imprecise exception semantics. Fixes #19854. - - - - - 61a203ba by Matthew Pickering at 2022-02-26T02:06:51-05:00 Make typechecking unfoldings from interfaces lazier The old logic was unecessarily strict in loading unfoldings because when reading the unfolding we would case on the result of attempting to load the template before commiting to which type of unfolding we were producing. Hence trying to inspect any of the information about an unfolding would force the template to be loaded. This also removes a potentially hard to discover bug where if the template failed to be typechecked for some reason then we would just not return an unfolding. Instead we now panic so these bad situations which should never arise can be identified. - - - - - 2be74460 by Matthew Pickering at 2022-02-26T02:06:51-05:00 Use a more up-to-date snapshot of the current rules in the simplifier As the prescient (now deleted) note warns in simplifyPgmIO we have to be a bit careful about when we gather rules from the EPS so that we get the rules for imported bindings. ``` -- Get any new rules, and extend the rule base -- See Note [Overall plumbing for rules] in GHC.Core.Rules -- We need to do this regularly, because simplification can -- poke on IdInfo thunks, which in turn brings in new rules -- behind the scenes. Otherwise there's a danger we'll simply -- miss the rules for Ids hidden inside imported inlinings ``` Given the previous commit, the loading of unfoldings is now even more delayed so we need to be more careful to read the EPS rule base closer to the point where we decide to try rules. Without this fix GHC performance regressed by a noticeably amount because the `zip` rule was not brought into scope eagerly enough which led to a further series of unfortunate events in the simplifer which tipped `substTyWithCoVars` over the edge of the size threshold, stopped it being inlined and increased allocations by 10% in some cases. Furthermore, this change is noticeably in the testsuite as it changes T19790 so that the `length` rules from GHC.List fires earlier. ------------------------- Metric Increase: T9961 ------------------------- - - - - - b8046195 by Matthew Pickering at 2022-02-26T02:06:52-05:00 Improve efficiency of extending a RuleEnv with a new RuleBase Essentially we apply the identity: > lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) > = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 The latter being more efficient as we don't construct an intermediate map. This is now quite important as each time we try and apply rules we need to combine the current EPS RuleBase with the HPT and ModGuts rule bases. - - - - - 033e9f0f by sheaf at 2022-02-26T02:07:30-05:00 Error on anon wildcards in tcAnonWildCardOcc The code in tcAnonWildCardOcc assumed that it could never encounter anonymous wildcards in illegal positions, because the renamer would have ruled them out. However, it's possible to sneak past the checks in the renamer by using Template Haskell. It isn't possible to simply pass on additional information when renaming Template Haskell brackets, because we don't know in advance in what context the bracket will be spliced in (see test case T15433b). So we accept that we might encounter these bogus wildcards in the typechecker and throw the appropriate error. This patch also migrates the error messages for illegal wildcards in types to use the diagnostic infrastructure. Fixes #15433 - - - - - 32d8fe3a by sheaf at 2022-02-26T14:15:33+01:00 Core Lint: ensure primops can be eta-expanded This patch adds a check to Core Lint, checkCanEtaExpand, which ensures that primops and other wired-in functions with no binding such as unsafeCoerce#, oneShot, rightSection... can always be eta-expanded, by checking that the remaining argument types have a fixed RuntimeRep. Two subtleties came up: - the notion of arity in Core looks through newtypes, so we may need to unwrap newtypes in this check, - we want to avoid calling hasNoBinding on something whose unfolding we are in the process of linting, as this would cause a loop; to avoid this we add some information to the Core Lint environment that holds this information. Fixes #20480 - - - - - 0a80b436 by Peter Trommler at 2022-02-26T17:21:59-05:00 testsuite: Require LLVM for T15155l - - - - - 38cb920e by Oleg Grenrus at 2022-02-28T07:14:04-05:00 Add Monoid a => Monoid (STM a) instance - - - - - d734ef8f by Hécate Moonlight at 2022-02-28T07:14:42-05:00 Make modules in base stable. fix #18963 - - - - - fbf005e9 by Sven Tennie at 2022-02-28T19:16:01-05:00 Fix some hlint issues in ghc-heap This does not fix all hlint issues as the criticised index and length expressions seem to be fine in context. - - - - - adfddf7d by Matthew Pickering at 2022-02-28T19:16:36-05:00 hadrian: Suggest to the user to run ./configure if missing a setting If a setting is missing from the configuration file it's likely the user needs to reconfigure. Fixes #20476 - - - - - 4f0208e5 by Andreas Klebinger at 2022-02-28T19:17:12-05:00 CLabel cleanup: Remove these smart constructors for these reasons: * mkLocalClosureTableLabel : Does the same as the non-local variant. * mkLocalClosureLabel : Does the same as the non-local variant. * mkLocalInfoTableLabel : Decide if we make a local label based on the name and just use mkInfoTableLabel everywhere. - - - - - 065419af by Matthew Pickering at 2022-02-28T19:17:47-05:00 linking: Don't pass --hash-size and --reduce-memory-overhead to ld These flags were added to help with the high linking cost of the old split-objs mode. Now we are using split-sections these flags appear to make no difference to memory usage or time taken to link. I tested various configurations linking together the ghc library with -split-sections enabled. | linker | time (s) | | ------ | ------ | | gold | 0.95 | | ld | 1.6 | | ld (hash-size = 31, reduce-memory-overheads) | 1.6 | | ldd | 0.47 | Fixes #20967 - - - - - 3e65ef05 by Teo Camarasu at 2022-02-28T19:18:27-05:00 template-haskell: fix typo in docstring for Overlap - - - - - 80f9133e by Teo Camarasu at 2022-02-28T19:18:27-05:00 template-haskell: fix docstring for Bytes It seems like a commented out section of code was accidentally included in the docstring for a field. - - - - - 54774268 by Matthew Pickering at 2022-03-01T16:23:10-05:00 Fix longstanding issue with moduleGraphNodes - no hs-boot files case In the case when we tell moduleGraphNodes to drop hs-boot files the idea is to collapse hs-boot files into their hs file nodes. In the old code * nodeDependencies changed edges from IsBoot to NonBoot * moduleGraphNodes just dropped boot file nodes The net result is that any dependencies of the hs-boot files themselves were dropped. The correct thing to do is * nodeDependencies changes edges from IsBoot to NonBoot * moduleGraphNodes merges dependencies of IsBoot and NonBoot nodes. The result is a properly quotiented dependency graph which contains no hs-boot files nor hs-boot file edges. Why this didn't cause endless issues when compiling with boot files, we will never know. - - - - - c84dc506 by Matthew Pickering at 2022-03-01T16:23:10-05:00 driver: Properly add an edge between a .hs and its hs-boot file As noted in #21071 we were missing adding this edge so there were situations where the .hs file would get compiled before the .hs-boot file which leads to issues with -j. I fixed this properly by adding the edge in downsweep so the definition of nodeDependencies can be simplified to avoid adding this dummy edge in. There are plenty of tests which seem to have these redundant boot files anyway so no new test. #21094 tracks the more general issue of identifying redundant hs-boot and SOURCE imports. - - - - - 7aeb6d29 by sheaf at 2022-03-01T16:23:51-05:00 Core Lint: collect args through floatable ticks We were not looking through floatable ticks when collecting arguments in Core Lint, which caused `checkCanEtaExpand` to fail on something like: ```haskell reallyUnsafePtrEquality = \ @a -> (src<loc> reallyUnsafePtrEquality#) @Lifted @a @Lifted @a ``` We fix this by using `collectArgsTicks tickishFloatable` instead of `collectArgs`, to be consistent with the behaviour of eta expansion outlined in Note [Eta expansion and source notes] in GHC.Core.Opt.Arity. Fixes #21152. - - - - - 75caafaa by Matthew Pickering at 2022-03-02T01:14:59-05:00 Ticky profiling improvements. This adds a number of changes to ticky-ticky profiling. When an executable is profiled with IPE profiling it's now possible to associate id-related ticky counters to their source location. This works by emitting the info table address as part of the counter which can be looked up in the IPE table. Add a `-ticky-ap-thunk` flag. This flag prevents the use of some standard thunks which are precompiled into the RTS. This means reduced cache locality and increased code size. But it allows better attribution of execution cost to specific source locations instead of simple attributing it to the standard thunk. ticky-ticky now uses the `arg` field to emit additional information about counters in json format. When ticky-ticky is used in combination with the eventlog eventlog2html can be used to generate a html table from the eventlog similar to the old text output for ticky-ticky. - - - - - aeea6bd5 by doyougnu at 2022-03-02T01:15:39-05:00 StgToCmm.cgTopBinding: no isNCG, use binBlobThresh This is a one line change. It is a fixup from MR!7325, was pointed out in review of MR!7442, specifically: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7442#note_406581 The change removes isNCG check from cgTopBinding. Instead it changes the type of binBlobThresh in DynFlags from Word to Maybe Word, where a Just 0 or a Nothing indicates an infinite threshold and thus the disable CmmFileEmbed case in the original check. This improves the cohesion of the module because more NCG related Backend stuff is moved into, and checked in, StgToCmm.Config. Note, that the meaning of a Just 0 or a Nothing in binBlobThresh is indicated in a comment next to its field in GHC.StgToCmm.Config. DynFlags: binBlobThresh: Word -> Maybe Word StgToCmm.Config: binBlobThesh add not ncg check DynFlags.binBlob: move Just 0 check to dflags init StgToCmm.binBlob: only check isNCG, Just 0 check to dflags StgToCmm.Config: strictify binBlobThresh - - - - - b27b2af3 by sheaf at 2022-03-02T14:08:36-05:00 Introduce ConcreteTv metavariables This patch introduces a new kind of metavariable, by adding the constructor `ConcreteTv` to `MetaInfo`. A metavariable with `ConcreteTv` `MetaInfo`, henceforth a concrete metavariable, can only be unified with a type that is concrete (that is, a type that answers `True` to `GHC.Core.Type.isConcrete`). This solves the problem of dangling metavariables in `Concrete#` constraints: instead of emitting `Concrete# ty`, which contains a secret existential metavariable, we simply emit a primitive equality constraint `ty ~# concrete_tv` where `concrete_tv` is a fresh concrete metavariable. This means we can avoid all the complexity of canonicalising `Concrete#` constraints, as we can just re-use the existing machinery for `~#`. To finish things up, this patch then removes the `Concrete#` special predicate, and instead introduces the special predicate `IsRefl#` which enforces that a coercion is reflexive. Such a constraint is needed because the canonicaliser is quite happy to rewrite an equality constraint such as `ty ~# concrete_tv`, but such a rewriting is not handled by the rest of the compiler currently, as we need to make use of the resulting coercion, as outlined in the FixedRuntimeRep plan. The big upside of this approach (on top of simplifying the code) is that we can now selectively implement PHASE 2 of FixedRuntimeRep, by changing individual calls of `hasFixedRuntimeRep_MustBeRefl` to `hasFixedRuntimeRep` and making use of the obtained coercion. - - - - - 81b7c436 by Matthew Pickering at 2022-03-02T14:09:13-05:00 Make -dannot-lint not panic on let bound type variables After certain simplifier passes we end up with let bound type variables which are immediately inlined in the next pass. The core diff utility implemented by -dannot-lint failed to take these into account and paniced. Progress towards #20965 - - - - - f596c91a by sheaf at 2022-03-02T14:09:51-05:00 Improve out-of-order inferred type variables Don't instantiate type variables for :type in `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting `r1` but not `r2` in the type forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ... This fixes #21088. This patch also changes the primop pretty-printer to ensure that we put all the inferred type variables first. For example, the type of reallyUnsafePtrEquality# is now forall {l :: Levity} {k :: Levity} (a :: TYPE (BoxedRep l)) (b :: TYPE (BoxedRep k)). a -> b -> Int# This means we avoid running into issue #21088 entirely with the types of primops. Users can still write a type signature where the inferred type variables don't come first, however. This change to primops had a knock-on consequence, revealing that we were sometimes performing eta reduction on keepAlive#. This patch updates tryEtaReduce to avoid eta reducing functions with no binding, bringing it in line with tryEtaReducePrep, and thus fixing #21090. - - - - - 1617fed3 by Richard Eisenberg at 2022-03-02T14:10:28-05:00 Make inert_cycle_breakers into a stack. Close #20231. - - - - - c8652a0a by Richard Eisenberg at 2022-03-02T14:11:03-05:00 Make Constraint not *apart* from Type. More details in Note [coreView vs tcView] Close #21092. - - - - - 91a10cb0 by doyougnu at 2022-03-02T14:11:43-05:00 GenStgAlt 3-tuple synonym --> Record type This commit alters GenStgAlt from a type synonym to a Record with field accessors. In pursuit of #21078, this is not a required change but cleans up several areas for nicer code in the upcoming js-backend, and in GHC itself. GenStgAlt: 3-tuple -> record Stg.Utils: GenStgAlt 3-tuple -> record Stg.Stats: StgAlt 3-tuple --> record Stg.InferTags.Rewrite: StgAlt 3-tuple -> record Stg.FVs: GenStgAlt 3-tuple -> record Stg.CSE: GenStgAlt 3-tuple -> record Stg.InferTags: GenStgAlt 3-tuple --> record Stg.Debug: GenStgAlt 3-tuple --> record Stg.Lift.Analysis: GenStgAlt 3-tuple --> record Stg.Lift: GenStgAlt 3-tuple --> record ByteCode.Instr: GenStgAlt 3-tuple --> record Stg.Syntax: add GenStgAlt helper functions Stg.Unarise: GenStgAlt 3-tuple --> record Stg.BcPrep: GenStgAlt 3-tuple --> record CoreToStg: GenStgAlt 3-tuple --> record StgToCmm.Expr: GenStgAlt 3-tuple --> record StgToCmm.Bind: GenStgAlt 3-tuple --> record StgToByteCode: GenStgAlt 3-tuple --> record Stg.Lint: GenStgAlt 3-tuple --> record Stg.Syntax: strictify GenStgAlt GenStgAlt: add haddock, some cleanup fixup: remove calls to pure, single ViewPattern StgToByteCode: use case over viewpatterns - - - - - 73864f00 by Matthew Pickering at 2022-03-02T14:12:19-05:00 base: Remove default method from bitraversable The default instance leads to an infinite loop. bisequenceA is defined in terms of bisquence which is defined in terms of bitraverse. ``` bitraverse f g = (defn of bitraverse) bisequenceA . bimap f g = (defn of bisequenceA) bitraverse id id . bimap f g = (defn of bitraverse) ... ``` Any instances defined without an explicitly implementation are currently broken, therefore removing it will alert users to an issue in their code. CLC issue: https://github.com/haskell/core-libraries-committee/issues/47 Fixes #20329 #18901 - - - - - 9579bf35 by Matthew Pickering at 2022-03-02T14:12:54-05:00 ci: Add check to CI to ensure compiler uses correct BIGNUM_BACKEND - - - - - c48a7c3a by Sylvain Henry at 2022-03-03T07:37:12-05:00 Use Word64# primops in Word64 Num instance Taken froù!3658 - - - - - ce65d0cc by Matthew Pickering at 2022-03-03T07:37:48-05:00 hadrian: Correctly set whether we have a debug compiler when running tests For example, running the `slow-validate` flavour would incorrectly run the T16135 test which would fail with an assertion error, despite the fact that is should be skipped when we have a debug compiler. - - - - - e0c3e757 by Matthew Pickering at 2022-03-03T13:48:41-05:00 docs: Add note to unsafeCoerce function that you might want to use coerce [skip ci] Fixes #15429 - - - - - 559d4cf3 by Matthew Pickering at 2022-03-03T13:49:17-05:00 docs: Add note to RULES documentation about locally bound variables [skip ci] Fixes #20100 - - - - - c534b3dd by Matthew Pickering at 2022-03-03T13:49:53-05:00 Replace ad-hoc CPP with constant from GHC.Utils.Constant Fixes #21154 - - - - - de56cc7e by Krzysztof Gogolewski at 2022-03-04T12:44:26-05:00 Update documentation of LiberalTypeSynonyms We no longer require LiberalTypeSynonyms to use 'forall' or an unboxed tuple in a synonym. I also removed that kind checking before expanding synonyms "could be changed". This was true when type synonyms were thought of macros, but with the extensions such as SAKS or matchability I don't see it changing. - - - - - c0a39259 by Simon Jakobi at 2022-03-04T12:45:01-05:00 base: Mark GHC.Bits not-home for haddock Most (all) of the exports are re-exported from the preferable Data.Bits. - - - - - 3570eda5 by Sylvain Henry at 2022-03-04T12:45:42-05:00 Fix comments about Int64/Word64 primops - - - - - 6f84ee33 by Artem Pelenitsyn at 2022-03-05T01:06:47-05:00 remove MonadFail instances of ST CLC proposal: https://github.com/haskell/core-libraries-committee/issues/33 The instances had `fail` implemented in terms of `error`, whereas the idea of the `MonadFail` class is that the `fail` method should be implemented in terms of the monad itself. - - - - - 584cd5ae by sheaf at 2022-03-05T01:07:25-05:00 Don't allow Float#/Double# literal patterns This patch does the following two things: 1. Fix the check in Core Lint to properly throw an error when it comes across Float#/Double# literal patterns. The check was incorrect before, because it expected the type to be Float/Double instead of Float#/Double#. 2. Add an error in the parser when the user writes a floating-point literal pattern such as `case x of { 2.0## -> ... }`. Fixes #21115 - - - - - 706deee0 by Greg Steuck at 2022-03-05T17:44:10-08:00 Make T20214 terminate promptly be setting input to /dev/null It was hanging and timing out on OpenBSD before. - - - - - 14e90098 by Simon Peyton Jones at 2022-03-07T14:05:41-05:00 Always generalise top-level bindings Fix #21023 by always generalising top-level binding; change the documentation of -XMonoLocalBinds to match. - - - - - c9c31c3c by Matthew Pickering at 2022-03-07T14:06:16-05:00 hadrian: Add little flavour transformer to build stage2 with assertions This can be useful to build a `perf+assertions` build or even better `default+no_profiled_libs+omit_pragmas+assertions`. - - - - - 89c14a6c by Matthew Pickering at 2022-03-07T14:06:16-05:00 ci: Convert all deb10 make jobs into hadrian jobs This is the first step in converting all the CI configs to use hadrian rather than make. (#21129) The metrics increase due to hadrian using --hyperlinked-source for haddock builds. (See #21156) ------------------------- Metric Increase: haddock.Cabal haddock.base haddock.compiler ------------------------- - - - - - 7bfae2ee by Matthew Pickering at 2022-03-07T14:06:16-05:00 Replace use of BIN_DIST_PREP_TAR_COMP with BIN_DIST_NAME And adds a check to make sure we are not accidently settings BIN_DIST_PREP_TAR_COMP when using hadrian. - - - - - 5b35ca58 by Matthew Pickering at 2022-03-07T14:06:16-05:00 Fix gen_contents_index logic for hadrian bindist - - - - - 273bc133 by Krzysztof Gogolewski at 2022-03-07T14:06:52-05:00 Fix reporting constraints in pprTcSolverReportMsg 'no_instance_msg' and 'no_deduce_msg' were omitting the first wanted. - - - - - 5874a30a by Simon Jakobi at 2022-03-07T14:07:28-05:00 Improve setBit for Natural Previously the default definition was used, which involved allocating intermediate Natural values. Fixes #21173. - - - - - 7a02aeb8 by Matthew Pickering at 2022-03-07T14:08:03-05:00 Remove leftover trace in testsuite - - - - - 6ce6c250 by Andreas Klebinger at 2022-03-07T23:48:56-05:00 Expand and improve the Note [Strict Worker Ids]. I've added an explicit mention of the invariants surrounding those. As well as adding more direct cross references to the Strict Field Invariant. - - - - - d0f892fe by Ryan Scott at 2022-03-07T23:49:32-05:00 Delete GenericKind_ in favor of GenericKind_DC When deriving a `Generic1` instance, we need to know what the last type variable of a data type is. Previously, there were two mechanisms to determine this information: * `GenericKind_`, where `Gen1_` stored the last type variable of a data type constructor (i.e., the `tyConTyVars`). * `GenericKind_DC`, where `Gen1_DC` stored the last universally quantified type variable in a data constructor (i.e., the `dataConUnivTyVars`). These had different use cases, as `GenericKind_` was used for generating `Rep(1)` instances, while `GenericKind_DC` was used for generating `from(1)` and `to(1)` implementations. This was already a bit confusing, but things went from confusing to outright wrong after !6976. This is because after !6976, the `deriving` machinery stopped using `tyConTyVars` in favor of `dataConUnivTyVars`. Well, everywhere with the sole exception of `GenericKind_`, which still continued to use `tyConTyVars`. This lead to disaster when deriving a `Generic1` instance for a GADT family instance, as the `tyConTyVars` do not match the `dataConUnivTyVars`. (See #21185.) The fix is to stop using `GenericKind_` and replace it with `GenericKind_DC`. For the most part, this proves relatively straightforward. Some highlights: * The `forgetArgVar` function was deleted entirely, as it no longer proved necessary after `GenericKind_`'s demise. * The substitution that maps from the last type variable to `Any` (see `Note [Generating a correctly typed Rep instance]`) had to be moved from `tc_mkRepTy` to `tc_mkRepFamInsts`, as `tc_mkRepTy` no longer has access to the last type variable. Fixes #21185. - - - - - a60ddffd by Matthew Pickering at 2022-03-08T22:51:37+00:00 Move bootstrap and cabal-reinstall test jobs to nightly CI is creaking under the pressure of too many jobs so attempt to reduce the strain by removing a couple of jobs. - - - - - 7abe3288 by Matthew Pickering at 2022-03-09T10:24:15+00:00 Add 10 minute timeout to linters job - - - - - 3cf75ede by Matthew Pickering at 2022-03-09T10:24:16+00:00 Revert "hadrian: Correctly set whether we have a debug compiler when running tests" Needing the arguments for "GHC/Utils/Constant.hs" implies a dependency on the previous stage compiler. Whilst we work out how to get around this I will just revert this commit (as it only affects running the testsuite in debug way). This reverts commit ce65d0cceda4a028f30deafa3c39d40a250acc6a. - - - - - 18b9ba56 by Matthew Pickering at 2022-03-09T11:07:23+00:00 ci: Fix save_cache function Each interation of saving the cache would copy the whole `cabal` store into a subfolder in the CACHE_DIR rather than copying the contents of the cabal store into the cache dir. This resulted in a cache which looked like: ``` /builds/ghc/ghc/cabal-cache/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/ ``` So it would get one layer deeper every CI run and take longer and longer to compress. - - - - - bc684dfb by Ben Gamari at 2022-03-10T03:20:07-05:00 mr-template: Mention timeframe for review - - - - - 7f5f4ede by Vladislav Zavialov at 2022-03-10T03:20:43-05:00 Bump submodules: containers, exceptions GHC Proposal #371 requires TypeOperators to use type equality a~b. This submodule update pulls in the appropriate forward-compatibility changes in 'libraries/containers' and 'libraries/exceptions' - - - - - 8532b8a9 by Matthew Pickering at 2022-03-10T03:20:43-05:00 Add an inline pragma to lookupVarEnv The containers bump reduced the size of the Data.IntMap.Internal.lookup function so that it no longer experienced W/W. This means that the size of lookupVarEnv increased over the inlining threshold and it wasn't inlined into the hot code path in substTyVar. See containers#821, #21159 and !7638 for some more explanation. ------------------------- Metric Decrease: LargeRecord T12227 T13386 T15703 T18223 T5030 T8095 T9872a T9872b T9872c TcPlugin_RewritePerf ------------------------- - - - - - 844cf1e1 by Matthew Pickering at 2022-03-10T03:20:43-05:00 Normalise output of T10970 test The output of this test changes each time the containers submodule version updates. It's easier to apply the version normaliser so that the test checks that there is a version number, but not which one it is. - - - - - 24b6af26 by Ryan Scott at 2022-03-11T19:56:28-05:00 Refactor tcDeriving to generate tyfam insts before any bindings Previously, there was an awful hack in `genInst` (now called `genInstBinds` after this patch) where we had to return a continutation rather than directly returning the bindings for a derived instance. This was done for staging purposes, as we had to first infer the instance contexts for derived instances and then feed these contexts into the continuations to ensure the generated instance bindings had accurate instance contexts. `Note [Staging of tcDeriving]` in `GHC.Tc.Deriving` described this confusing state of affairs. The root cause of this confusing design was the fact that `genInst` was trying to generate instance bindings and associated type family instances for derived instances simultaneously. This really isn't possible, however: as `Note [Staging of tcDeriving]` explains, one needs to have access to the associated type family instances before one can properly infer the instance contexts for derived instances. The use of continuation-returning style was an attempt to circumvent this dependency, but it did so in an awkward way. This patch detangles this awkwardness by splitting up `genInst` into two functions: `genFamInsts` (for associated type family instances) and `genInstBinds` (for instance bindings). Now, the `tcDeriving` function calls `genFamInsts` and brings all the family instances into scope before calling `genInstBinds`. This removes the need for the awkward continuation-returning style seen in the previous version of `genInst`, making the code easier to understand. There are some knock-on changes as well: 1. `hasStockDeriving` now needs to return two separate functions: one that describes how to generate family instances for a stock-derived instance, and another that describes how to generate the instance bindings. I factored out this pattern into a new `StockGenFns` data type. 2. While documenting `StockGenFns`, I realized that there was some inconsistency regarding which `StockGenFns` functions needed which arguments. In particular, the function in `GHC.Tc.Deriv.Generics` which generates `Rep(1)` instances did not take a `SrcSpan` like other `gen_*` functions did, and it included an extra `[Type]` argument that was entirely redundant. As a consequence, I refactored the code in `GHC.Tc.Deriv.Generics` to more closely resemble other `gen_*` functions. A happy result of all this is that all `StockGenFns` functions now take exactly the same arguments, which makes everything more uniform. This is purely a refactoring that should not have any effect on user-observable behavior. The new design paves the way for an eventual fix for #20719. - - - - - 62caaa9b by Ben Gamari at 2022-03-11T19:57:03-05:00 gitlab-ci: Use the linters image in hlint job As the `hlint` executable is only available in the linters image. Fixes #21146. - - - - - 4abd7eb0 by Matthew Pickering at 2022-03-11T19:57:38-05:00 Remove partOfGhci check in the loader This special logic has been part of GHC ever since template haskell was introduced in 9af77fa423926fbda946b31e174173d0ec5ebac8. It's hard to believe in any case that this special logic pays its way at all. Given * The list is out-of-date, which has potential to lead to miscompilation when using "editline", which was removed in 2010 (46aed8a4). * The performance benefit seems negligable as each load only happens once anyway and packages specified by package flags are preloaded into the linker state at the start of compilation. Therefore we just remove this logic. Fixes #19791 - - - - - c40cbaa2 by Andreas Klebinger at 2022-03-11T19:58:14-05:00 Improve -dtag-inference-checks checks. FUN closures don't get tagged when evaluated. So no point in checking their tags. - - - - - ab00d23b by Simon Jakobi at 2022-03-11T19:58:49-05:00 Improve clearBit and complementBit for Natural Also optimize bigNatComplementBit#. Fixes #21175, #21181, #21194. - - - - - a6d8facb by Sebastian Graf at 2022-03-11T19:59:24-05:00 gitignore all (build) directories headed by _ - - - - - 524795fe by Sebastian Graf at 2022-03-11T19:59:24-05:00 Demand: Document why we need three additional equations of multSubDmd - - - - - 6bdcd557 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: make 64-bit word splitting for 32-bit targets respect target endianness This used to been broken for little-endian targets. - - - - - 9e67c69e by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: fix Double# literal payload for 32-bit targets Contrary to the legacy comment, the splitting didn't happen and we ended up with a single StgWord64 literal in the output code! Let's just do the splitting here. - - - - - 1eee2e28 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: use __builtin versions of memcpyish functions to fix type mismatch Our memcpyish primop's type signatures doesn't match the C type signatures. It's not a problem for typical archs, since their C ABI permits dropping the result, but it doesn't work for wasm. The previous logic would cast the memcpyish function pointer to an incorrect type and perform an indirect call, which results in a runtime trap on wasm. The most straightforward fix is: don't emit EFF_ for memcpyish functions. Since we don't want to include extra headers in .hc to bring in their prototypes, we can just use the __builtin versions. - - - - - 9d8d4837 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: emit __builtin_unreachable() when CmmSwitch doesn't contain fallback case Otherwise the C compiler may complain "warning: non-void function does not return a value in all control paths [-Wreturn-type]". - - - - - 27da5540 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: make floatToWord32/doubleToWord64 faster Use castFloatToWord32/castDoubleToWord64 in base to perform the reinterpret cast. - - - - - c98e8332 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: fix -Wunused-value warning in ASSIGN_BaseReg When ASSIGN_BaseReg is a no-op, we shouldn't generate any C code, otherwise C compiler complains a bunch of -Wunused-value warnings when doing unregisterised codegen. - - - - - 5932247c by Ben Gamari at 2022-03-11T20:00:36-05:00 users guide: Eliminate spurious \spxentry mentions We were failing to pass the style file to `makeindex`, as is done by the mklatex configuration generated by Sphinx. Fixes #20913. - - - - - e40cf4ef by Simon Jakobi at 2022-03-11T20:01:11-05:00 ghc-bignum: Tweak integerOr The result of ORing two BigNats is always greater or equal to the larger of the two. Therefore it is safe to skip the magnitude checks of integerFromBigNat#. - - - - - cf081476 by Vladislav Zavialov at 2022-03-12T07:02:40-05:00 checkUnboxedLitPat: use non-fatal addError This enables GHC to report more parse errors in a single pass. - - - - - 7fe07143 by Andreas Klebinger at 2022-03-12T07:03:16-05:00 Rename -fprof-late-ccs to -fprof-late - - - - - 88a94541 by Sylvain Henry at 2022-03-12T07:03:56-05:00 Hadrian: avoid useless allocations in trackArgument Cf ticky report before the change: Entries Alloc Alloc'd Non-void Arguments STG Name -------------------------------------------------------------------------------- 696987 29044128 0 1 L main:Target.trackArgument_go5{v r24kY} (fun) - - - - - 2509d676 by Sylvain Henry at 2022-03-12T07:04:36-05:00 Hadrian: avoid allocating in stageString (#19209) - - - - - c062fac0 by Sylvain Henry at 2022-03-12T07:04:36-05:00 Hadrian: remove useless imports Added for no reason in 7ce1b694f7be7fbf6e2d7b7eb0639e61fbe358c6 - - - - - c82fb934 by Sylvain Henry at 2022-03-12T07:05:16-05:00 Hadrian: avoid allocations in WayUnit's Read instance (#19209) - - - - - ed04aed2 by Sylvain Henry at 2022-03-12T07:05:16-05:00 Hadrian: use IntSet Binary instance for Way (#19209) - - - - - ad835531 by Simon Peyton Jones at 2022-03-13T18:12:12-04:00 Fix bug in weak loop-breakers in OccurAnal Note [Weak loop breakers] explains why we need to track variables free in RHS of rules. But we need to do this for /inactive/ rules as well as active ones, unlike the rhs_fv_env stuff. So we now have two fields in node Details, one for free vars of active rules, and one for free vars of all rules. This was shown up by #20820, which is now fixed. - - - - - 76b94b72 by Sebastian Graf at 2022-03-13T18:12:48-04:00 Worker/wrapper: Preserve float barriers (#21150) Issue #21150 shows that worker/wrapper allocated a worker function for a function with multiple calls that said "called at most once" when the first argument was absent. That's bad! This patch makes it so that WW preserves at least one non-one-shot value lambda (see `Note [Preserving float barriers]`) by passing around `void#` in place of absent arguments. Fixes #21150. Since the fix is pretty similar to `Note [Protecting the last value argument]`, I put the logic in `mkWorkerArgs`. There I realised (#21204) that `-ffun-to-thunk` is basically useless with `-ffull-laziness`, so I deprecated the flag, simplified and split into `needsVoidWorkerArg`/`addVoidWorkerArg`. SpecConstr is another client of that API. Fixes #21204. Metric Decrease: T14683 - - - - - 97db789e by romes at 2022-03-14T11:36:39-04:00 Fix up Note [Bind free vars] Move GHC-specific comments from Language.Haskell.Syntax.Binds to GHC.Hs.Binds It looks like the Note was deleted but there were actually two copies of it. L.H.S.B no longer references it, and GHC.Hs.Binds keeps an updated copy. (See #19252) There are other duplicated notes -- they will be fixed in the next commit - - - - - 135888dd by romes at 2022-03-14T11:36:39-04:00 TTG Pull AbsBinds and ABExport out of the main AST AbsBinds and ABExport both depended on the typechecker, and were thus removed from the main AST Expr. CollectPass now has a new function `collectXXHsBindsLR` used for the new HsBinds extension point Bumped haddock submodule to work with AST changes. The removed Notes from Language.Haskell.Syntax.Binds were duplicated (and not referenced) and the copies in GHC.Hs.Binds are kept (and referenced there). (See #19252) - - - - - 106413f0 by sheaf at 2022-03-14T11:37:21-04:00 Add two coercion optimisation perf tests - - - - - 8eadea67 by sheaf at 2022-03-14T15:08:24-04:00 Fix isLiftedType_maybe and handle fallout As #20837 pointed out, `isLiftedType_maybe` returned `Just False` in many situations where it should return `Nothing`, because it didn't take into account type families or type variables. In this patch, we fix this issue. We rename `isLiftedType_maybe` to `typeLevity_maybe`, which now returns a `Levity` instead of a boolean. We now return `Nothing` for types with kinds of the form `TYPE (F a1 ... an)` for a type family `F`, as well as `TYPE (BoxedRep l)` where `l` is a type variable. This fix caused several other problems, as other parts of the compiler were relying on `isLiftedType_maybe` returning a `Just` value, and were now panicking after the above fix. There were two main situations in which panics occurred: 1. Issues involving the let/app invariant. To uphold that invariant, we need to know whether something is lifted or not. If we get an answer of `Nothing` from `isLiftedType_maybe`, then we don't know what to do. As this invariant isn't particularly invariant, we can change the affected functions to not panic, e.g. by behaving the same in the `Just False` case and in the `Nothing` case (meaning: no observable change in behaviour compared to before). 2. Typechecking of data (/newtype) constructor patterns. Some programs involving patterns with unknown representations were accepted, such as T20363. Now that we are stricter, this caused further issues, culminating in Core Lint errors. However, the behaviour was incorrect the whole time; the incorrectness only being revealed by this change, not triggered by it. This patch fixes this by overhauling where the representation polymorphism involving pattern matching are done. Instead of doing it in `tcMatches`, we instead ensure that the `matchExpected` functions such as `matchExpectedFunTys`, `matchActualFunTySigma`, `matchActualFunTysRho` allow return argument pattern types which have a fixed RuntimeRep (as defined in Note [Fixed RuntimeRep]). This ensures that the pattern matching code only ever handles types with a known runtime representation. One exception was that patterns with an unknown representation type could sneak in via `tcConPat`, which points to a missing representation-polymorphism check, which this patch now adds. This means that we now reject the program in #20363, at least until we implement PHASE 2 of FixedRuntimeRep (allowing type families in RuntimeRep positions). The aforementioned refactoring, in which checks have been moved to `matchExpected` functions, is a first step in implementing PHASE 2 for patterns. Fixes #20837 - - - - - 8ff32124 by Sebastian Graf at 2022-03-14T15:09:01-04:00 DmdAnal: Don't unbox recursive data types (#11545) As `Note [Demand analysis for recursive data constructors]` describes, we now refrain from unboxing recursive data type arguments, for two reasons: 1. Relating to run/alloc perf: Similar to `Note [CPR for recursive data constructors]`, it seldomly improves run/alloc performance if we just unbox a finite number of layers of a potentially huge data structure. 2. Relating to ghc/alloc perf: Inductive definitions on single-product recursive data types like the one in T11545 will (diverge, and) have very deep demand signatures before any other abortion mechanism in Demand analysis is triggered. That leads to great and unnecessary churn on Demand analysis when ultimately we will never make use of any nested strictness information anyway. Conclusion: Discard nested demand and boxity information on such recursive types with the help of `Note [Detecting recursive data constructors]`. I also implemented `GHC.Types.Unique.MemoFun.memoiseUniqueFun` in order to avoid the overhead of repeated calls to `GHC.Core.Opt.WorkWrap.Utils.isRecDataCon`. It's nice and simple and guards against some smaller regressions in T9233 and T16577. ghc/alloc performance-wise, this patch is a very clear win: Test Metric value New value Change --------------------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,141,071,720 6,099,871,216 -0.7% MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,740,973,040 2,705,146,640 -1.3% T11545(normal) ghc/alloc 945,475,492 85,768,928 -90.9% GOOD T13056(optasm) ghc/alloc 370,245,880 326,980,632 -11.7% GOOD T18304(normal) ghc/alloc 90,933,944 76,998,064 -15.3% GOOD T9872a(normal) ghc/alloc 1,800,576,840 1,792,348,760 -0.5% T9872b(normal) ghc/alloc 2,086,492,432 2,073,991,848 -0.6% T9872c(normal) ghc/alloc 1,750,491,240 1,737,797,832 -0.7% TcPlugin_RewritePerf(normal) ghc/alloc 2,286,813,400 2,270,957,896 -0.7% geo. mean -2.9% No noteworthy change in run/alloc either. NoFib results show slight wins, too: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- constraints -1.9% -1.4% fasta -3.6% -2.7% reverse-complem -0.3% -0.9% treejoin -0.0% -0.3% -------------------------------------------------------------------------------- Min -3.6% -2.7% Max +0.1% +0.1% Geometric Mean -0.1% -0.1% Metric Decrease: T11545 T13056 T18304 - - - - - ab618309 by Vladislav Zavialov at 2022-03-15T18:34:38+03:00 Export (~) from Data.Type.Equality (#18862) * Users can define their own (~) type operator * Haddock can display documentation for the built-in (~) * New transitional warnings implemented: -Wtype-equality-out-of-scope -Wtype-equality-requires-operators Updates the haddock submodule. - - - - - 577135bf by Aaron Allen at 2022-03-16T02:27:48-04:00 Convert Diagnostics in GHC.Tc.Gen.Foreign Converts all uses of 'TcRnUnknownMessage' to proper diagnostics. - - - - - c1fed9da by Aaron Allen at 2022-03-16T02:27:48-04:00 Suggest FFI extensions as hints (#20116) - Use extension suggestion hints instead of suggesting extensions in the error message body for several FFI errors. - Adds a test case for `TcRnForeignImportPrimExtNotSet` - - - - - a33d1045 by Zubin Duggal at 2022-03-16T02:28:24-04:00 TH: allow negative patterns in quotes (#20711) We still don't allow negative overloaded patterns. Earler all negative patterns were treated as negative overloaded patterns. Now, we expliclty check the extension field to see if the pattern is actually a negative overloaded pattern - - - - - 1575c4a5 by Sebastian Graf at 2022-03-16T02:29:03-04:00 Demand: Let `Boxed` win in `lubBoxity` (#21119) Previously, we let `Unboxed` win in `lubBoxity`, which is unsoundly optimistic in terms ob Boxity analysis. "Unsoundly" in the sense that we sometimes unbox parameters that we better shouldn't unbox. Examples are #18907 and T19871.absent. Until now, we thought that this hack pulled its weight becuase it worked around some shortcomings of the phase separation between Boxity analysis and CPR analysis. But it is a gross hack which caused regressions itself that needed all kinds of fixes and workarounds. See for example #20767. It became impossible to work with in !7599, so I want to remove it. For example, at the moment, `lubDmd B dmd` will not unbox `dmd`, but `lubDmd A dmd` will. Given that `B` is supposed to be the bottom element of the lattice, it's hardly justifiable to get a better demand when `lub`bing with `A`. The consequence of letting `Boxed` win in `lubBoxity` is that we *would* regress #2387, #16040 and parts of #5075 and T19871.sumIO, until Boxity and CPR are able to communicate better. Fortunately, that is not the case since I could tweak the other source of optimism in Boxity analysis that is described in `Note [Unboxed demand on function bodies returning small products]` so that we *recursively* assume unboxed demands on function bodies returning small products. See the updated Note. `Note [Boxity for bottoming functions]` describes why we need bottoming functions to have signatures that say that they deeply unbox their arguments. In so doing, I had to tweak `finaliseArgBoxities` so that it will never unbox recursive data constructors. This is in line with our handling of them in CPR. I updated `Note [Which types are unboxed?]` to reflect that. In turn we fix #21119, #20767, #18907, T19871.absent and get a much simpler implementation (at least to think about). We can also drop the very ad-hoc definition of `deferAfterPreciseException` and its Note in favor of the simple, intuitive definition we used to have. Metric Decrease: T16875 T18223 T18698a T18698b hard_hole_fits Metric Increase: LargeRecord MultiComponentModulesRecomp T15703 T8095 T9872d Out of all the regresions, only the one in T9872d doesn't vanish in a perf build, where the compiler is bootstrapped with -O2 and thus SpecConstr. Reason for regressions: * T9872d is due to `ty_co_subst` taking its `LiftingContext` boxed. That is because the context is passed to a function argument, for example in `liftCoSubstTyVarBndrUsing`. * In T15703, LargeRecord and T8095, we get a bit more allocations in `expand_syn` and `piResultTys`, because a `TCvSubst` isn't unboxed. In both cases that guards against reboxing in some code paths. * The same is true for MultiComponentModulesRecomp, where we get less unboxing in `GHC.Unit.Finder.$wfindInstalledHomeModule`. In a perf build, allocations actually *improve* by over 4%! Results on NoFib: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- awards -0.4% +0.3% cacheprof -0.3% +2.4% fft -1.5% -5.1% fibheaps +1.2% +0.8% fluid -0.3% -0.1% ida +0.4% +0.9% k-nucleotide +0.4% -0.1% last-piece +10.5% +13.9% lift -4.4% +3.5% mandel2 -99.7% -99.8% mate -0.4% +3.6% parser -1.0% +0.1% puzzle -11.6% +6.5% reverse-complem -3.0% +2.0% scs -0.5% +0.1% sphere -0.4% -0.2% wave4main -8.2% -0.3% -------------------------------------------------------------------------------- Summary excludes mandel2 because of excessive bias Min -11.6% -5.1% Max +10.5% +13.9% Geometric Mean -0.2% +0.3% -------------------------------------------------------------------------------- Not bad for a bug fix. The regression in `last-piece` could become a win if SpecConstr would work on non-recursive functions. The regression in `fibheaps` is due to `Note [Reboxed crud for bottoming calls]`, e.g., #21128. - - - - - bb779b90 by sheaf at 2022-03-16T02:29:42-04:00 Add a regression test for #21130 This problem was due to a bug in cloneWanted, which was incorrectly creating a coercion hole to hold an evidence variable. This bug was introduced by 8bb52d91 and fixed in 81740ce8. Fixes #21130 - - - - - 0f0e2394 by Tamar Christina at 2022-03-17T10:16:37-04:00 linker: Initial Windows C++ exception unwinding support - - - - - 36d20d4d by Tamar Christina at 2022-03-17T10:16:37-04:00 linker: Fix ADDR32NB relocations on Windows - - - - - 8a516527 by Tamar Christina at 2022-03-17T10:16:37-04:00 testsuite: properly escape string paths - - - - - 1a0dd008 by sheaf at 2022-03-17T10:17:13-04:00 Hadrian: account for change in late-ccs flag The late cost centre flag was renamed from -fprof-late-ccs to -fprof-late in 7fe07143, but this change hadn't been propagated to Hadrian. - - - - - 8561c1af by romes at 2022-03-18T05:10:58-04:00 TTG: Refactor HsBracket - - - - - 19163397 by romes at 2022-03-18T05:10:58-04:00 Type-checking untyped brackets When HsExpr GhcTc, the HsBracket constructor should hold a HsBracket GhcRn, rather than an HsBracket GhcTc. We make use of the HsBracket p extension constructor (XBracket (XXBracket p)) to hold an HsBracket GhcRn when the pass is GhcTc See !4782 https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - 310890a5 by romes at 2022-03-18T05:10:58-04:00 Separate constructors for typed and untyped brackets Split HsBracket into HsTypedBracket and HsUntypedBracket. Unfortunately, we still cannot get rid of instance XXTypedBracket GhcTc = HsTypedBracket GhcRn despite no longer requiring it for typechecking, but rather because the TH desugarer works on GhcRn rather than GhcTc (See GHC.HsToCore.Quote) - - - - - 4a2567f5 by romes at 2022-03-18T05:10:58-04:00 TTG: Refactor bracket for desugaring during tc When desugaring a bracket we want to desugar /renamed/ rather than /typechecked/ code; So in (HsExpr GhcTc) tree, we must have a (HsExpr GhcRn) for the quotation itself. This commit reworks the TTG refactor on typed and untyped brackets by storing the /renamed/ code in the bracket field extension rather than in the constructor extension in `HsQuote` (previously called `HsUntypedBracket`) See Note [The life cycle of a TH quotation] and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - b056adc8 by romes at 2022-03-18T05:10:58-04:00 TTG: Make HsQuote GhcTc isomorphic to NoExtField An untyped bracket `HsQuote p` can never be constructed with `p ~ GhcTc`. This is because we don't typecheck `HsQuote` at all. That's OK, because we also never use `HsQuote GhcTc`. To enforce this at the type level we make `HsQuote GhcTc` isomorphic to `NoExtField` and impossible to construct otherwise, by using TTG field extensions to make all constructors, except for `XQuote` (which takes `NoExtField`), unconstructable, with `DataConCantHappen` This is explained more in detail in Note [The life cycle of a TH quotation] Related discussion: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - ac3b2e7d by romes at 2022-03-18T05:10:58-04:00 TTG: TH brackets finishing touches Rewrite the critical notes and fix outdated ones, use `HsQuote GhcRn` (in `HsBracketTc`) for desugaring regardless of the bracket being typed or untyped, remove unused `EpAnn` from `Hs*Bracket GhcRn`, zonkExpr factor out common brackets code, ppr_expr factor out common brackets code, and fix tests, to finish MR https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782. ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - d147428a by Ben Gamari at 2022-03-18T05:11:35-04:00 codeGen: Fix signedness of jump table indexing Previously while constructing the jump table index we would zero-extend the discriminant before subtracting the start of the jump-table. This goes subtly wrong in the case of a sub-word, signed discriminant, as described in the included Note. Fix this in both the PPC and X86 NCGs. Fixes #21186. - - - - - 435a3d5d by Ben Gamari at 2022-03-18T05:11:35-04:00 testsuite: Add test for #21186 - - - - - e9d8de93 by Zubin Duggal at 2022-03-19T07:35:49-04:00 TH: Fix pretty printing of newtypes with operators and GADT syntax (#20868) The pretty printer for regular data types already accounted for these, and had some duplication with the newtype pretty printer. Factoring the logic out into a common function and using it for both newtypes and data declarations is enough to fix the bug. - - - - - 244da9eb by sheaf at 2022-03-19T07:36:24-04:00 List GHC.Event.Internal in base.cabal on Windows GHC.Event.Internal was not listed in base.cabal on Windows. This caused undefined reference errors. This patch adds it back, by moving it out of the OS-specific logic in base.cabal. Fixes #21245. - - - - - d1c03719 by Andreas Klebinger at 2022-03-19T07:37:00-04:00 Compact regions: Maintain tags properly Fixes #21251 - - - - - d45bb701 by romes at 2022-03-19T07:37:36-04:00 Remove dead code HsDoRn - - - - - c842611f by nineonine at 2022-03-20T21:16:06-04:00 Revamp derived Eq instance code generation (#17240) This patch improves code generation for derived Eq instances. The idea is to use 'dataToTag' to evaluate both arguments. This allows to 'short-circuit' when tags do not match. Unfortunately, inner evals are still present when we branch on tags. This is due to the way 'dataToTag#' primop evaluates its argument in the code generator. #21207 was created to explore further optimizations. Metric Decrease: LargeRecord - - - - - 52ffd38c by Sylvain Henry at 2022-03-20T21:16:46-04:00 Avoid some SOURCE imports - - - - - b91798be by Zubin Duggal at 2022-03-23T13:39:39-04:00 hi haddock: Lex and store haddock docs in interface files Names appearing in Haddock docstrings are lexed and renamed like any other names appearing in the AST. We currently rename names irrespective of the namespace, so both type and constructor names corresponding to an identifier will appear in the docstring. Haddock will select a given name as the link destination based on its own heuristics. This patch also restricts the limitation of `-haddock` being incompatible with `Opt_KeepRawTokenStream`. The export and documenation structure is now computed in GHC and serialised in .hi files. This can be used by haddock to directly generate doc pages without reparsing or renaming the source. At the moment the operation of haddock is not modified, that's left to a future patch. Updates the haddock submodule with the minimum changes needed. - - - - - 78db231f by Cheng Shao at 2022-03-23T13:40:17-04:00 configure: bump LlvmMaxVersion to 14 LLVM 13.0.0 is released in Oct 2021, and latest head validates against LLVM 13 just fine if LlvmMaxVersion is bumped. - - - - - b06e5dd8 by Adam Sandberg Ericsson at 2022-03-23T13:40:54-04:00 docs: clarify the eventlog format documentation a little bit - - - - - 4dc62498 by Matthew Pickering at 2022-03-23T13:41:31-04:00 Fix behaviour of -Wunused-packages in ghci Ticket #21110 points out that -Wunused-packages behaves a bit unusually in GHCi. Now we define the semantics for -Wunused-packages in interactive mode as follows: * If you use -Wunused-packages on an initial load then the warning is reported. * If you explicitly set -Wunused-packages on the command line then the warning is displayed (until it is disabled) * If you then subsequently modify the set of available targets by using :load or :cd (:cd unloads everything) then the warning is (silently) turned off. This means that every :r the warning is printed if it's turned on (but you did ask for it). Fixes #21110 - - - - - fed05347 by Ben Gamari at 2022-03-23T13:42:07-04:00 rts/adjustor: Place adjustor templates in data section on all OSs In !7604 we started placing adjustor templates in the data section on Linux as some toolchains there reject relocations in the text section. However, it turns out that OpenBSD also exhibits this restriction. Fix this by *always* placing adjustor templates in the data section. Fixes #21155. - - - - - db32bb8c by Zubin Duggal at 2022-03-23T13:42:44-04:00 Improve error message when warning about unsupported LLVM version (#20958) Change the wording to make it clear that the upper bound is non-inclusive. - - - - - f214349a by Ben Gamari at 2022-03-23T13:43:20-04:00 rts: Untag function field in scavenge_PAP_payload Previously we failed to untag the function closure when scavenging the payload of a PAP, resulting in an invalid closure pointer being passed to scavenge_large_bitmap and consequently #21254. Fix this. Fixes #21254 - - - - - e6d0e287 by Ben Gamari at 2022-03-23T13:43:20-04:00 rts: Don't mark object code in markCAFs unless necessary Previously `markCAFs` would call `markObjectCode` even in non-major GCs. This is problematic since `prepareUnloadCheck` is not called in such GCs, meaning that the section index has not been updated. Fixes #21254 - - - - - 1a7cf096 by Sylvain Henry at 2022-03-23T13:44:05-04:00 Avoid redundant imports of GHC.Driver.Session Remove GHC.Driver.Session imports that weren't considered as redundant because of the reexport of PlatformConstants. Also remove this reexport as modules using this datatype should import GHC.Platform instead. - - - - - e3f60577 by Sylvain Henry at 2022-03-23T13:44:05-04:00 Reverse dependency between StgToCmm and Runtime.Heap.Layout - - - - - e6585ca1 by Sylvain Henry at 2022-03-23T13:44:46-04:00 Define filterOut with filter filter has fusion rules that filterOut lacks - - - - - c58d008c by Ryan Scott at 2022-03-24T06:10:43-04:00 Fix and simplify DeriveAnyClass's context inference using SubTypePredSpec As explained in `Note [Gathering and simplifying constraints for DeriveAnyClass]` in `GHC.Tc.Deriv.Infer`, `DeriveAnyClass` infers instance contexts by emitting implication constraints. Previously, these implication constraints were constructed by hand. This is a terribly trick thing to get right, as it involves a delicate interplay of skolemisation, metavariable instantiation, and `TcLevel` bumping. Despite much effort, we discovered in #20719 that the implementation was subtly incorrect, leading to valid programs being rejected. While we could scrutinize the code that manually constructs implication constraints and repair it, there is a better, less error-prone way to do things. After all, the heart of `DeriveAnyClass` is generating code which fills in each class method with defaults, e.g., `foo = $gdm_foo`. Typechecking this sort of code is tantamount to calling `tcSubTypeSigma`, as we much ensure that the type of `$gdm_foo` is a subtype of (i.e., more polymorphic than) the type of `foo`. As an added bonus, `tcSubTypeSigma` is a battle-tested function that handles skolemisation, metvariable instantiation, `TcLevel` bumping, and all other means of tricky bookkeeping correctly. With this insight, the solution to the problems uncovered in #20719 is simple: use `tcSubTypeSigma` to check if `$gdm_foo`'s type is a subtype of `foo`'s type. As a side effect, `tcSubTypeSigma` will emit exactly the implication constraint that we were attempting to construct by hand previously. Moreover, it does so correctly, fixing #20719 as a consequence. This patch implements the solution thusly: * The `PredSpec` data type (previously named `PredOrigin`) is now split into `SimplePredSpec`, which directly stores a `PredType`, and `SubTypePredSpec`, which stores the actual and expected types in a subtype check. `SubTypePredSpec` is only used for `DeriveAnyClass`; all other deriving strategies use `SimplePredSpec`. * Because `tcSubTypeSigma` manages the finer details of type variable instantiation and constraint solving under the hood, there is no longer any need to delicately split apart the method type signatures in `inferConstraintsAnyclass`. This greatly simplifies the implementation of `inferConstraintsAnyclass` and obviates the need to store skolems, metavariables, or given constraints in a `ThetaSpec` (previously named `ThetaOrigin`). As a bonus, this means that `ThetaSpec` now simply becomes a synonym for a list of `PredSpec`s, which is conceptually much simpler than it was before. * In `simplifyDeriv`, each `SubTypePredSpec` results in a call to `tcSubTypeSigma`. This is only performed for its side effect of emitting an implication constraint, which is fed to the rest of the constraint solving machinery in `simplifyDeriv`. I have updated `Note [Gathering and simplifying constraints for DeriveAnyClass]` to explain this in more detail. To make the changes in `simplifyDeriv` more manageable, I also performed some auxiliary refactoring: * Previously, every iteration of `simplifyDeriv` was skolemising the type variables at the start, simplifying, and then performing a reverse substitution at the end to un-skolemise the type variables. This is not necessary, however, since we can just as well skolemise once at the beginning of the `deriving` pipeline and zonk the `TcTyVar`s after `simplifyDeriv` is finished. This patch does just that, having been made possible by prior work in !7613. I have updated `Note [Overlap and deriving]` in `GHC.Tc.Deriv.Infer` to explain this, and I have also left comments on the relevant data structures (e.g., `DerivEnv` and `DerivSpec`) to explain when things might be `TcTyVar`s or `TyVar`s. * All of the aforementioned cleanup allowed me to remove an ad hoc deriving-related in `checkImplicationInvariants`, as all of the skolems in a `tcSubTypeSigma`–produced implication constraint should now be `TcTyVar` at the time the implication is created. * Since `simplifyDeriv` now needs a `SkolemInfo` and `UserTypeCtxt`, I have added `ds_skol_info` and `ds_user_ctxt` fields to `DerivSpec` to store these. Similarly, I have also added a `denv_skol_info` field to `DerivEnv`, which ultimately gets used to initialize the `ds_skol_info` in a `DerivSpec`. Fixes #20719. - - - - - 21680fb0 by Sebastian Graf at 2022-03-24T06:11:19-04:00 WorkWrap: Handle partial FUN apps in `isRecDataCon` (#21265) Partial FUN apps like `(->) Bool` aren't detected by `splitFunTy_maybe`. A silly oversight that is easily fixed by replacing `splitFunTy_maybe` with a guard in the `splitTyConApp_maybe` case. But fortunately, Simon nudged me into rewriting the whole `isRecDataCon` function in a way that makes it much shorter and hence clearer which DataCons are actually considered as recursive. Fixes #21265. - - - - - a2937e2b by Matthew Pickering at 2022-03-24T17:13:22-04:00 Add test for T21035 This test checks that you are allowed to explicitly supply object files for dependencies even if you haven't got the shared object for that library yet. Fixes #21035 - - - - - 1756d547 by Matthew Pickering at 2022-03-24T17:13:58-04:00 Add check to ensure we are not building validate jobs for releases - - - - - 99623358 by Matthew Pickering at 2022-03-24T17:13:58-04:00 hadrian: Correct generation of hsc2hs wrapper If you inspect the inside of a wrapper script for hsc2hs you will see that the cflag and lflag values are concatenated incorrectly. ``` HSC2HS_EXTRA="--cflag=-U__i686--lflag=-fuse-ld=gold" ``` It should instead be ``` HSC2HS_EXTRA="--cflag=-U__i686 --lflag=-fuse-ld=gold" ``` Fixes #21221 - - - - - fefd4e31 by Matthew Pickering at 2022-03-24T17:13:59-04:00 testsuite: Remove library dependenices from T21119 These dependencies would affect the demand signature depending on various rules and so on. Fixes #21271 - - - - - 5ff690b8 by Matthew Pickering at 2022-03-24T17:13:59-04:00 ci: Generate jobs for all normal builds and use hadrian for all builds This commit introduces a new script (.gitlab/gen_ci.hs) which generates a yaml file (.gitlab/jobs.yaml) which contains explicit descriptions for all the jobs we want to run. The jobs are separated into three categories: * validate - jobs run on every MR * nightly - jobs run once per day on the master branch * release - jobs for producing release artifacts The generation script is a Haskell program which includes a DSL for specifying the different jobs. The hope is that it's easier to reason about the different jobs and how the variables are merged together rather than the unclear and opaque yaml syntax. The goal is to fix issues like #21190 once and for all.. The `.gitlab/jobs.yaml` can be generated by running the `.gitlab/generate_jobs` script. You have to do this manually. Another consequence of this patch is that we use hadrian for all the validate, nightly and release builds on all platforms. - - - - - 1d673aa2 by Christiaan Baaij at 2022-03-25T11:35:49-04:00 Add the OPAQUE pragma A new pragma, `OPAQUE`, that ensures that every call of a named function annotated with an `OPAQUE` pragma remains a call of that named function, not some name-mangled variant. Implements GHC proposal 0415: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst This commit also updates the haddock submodule to handle the newly introduced lexer tokens corresponding to the OPAQUE pragma. - - - - - 83f5841b by Bodigrim at 2022-03-25T11:36:31-04:00 Add instance Lift ByteArray - - - - - 7cc1184a by Matthew Pickering at 2022-03-25T11:37:07-04:00 Make -ddump-rn-ast and -ddump-tc-ast work in GHCi Fixes #17830 - - - - - 940feaf3 by Sylvain Henry at 2022-03-25T11:37:47-04:00 Modularize Tidy (#17957) - Factorize Tidy options into TidyOpts datatype. Initialize it in GHC.Driver.Config.Tidy - Same thing for StaticPtrOpts - Perform lookups of unpackCString[Utf8]# once in initStaticPtrOpts instead of for every use of mkStringExprWithFS - - - - - 25101813 by Takenobu Tani at 2022-03-28T01:16:02-04:00 users-guide: Correct markdown for profiling This patch corrects some markdown. [skip ci] - - - - - c832ae93 by Matthew Pickering at 2022-03-28T01:16:38-04:00 hadrian: Flag cabal flag handling This patch basically deletes some ad-hoc handling of Cabal Flags and replaces it with a correct query of the LocalBuildInfo. The flags in the local build info can be modified by users by passing hadrian options For example (!4331) ``` *.genapply.cabal.configure.opts += --flags=unregisterised ``` And all the flags specified by the `Cabal Flags` builder were already passed to configure properly using `--flags`. - - - - - a9f3a5c6 by Ben Gamari at 2022-03-28T01:16:38-04:00 Disable text's dependency on simdutf by default Unfortunately we are simply not currently in a good position to robustly ship binary distributions which link against C++ code like simdutf. Fixes #20724. - - - - - eff86e8a by Richard Eisenberg at 2022-03-28T01:17:14-04:00 Add Red Herring to Note [What might equal later?] Close #21208. - - - - - 12653be9 by jberryman at 2022-03-28T01:17:55-04:00 Document typed splices inhibiting unused bind detection (#16524) - - - - - 4aeade15 by Adam Sandberg Ericsson at 2022-03-28T01:18:31-04:00 users-guide: group ticky-ticky profiling under one heading - - - - - cc59648a by Sylvain Henry at 2022-03-28T01:19:12-04:00 Hadrian: allow testsuite to run with cross-compilers (#21292) - - - - - 89cb1315 by Matthew Pickering at 2022-03-28T01:19:48-04:00 hadrian: Add show target to bindist makefile Some build systems use "make show" to query facts about the bindist, for example: ``` make show VALUE=ProjectVersion > version ``` to determine the ProjectVersion - - - - - 8229885c by Alan Zimmerman at 2022-03-28T19:23:28-04:00 EPA: let stmt with semicolon has wrong anchor The code let ;x =1 Captures the semicolon annotation, but did not widen the anchor in the ValBinds. Fix that. Closes #20247 - - - - - 2c12627c by Ryan Scott at 2022-03-28T19:24:04-04:00 Consistently attach SrcSpans to sub-expressions in TH splices Before, `GHC.ThToHs` was very inconsistent about where various sub-expressions would get the same `SrcSpan` from the original TH splice location or just a generic `noLoc` `SrcSpan`. I have ripped out all uses of `noLoc` in favor of the former instead, and I have added a `Note [Source locations within TH splices]` to officially enshrine this design choice. Fixes #21299. - - - - - 789add55 by Zubin Duggal at 2022-03-29T13:07:22-04:00 Fix all invalid haddock comments in the compiler Fixes #20935 and #20924 - - - - - 967dad03 by Zubin Duggal at 2022-03-29T13:07:22-04:00 hadrian: Build lib:GHC with -haddock and -Winvalid-haddock (#21273) - - - - - ad09a5f7 by sheaf at 2022-03-29T13:08:05-04:00 Hadrian: make DDEBUG separate from debugged RTS This patchs separates whether -DDEBUG is enabled (i.e. whether debug assertions are enabled) from whether we are using the debugged RTS (i.e. GhcDebugged = YES). This means that we properly skip tests which have been marked with `when(compiler_debugged(), skip)`. Fixes #21113, #21153 and #21234 - - - - - 840a6811 by Matthew Pickering at 2022-03-29T13:08:42-04:00 RTS: Zero gc_cpu_start and gc_cpu_end after accounting When passed a combination of `-N` and `-qn` options the cpu time for garbage collection was being vastly overcounted because the counters were not being zeroed appropiately. When -qn1 is passed, only 1 of the N avaiable GC threads is chosen to perform work, the rest are idle. At the end of the GC period, stat_endGC traverses all the GC threads and adds up the elapsed time from each of them. For threads which didn't participate in this GC, the value of the cpu time should be zero, but before this patch, the counters were not zeroed and hence we would count the same elapsed time on many subsequent iterations (until the thread participated in a GC again). The most direct way to zero these fields is to do so immediately after the value is added into the global counter, after which point they are never used again. We also tried another approach where we would zero the counter in yieldCapability but there are some (undiagnosed) siations where a capbility would not pass through yieldCapability before the GC ended and the same double counting problem would occur. Fixes #21082 - - - - - dda46e2d by Matthew Pickering at 2022-03-29T13:09:18-04:00 Add test for T21306 Fixes #21306 - - - - - f07c7766 by Jakob Brünker at 2022-03-30T03:10:33-04:00 Give parsing plugins access to errors Previously, when the parser produced non-fatal errors (i.e. it produced errors but the 'PState' is 'POk'), compilation would be aborted before the 'parsedResultAction' of any plugin was invoked. This commit changes that, so that such that 'parsedResultAction' gets collections of warnings and errors as argument, and must return them after potentially modifying them. Closes #20803 - - - - - e5dfde75 by Ben Gamari at 2022-03-30T03:11:10-04:00 Fix reference to Note [FunBind vs PatBind] This Note was renamed in 2535a6716202253df74d8190b028f85cc6d21b72 yet this occurrence was not updated. - - - - - 21894a63 by Krzysztof Gogolewski at 2022-03-30T03:11:45-04:00 Refactor: make primtypes independent of PrimReps Previously, 'pcPrimTyCon', the function used to define a primitive type, was taking a PrimRep, only to convert it to a RuntimeRep. Now it takes a RuntimeRep directly. Moved primRepToRuntimeRep to GHC.Types.RepType. It is now located next to its inverse function runtimeRepPrimRep. Now GHC.Builtin.Types.Prim no longer mentions PrimRep, and GHC.Types.RepType no longer imports GHC.Builtin.Types.Prim. Removed unused functions `primRepsToRuntimeRep` and `mkTupleRep`. Removed Note [PrimRep and kindPrimRep] - it was never referenced, didn't belong to Types.Prim, and Note [Getting from RuntimeRep to PrimRep] is more comprehensive. - - - - - 43da2963 by Matthew Pickering at 2022-03-30T09:55:49+01:00 Fix mention of non-existent "rehydrateIface" function [skip ci] Fixes #21303 - - - - - 6793a20f by gershomb at 2022-04-01T10:33:46+01:00 Remove wrong claim about naturality law. This docs change removes a longstanding confusion in the Traversable docs. The docs say "(The naturality law is implied by parametricity and thus so is the purity law [1, p15].)". However if one reads the reference a different "natural" law is implied by parametricity. The naturality law given as a law here is imposed. Further, the reference gives examples which violate both laws -- so they cannot be implied by parametricity. This PR just removes the wrong claim. - - - - - 5beeff46 by Ben Gamari at 2022-04-01T10:34:39+01:00 Refactor handling of global initializers GHC uses global initializers for a number of things including cost-center registration, info-table provenance registration, and setup of foreign exports. Previously, the global initializer arrays which referenced these initializers would live in the object file of the C stub, which would then be merged into the main object file of the module. Unfortunately, this approach is no longer tenable with the move to Clang/LLVM on Windows (see #21019). Specifically, lld's PE backend does not support object merging (that is, the -r flag). Instead we are now rather packaging a module's object files into a static library. However, this is problematic in the case of initializers as there are no references to the C stub object in the archive, meaning that the linker may drop the object from the final link. This patch refactors our handling of global initializers to instead place initializer arrays within the object file of the module to which they belong. We do this by introducing a Cmm data declaration containing the initializer array in the module's Cmm stream. While the initializer functions themselves remain in separate C stub objects, the reference from the module's object ensures that they are not dropped from the final link. In service of #21068. - - - - - 3e6fe71b by Matthew Pickering at 2022-04-01T10:35:41+01:00 Fix remaining issues in eventlog types (gen_event_types.py) * The size of End concurrent mark phase looks wrong and, it used to be 4 and now it's 0. * The size of Task create is wrong, used to be 18 and now 14. * The event ticky-ticky entry counter begin sample has the wrong name * The event ticky-ticky entry counter being sample has the wrong size, was 0 now 32. Closes #21070 - - - - - 7847f47a by Ben Gamari at 2022-04-01T10:35:41+01:00 users-guide: Fix a few small issues in eventlog format descriptions The CONC_MARK_END event description didn't mention its payload. Clarify the meaning of the CREATE_TASK's payload. - - - - - acfd5a4c by Matthew Pickering at 2022-04-01T10:35:53+01:00 ci: Regenerate jobs.yaml It seems I forgot to update this to reflect the current state of gen_ci.hs - - - - - a952dd80 by Matthew Pickering at 2022-04-01T10:35:59+01:00 ci: Attempt to fix windows cache issues It appears that running the script directly does nothing (no info is printed about saving the cache). - - - - - fb65e6e3 by Adrian Ratiu at 2022-04-01T10:49:52+01:00 fp_prog_ar.m4: take AR var into consideration In ChromeOS and Gentoo we want the ability to use LLVM ar instead of GNU ar even though both are installed, thus we pass (for eg) AR=llvm-ar to configure. Unfortunately GNU ar always gets picked regardless of the AR setting because the check does not consider the AR var when setting fp_prog_ar, hence this fix. - - - - - 1daaefdf by Greg Steuck at 2022-04-01T10:50:16+01:00 T13366 requires c++ & c++abi libraries on OpenBSD Fixes this failure: =====> 1 of 1 [0, 0, 0] T13366(normal) 1 of 1 [0, 0, 0] Compile failed (exit code 1) errors were: <no location info>: error: user specified .o/.so/.DLL could not be loaded (File not found) Whilst trying to load: (dynamic) stdc++ Additional directories searched: (none) *** unexpected failure for T13366(normal) - - - - - 18e6c85b by Jakob Bruenker at 2022-04-01T10:54:28+01:00 new datatypes for parsedResultAction Previously, the warnings and errors were given and returned as a tuple (Messages PsWarnings, Messages PsErrors). Now, it's just PsMessages. This, together with the HsParsedModule the parser plugin gets and returns, has been wrapped up as ParsedResult. - - - - - 9727e592 by Morrow at 2022-04-01T10:55:12+01:00 Clarify that runghc interprets the input program - - - - - f589dea3 by sheaf at 2022-04-01T10:59:58+01:00 Unify RuntimeRep arguments in ty_co_match The `ty_co_match` function ignored the implicit RuntimeRep coercions that occur in a `FunCo`. Even though a comment explained that this should be fine, #21205 showed that it could result in discarding a RuntimeRep coercion, and thus discarding an important cast entirely. With this patch, we first match the kinds in `ty_co_match`. Fixes #21205 ------------------------- Metric Increase: T12227 T18223 ------------------------- - - - - - 6f4dc372 by Andreas Klebinger at 2022-04-01T11:01:35+01:00 Export MutableByteArray from Data.Array.Byte This implements CLC proposal #49 - - - - - 5df9f5e7 by ARATA Mizuki at 2022-04-01T11:02:35+01:00 Add test cases for #20640 Closes #20640 - - - - - 8334ff9e by Krzysztof Gogolewski at 2022-04-01T11:03:16+01:00 Minor cleanup - Remove unused functions exprToCoercion_maybe, applyTypeToArg, typeMonoPrimRep_maybe, runtimeRepMonoPrimRep_maybe. - Replace orValid with a simpler check - Use splitAtList in applyTysX - Remove calls to extra_clean in the testsuite; it does not do anything. Metric Decrease: T18223 - - - - - b2785cfc by Eric Lindblad at 2022-04-01T11:04:07+01:00 hadrian typos - - - - - 418e6fab by Eric Lindblad at 2022-04-01T11:04:12+01:00 two typos - - - - - dd7c7c99 by Phil de Joux at 2022-04-01T11:04:56+01:00 Add tests and docs on plugin args and order. - - - - - 3e209a62 by MaxHearnden at 2022-04-01T11:05:19+01:00 Change may not to might not - - - - - b84380d3 by Matthew Pickering at 2022-04-01T11:07:27+01:00 hadrian: Remove linters-common from bindist Zubin observed that the bindists contains the utility library linters-common. There are two options: 1. Make sure only the right files are added into the bindist.. a bit tricky due to the non-trivial structure of the lib directory. 2. Remove the bad files once they get copied in.. a bit easier So I went for option 2 but we perhaps should go for option 1 in the future. Fixes #21203 - - - - - ba9904c1 by Zubin Duggal at 2022-04-01T11:07:31+01:00 hadrian: allow testing linters with out of tree compilers - - - - - 26547759 by Matthew Pickering at 2022-04-01T11:07:35+01:00 hadrian: Introduce CheckProgram datatype to replace a 7-tuple - - - - - df65d732 by Jakob Bruenker at 2022-04-01T11:08:28+01:00 Fix panic when pretty printing HsCmdLam When pretty printing a HsCmdLam with more than one argument, GHC panicked because of a missing case. This fixes that. Closes #21300 - - - - - ad6cd165 by John Ericson at 2022-04-01T11:10:06+01:00 hadrian: Remove vestigial -this-unit-id support check This has been dead code since 400ead81e80f66ad7b1260b11b2a92f25ccc3e5a. - - - - - 8ca7ab81 by Matthew Pickering at 2022-04-01T11:10:23+01:00 hadrian: Fix race involving empty package databases There was a small chance of a race occuring between the small window of 1. The first package (.conf) file get written into the database 2. hadrian calling "ghc-pkg recache" to refresh the package.conf file In this window the package database would contain rts.conf but not a package.cache file, and therefore if ghc was invoked it would error because it was missing. To solve this we call "ghc-pkg recache" at when the database is created by shake by writing the stamp file into the database folder. This also creates the package.cache file and so avoids the possibility of this race. - - - - - cc4ec64b by Matthew Pickering at 2022-04-01T11:11:05+01:00 hadrian: Add assertion that in/out tree args are the same There have been a few instances where this calculation was incorrect, so we add a non-terminal assertion when now checks they the two computations indeed compute the same thing. Fixes #21285 - - - - - 691508d8 by Matthew Pickering at 2022-04-01T11:13:10+01:00 hlint: Ignore suggestions in generated HaddockLex file With the make build system this file ends up in the compiler/ subdirectory so is linted. With hadrian, the file ends up in _build so it's not linted. Fixes #21313 - - - - - f8f152e7 by Krzysztof Gogolewski at 2022-04-01T11:14:08+01:00 Change GHC.Prim to GHC.Exts in docs and tests Users are supposed to import GHC.Exts rather than GHC.Prim. Part of #18749. - - - - - f8fc6d2e by Matthew Pickering at 2022-04-01T11:15:24+01:00 driver: Improve -Wunused-packages error message (and simplify implementation) In the past I improved the part of -Wunused-packages which found which packages were used. Now I improve the part which detects which ones were specified. The key innovation is to use the explicitUnits field from UnitState which has the result of resolving the package flags, so we don't need to mess about with the flag arguments from DynFlags anymore. The output now always includes the package name and version (and the flag which exposed it). ``` The following packages were specified via -package or -package-id flags, but were not needed for compilation: - bytestring-0.11.2.0 (exposed by flag -package bytestring) - ghc-9.3 (exposed by flag -package ghc) - process-1.6.13.2 (exposed by flag -package process) ``` Fixes #21307 - - - - - 5e5a12d9 by Matthew Pickering at 2022-04-01T11:15:32+01:00 driver: In oneshot mode, look for interface files in hidir How things should work: * -i is the search path for source files * -hidir explicitly sets the search path for interface files and the output location for interface files. * -odir sets the search path and output location for object files. Before in one shot mode we would look for the interface file in the search locations given by `-i`, but then set the path to be in the `hidir`, so in unusual situations the finder could find an interface file in the `-i` dir but later fail because it tried to read the interface file from the `-hidir`. A bug identified by #20569 - - - - - 950f58e7 by Matthew Pickering at 2022-04-01T11:15:36+01:00 docs: Update documentation interaction of search path, -hidir and -c mode. As noted in #20569 the documentation for search path was wrong because it seemed to indicate that `-i` dirs were important when looking for interface files in `-c` mode, but they are not important if `-hidir` is set. Fixes #20569 - - - - - d85c7dcb by sheaf at 2022-04-01T11:17:56+01:00 Keep track of promotion ticks in HsOpTy This patch adds a PromotionFlag field to HsOpTy, which is used in pretty-printing and when determining whether to emit warnings with -fwarn-unticked-promoted-constructors. This allows us to correctly report tick-related warnings for things like: type A = Int : '[] type B = [Int, Bool] Updates haddock submodule Fixes #19984 - - - - - 32070e6c by Jakob Bruenker at 2022-04-01T20:31:08+02:00 Implement \cases (Proposal 302) This commit implements proposal 302: \cases - Multi-way lambda expressions. This adds a new expression heralded by \cases, which works exactly like \case, but can match multiple apats instead of a single pat. Updates submodule haddock to support the ITlcases token. Closes #20768 - - - - - c6f77f39 by sheaf at 2022-04-01T20:33:05+02:00 Add a regression test for #21323 This bug was fixed at some point between GHC 9.0 and GHC 9.2; this patch simply adds a regression test. - - - - - 3596684e by Jakob Bruenker at 2022-04-01T20:33:05+02:00 Fix error when using empty case in arrow notation It was previously not possible to use -XEmptyCase in Arrow notation, since GHC would print "Exception: foldb of empty list". This is now fixed. Closes #21301 - - - - - 9a325b59 by Ben Gamari at 2022-04-01T20:33:05+02:00 users-guide: Fix various markup issues - - - - - aefb1e6d by sheaf at 2022-04-01T20:36:01+02:00 Ensure implicit parameters are lifted `tcExpr` typechecked implicit parameters by introducing a metavariable of kind `TYPE kappa`, without enforcing that `kappa ~ LiftedRep`. This patch instead creates a metavariable of kind `Type`. Fixes #21327 - - - - - ed62dc66 by Ben Gamari at 2022-04-05T11:44:51-04:00 gitlab-ci: Disable cabal-install store caching on Windows For reasons that remain a mystery, cabal-install seems to consistently corrupt its cache on Windows. Disable caching for now. Works around #21347. - - - - - 5ece5c5a by Ryan Scott at 2022-04-06T13:00:51-04:00 Add /linters/*/dist-install/ to .gitignore Fixes #21335. [ci skip] - - - - - 410c76ee by Ben Gamari at 2022-04-06T13:01:28-04:00 Use static archives as an alternative to object merging Unfortunately, `lld`'s COFF backend does not currently support object merging. With ld.bfd having broken support for high image-load base addresses, it's necessary to find an alternative. Here I introduce support in the driver for generating static archives, which we use on Windows instead of object merging. Closes #21068. - - - - - 400666c8 by Ben Gamari at 2022-04-06T13:01:28-04:00 rts/linker: Catch archives masquerading as object files Check the file's header to catch static archive bearing the `.o` extension, as may happen on Windows after the Clang refactoring. See #21068 - - - - - 694d39f0 by Ben Gamari at 2022-04-06T13:01:28-04:00 driver: Make object merging optional On Windows we don't have a linker which supports object joining (i.e. the `-r` flag). Consequently, `-pgmlm` is now a `Maybe`. See #21068. - - - - - 41fcb5cd by Ben Gamari at 2022-04-06T13:01:28-04:00 hadrian: Refactor handling of ar flags Previously the setup was quite fragile as it had to assume which arguments were file arguments and which were flags. - - - - - 3ac80a86 by Ben Gamari at 2022-04-06T13:01:28-04:00 hadrian: Produce ar archives with L modifier on Windows Since object files may in fact be archive files, we must ensure that their contents are merged rather than constructing an archive-of-an-archive. See #21068. - - - - - 295c35c5 by Ben Gamari at 2022-04-06T13:01:28-04:00 Add a Note describing lack of object merging on Windows See #21068. - - - - - d2ae0a3a by Ben Gamari at 2022-04-06T13:01:28-04:00 Build ar archives with -L when "joining" objects Since there may be .o files which are in fact archives. - - - - - babb47d2 by Zubin Duggal at 2022-04-06T13:02:04-04:00 Add warnings for file header pragmas that appear in the body of a module (#20385) Once we are done parsing the header of a module to obtain the options, we look through the rest of the tokens in order to determine if they contain any misplaced file header pragmas that would usually be ignored, potentially resulting in bad error messages. The warnings are reported immediately so that later errors don't shadow over potentially helpful warnings. Metric Increase: T13719 - - - - - 3f31825b by Ben Gamari at 2022-04-06T13:02:40-04:00 rts/AdjustorPool: Generalize to allow arbitrary contexts Unfortunately the i386 adjustor logic needs this. - - - - - 9b645ee1 by Ben Gamari at 2022-04-06T13:02:40-04:00 adjustors/i386: Use AdjustorPool In !7511 (closed) I introduced a new allocator for adjustors, AdjustorPool, which eliminates the address space fragmentation issues which adjustors can introduce. In that work I focused on amd64 since that was the platform where I observed issues. However, in #21132 we noted that the size of adjustors is also a cause of CI fragility on i386. In this MR I port i386 to use AdjustorPool. Sadly the complexity of the i386 adjustor code does cause require a bit of generalization which makes the code a bit more opaque but such is the world. Closes #21132. - - - - - c657a616 by Ben Gamari at 2022-04-06T13:03:16-04:00 hadrian: Clean up flavour transformer definitions Previously the `ipe` and `omit_pragmas` transformers were hackily defined using the textual key-value syntax. Fix this. - - - - - 9ce273b9 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab-ci: Drop dead HACKAGE_INDEX_STATE variable - - - - - 01845375 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab/darwin: Factor out bindists This makes it a bit easier to bump them. - - - - - c41c478e by Ben Gamari at 2022-04-06T13:03:16-04:00 Fix a few new warnings when booting with GHC 9.2.2 -Wuni-incomplete-patterns and apparent improvements in the pattern match checker surfaced these. - - - - - 6563cd24 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab-ci: Bump bootstrap compiler to 9.2.2 This is necessary to build recent `text` commits. Bumps Hackage index state for a hashable which builds with GHC 9.2. - - - - - a62e983e by Ben Gamari at 2022-04-06T13:03:16-04:00 Bump text submodule to current `master` Addresses #21295. - - - - - 88d61031 by Vladislav Zavialov at 2022-04-06T13:03:53-04:00 Refactor OutputableBndrFlag instances The matching on GhcPass introduced by 95275a5f25a is not necessary. This patch reverts it to make the code simpler. - - - - - f601f002 by GHC GitLab CI at 2022-04-06T15:18:26-04:00 rts: Eliminate use of nested functions This is a gcc-specific extension. - - - - - d4c5f29c by Ben Gamari at 2022-04-06T15:18:26-04:00 driver: Drop hacks surrounding windres invocation Drop hack for #1828, among others as they appear to be unnecessary when using `llvm-windres`. - - - - - 6be2c5a7 by Ben Gamari at 2022-04-06T15:18:26-04:00 Windows/Clang: Build system adaptation * Bump win32-tarballs to 0.7 * Move Windows toolchain autoconf logic into separate file * Use clang and LLVM utilities as described in #21019 * Disable object merging as lld doesn't support -r * Drop --oformat=pe-bigobj-x86-64 arguments from ld flags as LLD detects that the output is large on its own. * Drop gcc wrapper since Clang finds its root fine on its own. - - - - - c6fb7aff by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Test that we can build bigobj PE objects - - - - - 79851c07 by Ben Gamari at 2022-04-06T15:18:26-04:00 Drop -static-libgcc This flag is not applicable when Clang is used. - - - - - 1f8a8264 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Port T16514 to C Previously this test was C++ which made it a bit of a portability problem. - - - - - d7e650d1 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark Windows as a libc++ platform - - - - - d7886c46 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark T9405 as fixed on Windows I have not seen it fail since moving to clang. Closes #12714. - - - - - 4c3fbb4e by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark FloatFnInverses as fixed The new toolchain has fixed it. Closes #15670. - - - - - 402c36ba by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Rework T13606 to avoid gcc dependence Previously we used libgcc_s's import library in T13606. However, now that we ship with clang we no longer have this library. Instead we now use gdi32. - - - - - 9934ad54 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Clean up tests depending on C++ std lib - - - - - 12fcdef2 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Split T13366 into two tests Split up the C and C++ uses since the latter is significantly more platform-dependent. - - - - - 3c08a198 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Fix mk-big-obj I'm a bit unclear on how this previously worked as it attempted to build an executable without defining `main`. - - - - - 7e97cc23 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Provide module definitions in T10955dyn Otherwise the linker will export all symbols, including those provided by the RTS, from the produced shared object. Consequently, attempting to link against multiple objects simultaneously will cause the linker to complain that RTS symbols are multiply defined. Avoid this by limiting the DLL exports with a module definition file. - - - - - 9a248afa by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark test-defaulting-plugin as fragile on Windows Currently llvm-ar does not handle long file paths, resulting in occassional failures of these tests and #21293. - - - - - 39371aa4 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite/driver: Treat framework failures of fragile tests as non-fatal Previously we would report framework failures of tests marked as fragile as failures. Now we rather treat them as fragile test failures, which are not fatal to the testsuite run. Noticed while investigating #21293. - - - - - a1e6661d by Ben Gamari at 2022-04-06T15:18:32-04:00 Bump Cabal submodule - Disable support for library-for-ghci on Windows as described in #21068. - Teach Cabal to use `ar -L` when available - - - - - f7b0f63c by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump process submodule Fixes missing TEST_CC_OPTS in testsuite tests. - - - - - 109cee19 by Ben Gamari at 2022-04-06T15:18:37-04:00 hadrian: Disable ghci libraries when object merging is not available - - - - - c22fba5c by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump bytestring submodule - - - - - 6e2744cc by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump text submodule - - - - - 32333747 by Ben Gamari at 2022-04-06T15:18:37-04:00 hadrian: Build wrappers using ghc rather than cc - - - - - 59787ba5 by Ben Gamari at 2022-04-06T15:18:37-04:00 linker/PEi386: More descriptive error message - - - - - 5e3c3c4f by Ben Gamari at 2022-04-06T15:18:37-04:00 testsuite: Mark TH_spliceE5_prof as unbroken on Windows It was previously failing due to #18721 and now passes with the new toolchain. Closes #18721. - - - - - 9eb0a9d9 by GHC GitLab CI at 2022-04-06T15:23:48-04:00 rts/PEi386: Move some debugging output to -DL - - - - - ce874595 by Ben Gamari at 2022-04-06T15:24:01-04:00 nativeGen/x86: Use %rip-relative addressing On Windows with high-entropy ASLR we must use %rip-relative addressing to avoid overflowing the signed 32-bit immediate size of x86-64. Since %rip-relative addressing comes essentially for free and can make linking significantly easier, we use it on all platforms. - - - - - 52deee64 by Ben Gamari at 2022-04-06T15:24:01-04:00 Generate LEA for label expressions - - - - - 105a0056 by Ben Gamari at 2022-04-06T15:24:01-04:00 Refactor is32BitLit to take Platform rather than Bool - - - - - ec4526b5 by Ben Gamari at 2022-04-06T15:24:01-04:00 Don't assume that labels are 32-bit on Windows - - - - - ffdbe457 by Ben Gamari at 2022-04-06T15:24:01-04:00 nativeGen: Note signed-extended nature of MOV - - - - - bfb79697 by Ben Gamari at 2022-04-06T15:30:56-04:00 rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h It's easier to ensure that this is included first than Rts.h - - - - - 5ad143fd by Ben Gamari at 2022-04-06T15:30:56-04:00 rts: Fix various #include issues This fixes various violations of the newly-added RTS includes linter. - - - - - a59a66a8 by Ben Gamari at 2022-04-06T15:30:56-04:00 testsuite: Lint RTS #includes Verifies two important properties of #includes in the RTS: * That system headers don't appear inside of a `<BeginPrivate.h>` block as this can hide system library symbols, resulting in very hard-to-diagnose linker errors * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO is set correctly before system headers are included. - - - - - 42bf7528 by GHC GitLab CI at 2022-04-06T16:25:04-04:00 rts/PEi386: Fix memory leak Previously we would leak the section information of the `.bss` section. - - - - - d286a55c by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Preserve information about symbol types As noted in #20978, the linker would previously handle overflowed relocations by creating a jump island. While this is fine in the case of code symbols, it's very much not okay in the case of data symbols. To fix this we must keep track of whether each symbol is code or data and relocate them appropriately. This patch takes the first step in this direction, adding a symbol type field to the linker's symbol table. It doesn't yet change relocation behavior to take advantage of this knowledge. Fixes #20978. - - - - - e689e9d5 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Fix relocation overflow behavior This fixes handling of overflowed relocations on PEi386 targets: * Refuse to create jump islands for relocations of data symbols * Correctly handle the `__imp___acrt_iob_func` symbol, which is an new type of symbol: `SYM_TYPE_INDIRECT_DATA` - - - - - 655e7d8f by GHC GitLab CI at 2022-04-06T16:25:25-04:00 rts: Mark anything that might have an info table as data Tables-next-to-code mandates that we treat symbols with info tables like data since we cannot relocate them using a jump island. See #20983. - - - - - 7e8cc293 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Rework linker This is a significant rework of the PEi386 linker, making the linker compatible with high image base addresses. Specifically, we now use the m32 allocator instead of `HeapAllocate`. In addition I found a number of latent bugs in our handling of import libraries and relocations. I've added quite a few comments describing what I've learned about Windows import libraries while fixing these. Thanks to Tamar Christina (@Phyx) for providing the address space search logic, countless hours of help while debugging, and his boundless Windows knowledge. Co-Authored-By: Tamar Christina <tamar at zhox.com> - - - - - ff625218 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Move allocateBytes to MMap.c - - - - - f562b5ca by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Avoid accidentally-quadratic allocation cost We now preserve the address that we last mapped, allowing us to resume our search and avoiding quadratic allocation costs. This fixes the runtime of T10296a, which allocates many adjustors. - - - - - 3247b7db by Ben Gamari at 2022-04-06T16:25:25-04:00 Move msvcrt dep out of base - - - - - fa404335 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: More descriptive debug output - - - - - 140f338f by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PathUtils: Define pathprintf in terms of snwprintf on Windows swprintf deviates from usual `snprintf` semantics in that it does not guarantee reasonable behavior when the buffer is NULL (that is, returning the number of bytes that would have been emitted). - - - - - eb60565b by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Report archive member index - - - - - 209fd61b by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Split up object resolution and initialization Previously the RTS linker would call initializers during the "resolve" phase of linking. However, this is problematic in the case of cyclic dependencies between objects. In particular, consider the case where we have a situation where a static library contains a set of recursive objects: * object A has depends upon symbols in object B * object B has an initializer that depends upon object A * we try to load object A The linker would previously: 1. start resolving object A 2. encounter the reference to object B, loading it resolve object B 3. run object B's initializer 4. the initializer will attempt to call into object A, which hasn't been fully resolved (and therefore protected) Fix this by moving constructor execution to a new linking phase, which follows resolution. Fix #21253. - - - - - 8e8a1021 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker/LoadArchive: Fix leaking file handle Previously `isArchive` could leak a `FILE` handle if the `fread` returned a short read. - - - - - 429ea5d9 by sheaf at 2022-04-07T07:55:52-04:00 Remove Fun pattern from Typeable COMPLETE set GHC merge request !963 improved warnings in the presence of COMPLETE annotations. This allows the removal of the Fun pattern from the complete set. Doing so expectedly causes some redundant pattern match warnings, in particular in GHC.Utils.Binary.Typeable and Data.Binary.Class from the binary library; this commit addresses that. Updates binary submodule Fixes #20230 - - - - - 54b18824 by Alan Zimmerman at 2022-04-07T07:56:28-04:00 EPA: handling of con_bndrs in mkGadtDecl Get rid of unnnecessary case clause that always matched. Closes #20558 - - - - - 9c838429 by Ben Gamari at 2022-04-07T09:38:53-04:00 testsuite: Mark T10420 as broken on Windows Due to #21322. - - - - - 50739d2b by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Refactor and fix printf attributes on clang Clang on Windows does not understand the `gnu_printf` attribute; use `printf` instead. - - - - - 9eeaeca4 by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Add missing newline in error message - - - - - fcef9a17 by Ben Gamari at 2022-04-07T09:42:42-04:00 configure: Make environ decl check more robust Some platforms (e.g. Windows/clang64) declare `environ` in `<stdlib.h>`, not `<unistd.h>` - - - - - 8162b4f3 by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Adjust RTS symbol table on Windows for ucrt - - - - - 633280d7 by Ben Gamari at 2022-04-07T09:43:21-04:00 testsuite: Fix exit code of bounds checking tests on Windows `abort` exits with 255, not 134, on Windows. - - - - - cab4dc01 by Ben Gamari at 2022-04-07T09:43:31-04:00 testsuite: Update expected output from T5435 tests on Windows I'll admit, I don't currently see *why* this output is reordered but it is a fairly benign difference and I'm out of time to investigate. - - - - - edf5134e by Ben Gamari at 2022-04-07T09:43:35-04:00 testsuite: Mark T20918 as broken on Windows Our toolchain on Windows doesn't currently have Windows support. - - - - - d0ddeff3 by Ben Gamari at 2022-04-07T09:43:39-04:00 testsuite: Mark linker unloading tests as broken on Windows Due to #20354. We will need to investigate this prior the release. - - - - - 5a86da2b by Ben Gamari at 2022-04-07T09:43:43-04:00 testsuite: Mark T9405 as broken on Windows Due to #21361. - - - - - 4aa86dcf by Ben Gamari at 2022-04-07T09:44:18-04:00 Merge branches 'wip/windows-high-codegen', 'wip/windows-high-linker', 'wip/windows-clang-2' and 'wip/lint-rts-includes' into wip/windows-clang-join - - - - - 7206f055 by Ben Gamari at 2022-04-07T09:45:07-04:00 rts/CloneStack: Ensure that Rts.h is #included first As is necessary on Windows. - - - - - 9cfcb27b by Ben Gamari at 2022-04-07T09:45:07-04:00 rts: Fallback to ucrtbase not msvcrt Since we have switched to Clang the toolchain now links against ucrt rather than msvcrt. - - - - - d6665d85 by Ben Gamari at 2022-04-07T09:46:25-04:00 Accept spurious perf test shifts on Windows Metric Decrease: T16875 Metric Increase: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 83363c8b by Simon Peyton Jones at 2022-04-07T12:57:21-04:00 Use prepareBinding in tryCastWorkerWrapper As #21144 showed, tryCastWorkerWrapper was calling prepareRhs, and then unconditionally floating the bindings, without the checks of doFloatFromRhs. That led to floating an unlifted binding into a Rec group. This patch refactors prepareBinding to make these checks, and do them uniformly across all calls. A nice improvement. Other changes * Instead of passing around a RecFlag and a TopLevelFlag; and sometimes a (Maybe SimplCont) for join points, define a new Simplifier-specific data type BindContext: data BindContext = BC_Let TopLevelFlag RecFlag | BC_Join SimplCont and use it consistently. * Kill off completeNonRecX by inlining it. It was only called in one place. * Add a wrapper simplImpRules for simplRules. Compile time on T9630 drops by 4.7%; little else changes. Metric Decrease: T9630 - - - - - 02279a9c by Vladislav Zavialov at 2022-04-07T12:57:59-04:00 Rename [] to List (#21294) This patch implements a small part of GHC Proposal #475. The key change is in GHC.Types: - data [] a = [] | a : [a] + data List a = [] | a : List a And the rest of the patch makes sure that List is pretty-printed as [] in various contexts. Updates the haddock submodule. - - - - - 08480d2a by Simon Peyton Jones at 2022-04-07T12:58:36-04:00 Fix the free-var test in validDerivPred The free-var test (now documented as (VD3)) was too narrow, affecting only class predicates. #21302 demonstrated that this wasn't enough! Fixes #21302. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - b3d6d23d by Andreas Klebinger at 2022-04-07T12:59:12-04:00 Properly explain where INLINE pragmas can appear. Fixes #20676 - - - - - 23ef62b3 by Ben Gamari at 2022-04-07T14:28:28-04:00 rts: Fix off-by-one in snwprintf usage - - - - - b2dbcc7d by Simon Jakobi at 2022-04-08T03:00:38-04:00 Improve seq[D]VarSet Previously, the use of size[D]VarSet would involve a traversal of the entire underlying IntMap. Since IntMaps are already spine-strict, this is unnecessary. - - - - - 64ac20a7 by sheaf at 2022-04-08T03:01:16-04:00 Add test for #21338 This no-skolem-info bug was fixed by the no-skolem-info patch that will be part of GHC 9.4. This patch adds a regression test for the issue reported in issue #21338. Fixes #21338. - - - - - c32c4db6 by Ben Gamari at 2022-04-08T03:01:53-04:00 rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h It's easier to ensure that this is included first than Rts.h - - - - - 56f85d62 by Ben Gamari at 2022-04-08T03:01:53-04:00 rts: Fix various #include issues This fixes various violations of the newly-added RTS includes linter. - - - - - cb1f31f5 by Ben Gamari at 2022-04-08T03:01:53-04:00 testsuite: Lint RTS #includes Verifies two important properties of #includes in the RTS: * That system headers don't appear inside of a `<BeginPrivate.h>` block as this can hide system library symbols, resulting in very hard-to-diagnose linker errors * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO is set correctly before system headers are included. - - - - - c44432db by Krzysztof Gogolewski at 2022-04-08T03:02:29-04:00 Fixes to 9.4 release notes - Mention -Wforall-identifier - Improve description of withDict - Fix formatting - - - - - 777365f1 by sheaf at 2022-04-08T09:43:35-04:00 Correctly report SrcLoc of redundant constraints We were accidentally dropping the source location information in certain circumstances when reporting redundant constraints. This patch makes sure that we set the TcLclEnv correctly before reporting the warning. Fixes #21315 - - - - - af300a43 by Vladislav Zavialov at 2022-04-08T09:44:11-04:00 Reject illegal quote mark in data con declarations (#17865) * Non-fatal (i.e. recoverable) parse error * Checking infix constructors * Extended the regression test - - - - - 56254e6b by Ben Gamari at 2022-04-08T09:59:46-04:00 Merge remote-tracking branch 'origin/master' - - - - - 6e2c3b7c by Matthew Pickering at 2022-04-08T13:55:15-04:00 driver: Introduce HomeModInfoCache abstraction The HomeModInfoCache is a mutable cache which is updated incrementally as the driver completes, this makes it robust to exceptions including (SIGINT) The interface for the cache is described by the `HomeMOdInfoCache` data type: ``` data HomeModInfoCache = HomeModInfoCache { hmi_clearCache :: IO [HomeModInfo] , hmi_addToCache :: HomeModInfo -> IO () } ``` The first operation clears the cache and returns its contents. This is designed so it's harder to end up in situations where the cache is retained throughout the execution of upsweep. The second operation allows a module to be added to the cache. The one slightly nasty part is in `interpretBuildPlan` where we have to be careful to ensure that the cache writes happen: 1. In parralel 2. Before the executation continues after upsweep. This requires some simple, localised MVar wrangling. Fixes #20780 - - - - - 85f4a3c9 by Andreas Klebinger at 2022-04-08T13:55:50-04:00 Add flag -fprof-manual which controls if GHC should honour manual cost centres. This allows disabling of manual control centres in code a user doesn't control like libraries. Fixes #18867 - - - - - 3415981c by Vladislav Zavialov at 2022-04-08T13:56:27-04:00 HsUniToken for :: in GADT constructors (#19623) One more step towards the new design of EPA. Updates the haddock submodule. - - - - - 23f95735 by sheaf at 2022-04-08T13:57:07-04:00 Docs: datacon eta-expansion, rep-poly checks The existing notes weren't very clear on how the eta-expansion of data constructors that occurs in tcInferDataCon/dsConLike interacts with the representation polymorphism invariants. So we explain with a few more details how we ensure that the representation-polymorphic lambdas introduced by tcInferDataCon/dsConLike don't end up causing problems, by checking they are properly instantiated and then relying on the simple optimiser to perform beta reduction. A few additional changes: - ConLikeTc just take type variables instead of binders, as we never actually used the binders. - Removed the FRRApp constructor of FRROrigin; it was no longer used now that we use ExpectedFunTyOrigin. - Adds a bit of documentation to the constructors of ExpectedFunTyOrigin. - - - - - d4480490 by Matthew Pickering at 2022-04-08T13:57:43-04:00 ci: Replace "always" with "on_success" to stop build jobs running before hadrian-ghci has finished See https://docs.gitlab.com/ee/ci/yaml/#when * always means, always run not matter what * on_success means, run if the dependencies have built successfully - - - - - 0736e949 by Vladislav Zavialov at 2022-04-08T13:58:19-04:00 Disallow (->) as a data constructor name (#16999) The code was misusing isLexCon, which was never meant for validation. In fact, its documentation states the following: Use these functions to figure what kind of name a 'FastString' represents; these functions do /not/ check that the identifier is valid. Ha! This sign can't stop me because I can't read. The fix is to use okConOcc instead. The other checks (isTcOcc or isDataOcc) seem superfluous, so I also removed those. - - - - - e58d5eeb by Simon Peyton Jones at 2022-04-08T13:58:55-04:00 Tiny documentation wibble This commit commit 83363c8b04837ee871a304cf85207cf79b299fb0 Author: Simon Peyton Jones <simon.peytonjones at gmail.com> Date: Fri Mar 11 16:55:38 2022 +0000 Use prepareBinding in tryCastWorkerWrapper refactored completeNonRecX away, but left a Note referring to it. This MR fixes that Note. - - - - - 4bb00839 by Matthew Pickering at 2022-04-09T07:40:28-04:00 ci: Fix nightly head.hackage pipelines This also needs a corresponding commit to head.hackage, I also made the job explicitly depend on the fedora33 job so that it isn't blocked by a failing windows job, which causes docs-tarball to fail. - - - - - 3c48e12a by Matthew Pickering at 2022-04-09T07:40:28-04:00 ci: Remove doc-tarball dependency from perf and perf-nofib jobs These don't depend on the contents of the tarball so we can run them straight after the fedora33 job finishes. - - - - - 27362265 by Matthew Pickering at 2022-04-09T07:41:04-04:00 Bump deepseq to 1.4.7.0 Updates deepseq submodule Fixes #20653 - - - - - dcf30da8 by Joachim Breitner at 2022-04-09T13:02:19-04:00 Drop the app invariant previously, GHC had the "let/app-invariant" which said that the RHS of a let or the argument of an application must be of lifted type or ok for speculation. We want this on let to freely float them around, and we wanted that on app to freely convert between the two (e.g. in beta-reduction or inlining). However, the app invariant meant that simple code didn't stay simple and this got in the way of rules matching. By removing the app invariant, this thus fixes #20554. The new invariant is now called "let-can-float invariant", which is hopefully easier to guess its meaning correctly. Dropping the app invariant means that everywhere where we effectively do beta-reduction (in the two simplifiers, but also in `exprIsConApp_maybe` and other innocent looking places) we now have to check if the argument must be evaluated (unlifted and side-effecting), and analyses have to be adjusted to the new semantics of `App`. Also, `LetFloats` in the simplifier can now also carry such non-floating bindings. The fix for DmdAnal, refine by Sebastian, makes functions with unlifted arguments strict in these arguments, which changes some signatures. This causes some extra calls to `exprType` and `exprOkForSpeculation`, so some perf benchmarks regress a bit (while others improve). Metric Decrease: T9020 Metric Increase: LargeRecord T12545 T15164 T16577 T18223 T5642 T9961 Co-authored-by: Sebastian Graf <sebastian.graf at kit.edu> - - - - - 6c6c5379 by Philip Hazelden at 2022-04-09T13:02:59-04:00 Add functions traceWith, traceShowWith, traceEventWith. As discussed at https://github.com/haskell/core-libraries-committee/issues/36 - - - - - 8fafacf7 by Philip Hazelden at 2022-04-09T13:02:59-04:00 Add tests for several trace functions. - - - - - 20bbf3ac by Philip Hazelden at 2022-04-09T13:02:59-04:00 Update changelog. - - - - - 47d18b0b by Andreas Klebinger at 2022-04-09T13:03:35-04:00 Add regression test for #19569 - - - - - 5f8d6e65 by sheaf at 2022-04-09T13:04:14-04:00 Fix missing SymCo in pushCoercionIntoLambda There was a missing SymCo in pushCoercionIntoLambda. Currently this codepath is only used with rewrite rules, so this bug managed to slip by, but trying to use pushCoercionIntoLambda in other contexts revealed the bug. - - - - - 20eca489 by Vladislav Zavialov at 2022-04-09T13:04:50-04:00 Refactor: simplify lexing of the dot Before this patch, the lexer did a truly roundabout thing with the dot: 1. look up the varsym in reservedSymsFM and turn it into ITdot 2. under OverloadedRecordDot, turn it into ITvarsym 3. in varsym_(prefix|suffix|...) turn it into ITvarsym, ITdot, or ITproj, depending on extensions and whitespace Turns out, the last step is sufficient to handle the dot correctly. This patch removes the first two steps. - - - - - 5440f63e by Hécate Moonlight at 2022-04-12T11:11:06-04:00 Document that DuplicateRecordFields doesn't tolerates ambiguous fields Fix #19891 - - - - - 0090ad7b by Sebastian Graf at 2022-04-12T11:11:42-04:00 Eta reduction based on evaluation context (#21261) I completely rewrote our Notes surrounding eta-reduction. The new entry point is `Note [Eta reduction makes sense]`. Then I went on to extend the Simplifier to maintain an evaluation context in the form of a `SubDemand` inside a `SimplCont`. That `SubDemand` is useful for doing eta reduction according to `Note [Eta reduction based on evaluation context]`, which describes how Demand analysis, Simplifier and `tryEtaReduce` interact to facilitate eta reduction in more scenarios. Thus we fix #21261. ghc/alloc perf marginally improves (-0.0%). A medium-sized win is when compiling T3064 (-3%). It seems that haddock improves by 0.6% to 1.0%, too. Metric Decrease: T3064 - - - - - 4d2ee313 by Sebastian Graf at 2022-04-12T17:54:57+02:00 Specialising through specialised method calls (#19644) In #19644, we discovered that the ClassOp/DFun rules from Note [ClassOp/DFun selection] inhibit transitive specialisation in a scenario like ``` class C a where m :: Show b => a -> b -> ...; n :: ... instance C Int where m = ... -- $cm :: Show b => Int -> b -> ... f :: forall a b. (C a, Show b) => ... f $dC $dShow = ... m @a $dC @b $dShow ... main = ... f @Int @Bool ... ``` After we specialise `f` for `Int`, we'll see `m @a $dC @b $dShow` in the body of `$sf`. But before this patch, Specialise doesn't apply the ClassOp/DFun rule to rewrite to a call of the instance method for `C Int`, e.g., `$cm @Bool $dShow`. As a result, Specialise couldn't further specialise `$cm` for `Bool`. There's a better example in `Note [Specialisation modulo dictionary selectors]`. This patch enables proper Specialisation, as follows: 1. In the App case of `specExpr`, try to apply the CalssOp/DictSel rule on the head of the application 2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and `$dShow` in `bindAuxiliaryDict` NB: Without (2), (1) would be pointless, because `lookupRule` wouldn't be able to look into the RHS of `$dC` to see the DFun. (2) triggered #21332, because the Specialiser floats around dictionaries without accounting for them in the `SpecEnv`'s `InScopeSet`, triggering a panic when rewriting dictionary unfoldings. Fixes #19644 and #21332. - - - - - b06f4f47 by Sebastian Graf at 2022-04-12T17:54:58+02:00 Specialise: Check `typeDeterminesValue` before specialising on an interesting dictionary I extracted the checks from `Note [Type determines value]` into its own function, so that we share the logic properly. Then I made sure that we actually call `typeDeterminesValue` everywhere we check for `interestingDict`. - - - - - a42dbc55 by Matthew Pickering at 2022-04-13T06:24:52-04:00 Refine warning about defining rules in SAFE modules This change makes it clear that it's the definition rather than any usage which is a problem, and that rules defined in other modules will still be used to do rewrites. Fixes #20923 - - - - - df893f66 by Andreas Klebinger at 2022-04-14T08:18:37-04:00 StgLint: Lint constructor applications and strict workers for arity. This will mean T9208 when run with lint will return a lint error instead of resulting in a panic. Fixes #21117 - - - - - 426ec446 by sheaf at 2022-04-14T08:19:16-04:00 Hadrian: use a set to keep track of ways The order in which ways are provided doesn't matter, so we use a data structure with the appropriate semantics to represent ways. Fixes #21378 - - - - - 7c639b9a by Dylan Yudaken at 2022-04-15T13:55:59-04:00 Only enable PROF_SPIN in DEBUG - - - - - 96b9e5ea by Ben Gamari at 2022-04-15T13:56:34-04:00 testsuite: Add test for #21390 - - - - - d8392f6a by Ben Gamari at 2022-04-15T13:56:34-04:00 rts: Ensure that the interpreter doesn't disregard tags Previously the interpreter's handling of `RET_BCO` stack frames would throw away the tag of the returned closure. This resulted in #21390. - - - - - 83c67f76 by Alan Zimmerman at 2022-04-20T11:49:28-04:00 Add -dkeep-comments flag to keep comments in the parser This provides a way to set the Opt_KeepRawTokenStream from the command line, allowing exact print annotation users to see exactly what is produced for a given parsed file, when used in conjunction with -ddump-parsed-ast Discussed in #19706, but this commit does not close the issue. - - - - - a5ea65c9 by Krzysztof Gogolewski at 2022-04-20T11:50:04-04:00 Remove LevityInfo Every Id was storing a boolean whether it could be levity-polymorphic. This information is no longer needed since representation-checking has been moved to the typechecker. - - - - - 49bd7584 by Andreas Klebinger at 2022-04-20T11:50:39-04:00 Fix a shadowing issue in StgUnarise. For I assume performance reasons we don't record no-op replacements during unarise. This lead to problems with code like this: f = \(Eta_B0 :: VoidType) x1 x2 -> ... let foo = \(Eta_B0 :: LiftedType) -> g x y Eta_B0 in ... Here we would record the outer Eta_B0 as void rep, but would not shadow Eta_B0 inside `foo` because this arg is single-rep and so doesn't need to replaced. But this means when looking at occurence sites we would check the env and assume it's void rep based on the entry we made for the (no longer in scope) outer `Eta_B0`. Fixes #21396 and the ticket has a few more details. - - - - - 0c02c919 by Simon Peyton Jones at 2022-04-20T11:51:15-04:00 Fix substitution in bindAuxiliaryDict In GHC.Core.Opt.Specialise.bindAuxiliaryDict we were unnecessarily calling `extendInScope` to bring into scope variables that were /already/ in scope. Worse, GHC.Core.Subst.extendInScope strangely deleted the newly-in-scope variables from the substitution -- and that was fatal in #21391. I removed the redundant calls to extendInScope. More ambitiously, I changed GHC.Core.Subst.extendInScope (and cousins) to stop deleting variables from the substitution. I even changed the names of the function to extendSubstInScope (and cousins) and audited all the calls to check that deleting from the substitution was wrong. In fact there are very few such calls, and they are all about introducing a fresh non-in-scope variable. These are "OutIds"; it is utterly wrong to mess with the "InId" substitution. I have not added a Note, because I'm deleting wrong code, and it'd be distracting to document a bug. - - - - - 0481a6af by Cheng Shao at 2022-04-21T11:06:06+00:00 [ci skip] Drop outdated TODO in RtsAPI.c - - - - - 1e062a8a by Ben Gamari at 2022-04-22T02:12:59-04:00 rts: Introduce ip_STACK_FRAME While debugging it is very useful to be able to determine whether a given info table is a stack frame or not. We have spare bits in the closure flags array anyways, use one for this information. - - - - - 08a6a2ee by Ben Gamari at 2022-04-22T02:12:59-04:00 rts: Mark closureFlags array as const - - - - - 8f9b8282 by Krzysztof Gogolewski at 2022-04-22T02:13:35-04:00 Check for zero-bit types in sizeExpr Fixes #20940 Metric Decrease: T18698a - - - - - fcf22883 by Andreas Klebinger at 2022-04-22T02:14:10-04:00 Include the way string in the file name for dump files. This can be disabled by `-fno-dump-with-ways` if not desired. Finally we will be able to look at both profiled and non-profiled dumps when compiling with dump flags and we compile in both ways. - - - - - 252394ce by Bodigrim at 2022-04-22T02:14:48-04:00 Improve error messages from GHC.IO.Encoding.Failure - - - - - 250f57c1 by Bodigrim at 2022-04-22T02:14:48-04:00 Update test baselines to match new error messages from GHC.IO.Encoding.Failure - - - - - 5ac9b321 by Ben Gamari at 2022-04-22T02:15:25-04:00 get-win32-tarballs: Drop i686 architecture As of #18487 we no longer support 32-bit Windows. Fixes #21372. - - - - - dd5fecb0 by Ben Gamari at 2022-04-22T02:16:00-04:00 hadrian: Don't rely on xxx not being present in installation path Previously Hadrian's installation makefile would assume that the string `xxx` did not appear in the installation path. This would of course break for some users. Fixes #21402. - - - - - 09e98859 by Ben Gamari at 2022-04-22T02:16:35-04:00 testsuite: Ensure that GHC doesn't pick up environment files Here we set GHC_ENVIRONMENT="-" to ensure that GHC invocations of tests don't pick up a user's local package environment. Fixes #21365. Metric Decrease: T10421 T12234 T12425 T13035 T16875 T9198 - - - - - 76bb8cb3 by Ben Gamari at 2022-04-22T02:17:11-04:00 hadrian: Enable -dlint in devel2 flavour Previously only -dcore-lint was enabled. - - - - - f435d55f by Krzysztof Gogolewski at 2022-04-22T08:00:18-04:00 Fixes to rubbish literals * In CoreToStg, the application 'RUBBISH[rep] x' was simplified to 'RUBBISH[rep]'. But it is possible that the result of the function is represented differently than the function. * In Unarise, 'LitRubbish (primRepToType prep)' is incorrect: LitRubbish takes a RuntimeRep such as IntRep, while primRepToType returns a type such as Any @(TYPE IntRep). Use primRepToRuntimeRep instead. This code is never run in the testsuite. * In StgToByteCode, all rubbish literals were assumed to be boxed. This code predates representation-polymorphic RubbishLit and I think it was not updated. I don't have a testcase for any of those issues, but the code looks wrong. - - - - - 93c16b94 by sheaf at 2022-04-22T08:00:57-04:00 Relax "suppressing errors" assert in reportWanteds The assertion in reportWanteds that we aren't suppressing all the Wanted constraints was too strong: it might be the case that we are inside an implication, and have already reported an unsolved Wanted from outside the implication. It is possible that all Wanteds inside the implication have been rewritten by the outer Wanted, so we shouldn't throw an assertion failure in that case. Fixes #21405 - - - - - 78ec692d by Andreas Klebinger at 2022-04-22T08:01:33-04:00 Mention new MutableByteArray# wrapper in base changelog. - - - - - 56d7cb53 by Eric Lindblad at 2022-04-22T14:13:32-04:00 unlist announce - - - - - 1e4dcf23 by sheaf at 2022-04-22T14:14:12-04:00 decideMonoTyVars: account for CoVars in candidates The "candidates" passed to decideMonoTyVars can contain coercion holes. This is because we might well decide to quantify over some unsolved equality constraints, as long as they are not definitely insoluble. In that situation, decideMonoTyVars was passing a set of type variables that was not closed over kinds to closeWrtFunDeps, which was tripping up an assertion failure. Fixes #21404 - - - - - 2c541f99 by Simon Peyton Jones at 2022-04-22T14:14:47-04:00 Improve floated dicts in Specialise Second fix to #21391. It turned out that we missed calling bringFloatedDictsIntoScope when specialising imports, which led to the same bug as before. I refactored to move that call to a single place, in specCalls, so we can't forget it. This meant making `FloatedDictBinds` into its own type, pairing the dictionary bindings themselves with the set of their binders. Nicer this way. - - - - - 0950e2c4 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Ensure that --extra-lib-dirs are used Previously we only took `extraLibDirs` and friends from the package description, ignoring any contribution from the `LocalBuildInfo`. Fix this. Fixes #20566. - - - - - 53cc93ae by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Drop redundant include directories The package-specific include directories in Settings.Builders.Common.cIncludeDirs are now redundant since they now come from Cabal. Closes #20566. - - - - - b2721819 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Clean up handling of libffi dependencies - - - - - 18e5103f by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: More robust library way detection Previously `test.mk` would try to determine whether the dynamic, profiling, and vanilla library ways are available by searching for `PrimOpWrappers.{,dyn_,p_}hi` in directory reported by `ghc-pkg field ghc-prim library-dirs`. However, this is extremely fragile as there is no guarantee that there is only one library directory. To handle the case of multiple `library-dirs` correct we would have to carry out the delicate task of tokenising the directory list (in shell, no less). Since this isn't a task that I am eager to solve, I have rather moved the detection logic into the testsuite driver and instead perform a test compilation in each of the ways. This should be more robust than the previous approach. I stumbled upon this while fixing #20579. - - - - - 6c7a4913 by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: Cabalify ghc-config To ensure that the build benefits from Hadrian's usual logic for building packages, avoiding #21409. Closes #21409. - - - - - 9af091f7 by Ben Gamari at 2022-04-25T10:18:53-04:00 rts: Factor out built-in GC roots - - - - - e7c4719d by Ben Gamari at 2022-04-25T10:18:54-04:00 Ensure that wired-in exception closures aren't GC'd As described in Note [Wired-in exceptions are not CAFfy], a small set of built-in exception closures get special treatment in the code generator, being declared as non-CAFfy despite potentially containing CAF references. The original intent of this treatment for the RTS to then add StablePtrs for each of the closures, ensuring that they are not GC'd. However, this logic was not applied consistently and eventually removed entirely in 951c1fb0. This lead to #21141. Here we fix this bug by reintroducing the StablePtrs and document the status quo. Closes #21141. - - - - - 9587726f by Ben Gamari at 2022-04-25T10:18:54-04:00 testsuite: Add testcase for #21141 - - - - - cb71226f by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop dead code in GHC.Linker.Static.linkBinary' Previously we supported building statically-linked executables using libtool. However, this was dropped in 91262e75dd1d80f8f28a3922934ec7e59290e28c in favor of using ar/ranlib directly. Consequently we can drop this logic. Fixes #18826. - - - - - 9420d26b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop libtool path from settings file GHC no longers uses libtool for linking and therefore this is no longer necessary. - - - - - 41cf758b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop remaining vestiges of libtool Drop libtool logic from gen-dll, allowing us to drop the remaining logic from the `configure` script. Strangely, this appears to reliably reduce compiler allocations of T16875 on Windows. Closes #18826. Metric Decrease: T16875 - - - - - e09afbf2 by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - e76705cf by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Improve documentation of closure types Also drops the unused TREC_COMMITTED transaction state. - - - - - f2c08124 by Bodigrim at 2022-04-25T10:20:44-04:00 Document behaviour of RULES with KnownNat - - - - - 360dc2bc by Li-yao Xia at 2022-04-25T19:13:06+00:00 Fix rendering of liftA haddock - - - - - 16df6058 by Ben Gamari at 2022-04-27T10:02:25-04:00 testsuite: Report minimum and maximum stat changes As suggested in #20733. - - - - - e39cab62 by Fabian Thorand at 2022-04-27T10:03:03-04:00 Defer freeing of mega block groups Solves the quadratic worst case performance of freeing megablocks that was described in issue #19897. During GC runs, we now keep a secondary free list for megablocks that is neither sorted, nor coalesced. That way, free becomes an O(1) operation at the expense of not being able to reuse memory for larger allocations. At the end of a GC run, the secondary free list is sorted and then merged into the actual free list in a single pass. That way, our worst case performance is O(n log(n)) rather than O(n^2). We postulate that temporarily losing coalescense during a single GC run won't have any adverse effects in practice because: - We would need to release enough memory during the GC, and then after that (but within the same GC run) allocate a megablock group of more than one megablock. This seems unlikely, as large objects are not copied during GC, and so we shouldn't need such large allocations during a GC run. - Allocations of megablock groups of more than one megablock are rare. They only happen when a single heap object is large enough to require that amount of space. Any allocation areas that are supposed to hold more than one heap object cannot use megablock groups, because only the first megablock of a megablock group has valid `bdescr`s. Thus, heap object can only start in the first megablock of a group, not in later ones. - - - - - 5de6be0c by Fabian Thorand at 2022-04-27T10:03:03-04:00 Add note about inefficiency in returnMemoryToOS - - - - - 8bef471a by sheaf at 2022-04-27T10:03:43-04:00 Ensure that Any is Boxed in FFI imports/exports We should only accept the type `Any` in foreign import/export declarations when it has type `Type` or `UnliftedType`. This patch adds a kind check, and a special error message triggered by occurrences of `Any` in foreign import/export declarations at other kinds. Fixes #21305 - - - - - ba3d4e1c by Ben Gamari at 2022-04-27T10:04:19-04:00 Basic response file support Here we introduce support into our command-line parsing infrastructure and driver for handling gnu-style response file arguments, typically used to work around platform command-line length limitations. Fixes #16476. - - - - - 3b6061be by Ben Gamari at 2022-04-27T10:04:19-04:00 testsuite: Add test for #16476 - - - - - 75bf1337 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix cabal-reinstall job It's quite nice we can do this by mostly deleting code Fixes #21373 - - - - - 2c00d904 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add test to check that release jobs have profiled libs - - - - - 50d78d3b by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Explicitly handle failures in test_hadrian We also disable the stage1 testing which is broken. Related to #21072 - - - - - 2dcdf091 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix shell command - - - - - 55c84123 by Matthew Pickering at 2022-04-27T10:04:55-04:00 bootstrap: Add bootstrapping files for ghc-9_2_2 Fixes #21373 - - - - - c7ee0be6 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add linting job which checks authors are not GHC CI - - - - - 23aad124 by Adam Sandberg Ericsson at 2022-04-27T10:05:31-04:00 rts: state explicitly what evacuate and scavange mean in the copying gc - - - - - 318e0005 by Ben Gamari at 2022-04-27T10:06:07-04:00 rts/eventlog: Don't attempt to flush if there is no writer If the user has not configured a writer then there is nothing to flush. - - - - - ee11d043 by Ben Gamari at 2022-04-27T10:06:07-04:00 Enable eventlog support in all ways by default Here we deprecate the eventlogging RTS ways and instead enable eventlog support in the remaining ways. This simplifies packaging and reduces GHC compilation times (as we can eliminate two whole compilations of the RTS) while simplifying the end-user story. The trade-off is a small increase in binary sizes in the case that the user does not want eventlogging support, but we think that this is a fine trade-off. This also revealed a latent RTS bug: some files which included `Cmm.h` also assumed that it defined various macros which were in fact defined by `Config.h`, which `Cmm.h` did not include. Fixing this in turn revealed that `StgMiscClosures.cmm` failed to import various spinlock statistics counters, as evidenced by the failed unregisterised build. Closes #18948. - - - - - a2e5ab70 by Andreas Klebinger at 2022-04-27T10:06:43-04:00 Change `-dsuppress-ticks` to only suppress non-code ticks. This means cost centres and coverage ticks will still be present in output. Makes using -dsuppress-all more convenient when looking at profiled builds. - - - - - ec9d7e04 by Ben Gamari at 2022-04-27T10:07:21-04:00 Bump text submodule. This should fix #21352 - - - - - c3105be4 by Bodigrim at 2022-04-27T10:08:01-04:00 Documentation for setLocaleEncoding - - - - - 7f618fd3 by sheaf at 2022-04-27T10:08:40-04:00 Update docs for change to type-checking plugins There was no mention of the changes to type-checking plugins in the 9.4.1 notes, and the extending_ghc documentation contained a reference to an outdated type. - - - - - 4419dd3a by Adam Sandberg Ericsson at 2022-04-27T10:09:18-04:00 rts: add some more documentation to StgWeak closure type - - - - - 5a7f0dee by Matthew Pickering at 2022-04-27T10:09:54-04:00 Give Cmm files fake ModuleNames which include full filepath This fixes the initialisation functions when using -prof or -finfo-table-map. Fixes #21370 - - - - - 81cf52bb by sheaf at 2022-04-27T10:10:33-04:00 Mark GHC.Prim.PtrEq as Unsafe This module exports unsafe pointer equality operations, so we accordingly mark it as Unsafe. Fixes #21433 - - - - - f6a8185d by Ben Gamari at 2022-04-28T09:10:31+00:00 testsuite: Add performance test for #14766 This distills the essence of the Sigs.hs program found in the ticket. - - - - - c7a3dc29 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Add Monoid instance to Way - - - - - 654bafea by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Enrich flavours to build profiled/debugged/threaded ghcs per stage - - - - - 4ad559c8 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: add debug_ghc and debug_stage1_ghc flavour transformers - - - - - f9728fdb by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Don't pass -rtsopts when building libraries - - - - - 769279e6 by Matthew Pickering at 2022-04-28T18:54:44-04:00 testsuite: Fix calculation about whether to pass -dynamic to compiler - - - - - da8ae7f2 by Ben Gamari at 2022-04-28T18:55:20-04:00 hadrian: Clean up flavour transformer definitions Previously the `ipe` and `omit_pragmas` transformers were hackily defined using the textual key-value syntax. Fix this. - - - - - 61305184 by Ben Gamari at 2022-04-28T18:55:56-04:00 Bump process submodule - - - - - a8c99391 by sheaf at 2022-04-28T18:56:37-04:00 Fix unification of ConcreteTvs, removing IsRefl# This patch fixes the unification of concrete type variables. The subtlety was that unifying concrete metavariables is more subtle than other metavariables, as decomposition is possible. See the Note [Unifying concrete metavariables], which explains how we unify a concrete type variable with a type 'ty' by concretising 'ty', using the function 'GHC.Tc.Utils.Concrete.concretise'. This can be used to perform an eager syntactic check for concreteness, allowing us to remove the IsRefl# special predicate. Instead of emitting two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we instead concretise 'rr'. If this succeeds we can fill 'concrete_tv', and otherwise we directly emit an error message to the typechecker environment instead of deferring. We still need the error message to be passed on (instead of directly thrown), as we might benefit from further unification in which case we will need to zonk the stored types. To achieve this, we change the 'wc_holes' field of 'WantedConstraints' to 'wc_errors', which stores general delayed errors. For the moement, a delayed error is either a hole, or a syntactic equality error. hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and hasFixedRuntimeRep has been refactored to directly return the most useful coercion for PHASE 2 of FixedRuntimeRep. This patch also adds a field ir_frr to the InferResult datatype, holding a value of type Maybe FRROrigin. When this value is not Nothing, this means that we must fill the ir_ref field with a type which has a fixed RuntimeRep. When it comes time to fill such an ExpType, we ensure that the type has a fixed RuntimeRep by performing a representation-polymorphism check with the given FRROrigin This is similar to what we already do to ensure we fill an Infer ExpType with a type of the correct TcLevel. This allows us to properly perform representation-polymorphism checks on 'Infer' 'ExpTypes'. The fillInferResult function had to be moved to GHC.Tc.Utils.Unify to avoid a cyclic import now that it calls hasFixedRuntimeRep. This patch also changes the code in matchExpectedFunTys to make use of the coercions, which is now possible thanks to the previous change. This implements PHASE 2 of FixedRuntimeRep in some situations. For example, the test cases T13105 and T17536b are now both accepted. Fixes #21239 and #21325 ------------------------- Metric Decrease: T18223 T5631 ------------------------- - - - - - 43bd897d by Simon Peyton Jones at 2022-04-28T18:57:13-04:00 Add INLINE pragmas for Enum helper methods As #21343 showed, we need to be super-certain that the "helper methods" for Enum instances are actually inlined or specialised. I also tripped over this when I discovered that numericEnumFromTo and friends had no pragmas at all, so their performance was very fragile. If they weren't inlined, all bets were off. So I've added INLINE pragmas for them too. See new Note [Inline Enum method helpers] in GHC.Enum. I also expanded Note [Checking for INLINE loop breakers] in GHC.Core.Lint to explain why an INLINE function might temporarily be a loop breaker -- this was the initial bug report in #21343. Strangely we get a 16% runtime allocation decrease in perf/should_run/T15185, but only on i386. Since it moves in the right direction I'm disinclined to investigate, so I'll accept it. Metric Decrease: T15185 - - - - - ca1434e3 by Ben Gamari at 2022-04-28T18:57:49-04:00 configure: Bump GHC version to 9.5 Bumps haddock submodule. - - - - - 292e3971 by Teo Camarasu at 2022-04-28T18:58:28-04:00 add since annotation for GHC.Stack.CCS.whereFrom - - - - - 905206d6 by Tamar Christina at 2022-04-28T22:19:34-04:00 winio: add support to iserv. - - - - - d182897e by Tamar Christina at 2022-04-28T22:19:34-04:00 Remove unused line - - - - - 22cf4698 by Matthew Pickering at 2022-04-28T22:20:10-04:00 Revert "rts: Refactor handling of dead threads' stacks" This reverts commit e09afbf2a998beea7783e3de5dce5dd3c6ff23db. - - - - - 8ed57135 by Matthew Pickering at 2022-04-29T04:11:29-04:00 Provide efficient unionMG function for combining two module graphs. This function is used by API clients (hls). This supercedes !6922 - - - - - 0235ff02 by Ben Gamari at 2022-04-29T04:12:05-04:00 Bump bytestring submodule Update to current `master`. - - - - - 01988418 by Matthew Pickering at 2022-04-29T04:12:05-04:00 testsuite: Normalise package versions in UnusedPackages test - - - - - 724d0dc0 by Matthew Pickering at 2022-04-29T08:59:42+00:00 testsuite: Deduplicate ways correctly This was leading to a bug where we would run a profasm test twice which led to invalid junit.xml which meant the test results database was not being populated for the fedora33-perf job. - - - - - 5630dde6 by Ben Gamari at 2022-04-29T13:06:20-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - 0cdef807 by parsonsmatt at 2022-04-30T16:51:12-04:00 Add a note about instance visibility across component boundaries In principle, the *visible* instances are * all instances defined in a prior top-level declaration group (see docs on `newDeclarationGroup`), or * all instances defined in any module transitively imported by the module being compiled However, actually searching all modules transitively below the one being compiled is unreasonably expensive, so `reifyInstances` will report only the instance for modules that GHC has had some cause to visit during this compilation. This is a shortcoming: `reifyInstances` might fail to report instances for a type that is otherwise unusued, or instances defined in a different component. You can work around this shortcoming by explicitly importing the modules whose instances you want to be visible. GHC issue #20529 has some discussion around this. Fixes #20529 - - - - - e2dd884a by Ryan Scott at 2022-04-30T16:51:47-04:00 Make mkFunCo take AnonArgFlags into account Previously, whenever `mkFunCo` would produce reflexive coercions, it would use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is also used to produce coercions between types of the form `ty1 => ty2` in certain places. This has the unfortunate side effect of causing the type of the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted in #21328. This patch address this by changing replacing the use of `mkVisFunTy` with `mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`, so this should always produce the correct `AnonArgFlag`. As a result, this patch fixes part (2) of #21328. This is not the only possible way to fix #21328, as the discussion on that issue lists some possible alternatives. Ultimately, it was concluded that the alternatives would be difficult to maintain, and since we already use `mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType` in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType` does not regress the performance of any test case we have in GHC's test suite. - - - - - 170da54f by Ben Gamari at 2022-04-30T16:52:27-04:00 Convert More Diagnostics (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors. - - - - - 39edc7b4 by Marius Ghita at 2022-04-30T16:53:06-04:00 Update user guide example rewrite rules formatting Change the rewrite rule examples to include a space between the composition of `f` and `g` in the map rewrite rule examples. Without this change, if the user has locally enabled the extension OverloadedRecordDot the copied example will result in a compile time error that `g` is not a field of `f`. ``` • Could not deduce (GHC.Records.HasField "g" (a -> b) (a1 -> b)) arising from selecting the field ‘g’ ``` - - - - - 2e951e48 by Adam Sandberg Ericsson at 2022-04-30T16:53:42-04:00 ghc-boot: export typesynonyms from GHC.Utils.Encoding This makes the Haddocks easier to understand. - - - - - d8cbc77e by Adam Sandberg Ericsson at 2022-04-30T16:54:18-04:00 users guide: add categories to some flags - - - - - d0f14fad by Chris Martin at 2022-04-30T16:54:57-04:00 hacking guide: mention the core libraries committee - - - - - 34b28200 by Matthew Pickering at 2022-04-30T16:55:32-04:00 Revert "Make the specialiser handle polymorphic specialisation" This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8. See ticket #21229 ------------------------- Metric Decrease: T15164 Metric Increase: T13056 ------------------------- - - - - - ee891c1e by Matthew Pickering at 2022-04-30T16:55:32-04:00 Add test for T21229 - - - - - ab677cc8 by Matthew Pickering at 2022-04-30T16:56:08-04:00 Hadrian: Update README about the flavour/testsuite contract There have been a number of tickets about non-tested flavours not passing the testsuite.. this is expected and now noted in the documentation. You use other flavours to run the testsuite at your own risk. Fixes #21418 - - - - - b57b5b92 by Ben Gamari at 2022-04-30T16:56:44-04:00 rts/m32: Fix assertion failure This fixes an assertion failure in the m32 allocator due to the imprecisely specified preconditions of `m32_allocator_push_filled_list`. Specifically, the caller must ensure that the page type is set to filled prior to calling `m32_allocator_push_filled_list`. While this issue did result in an assertion failure in the debug RTS, the issue is in fact benign. - - - - - a7053a6c by sheaf at 2022-04-30T16:57:23-04:00 Testsuite driver: don't crash on empty metrics The testsuite driver crashed when trying to display minimum/maximum performance changes when there are no metrics (i.e. there is no baseline available). This patch fixes that. - - - - - 636f7c62 by Andreas Klebinger at 2022-05-01T22:21:17-04:00 StgLint: Check that functions are applied to compatible runtime reps We use compatibleRep to compare reps, and avoid checking functions with levity polymorphic types because of #21399. - - - - - 60071076 by Hécate Moonlight at 2022-05-01T22:21:55-04:00 Add documentation to the ByteArray# primetype. close #21417 - - - - - 2b2e3020 by Andreas Klebinger at 2022-05-01T22:22:31-04:00 exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is bottoming. We used to check the divergence and that the number of arguments > arity. But arity zero represents unknown arity so this was subtly broken for a long time! We would check if the saturated function diverges, and if we applied >=arity arguments. But for unknown arity functions any number of arguments is >=idArity. This fixes #21440. - - - - - 4eaf0f33 by Eric Lindblad at 2022-05-01T22:23:11-04:00 typos - - - - - fc58df90 by Niklas Hambüchen at 2022-05-02T08:59:27+00:00 libraries/base: docs: Explain relationshipt between `finalizeForeignPtr` and `*Conc*` creation Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/21420 - - - - - 3e400f20 by Krzysztof Gogolewski at 2022-05-02T18:29:23-04:00 Remove obsolete code in CoreToStg Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4. This codepath is tested by T15696_3. - - - - - 4a780928 by Krzysztof Gogolewski at 2022-05-02T18:29:24-04:00 Fix several note references - - - - - 15ffe2b0 by Sebastian Graf at 2022-05-03T20:11:51+02:00 Assume at least one evaluation for nested SubDemands (#21081, #21133) See the new `Note [SubDemand denotes at least one evaluation]`. A demand `n :* sd` on a let binder `x=e` now means > "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is > evaluated deeply in sub-demand `sd`." The "any time it is evaluated" premise is what this patch adds. As a result, we get better nested strictness. For example (T21081) ```hs f :: (Bool, Bool) -> (Bool, Bool) f pr = (case pr of (a,b) -> a /= b, True) -- before: <MP(L,L)> -- after: <MP(SL,SL)> g :: Int -> (Bool, Bool) g x = let y = let z = odd x in (z,z) in f y ``` The change in demand signature "before" to "after" allows us to case-bind `z` here. Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`, albeit). We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand expansion. In an attempt to fix a regression caused by less inlining due to eta-reduction in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus fixing #21345 on the go. The main point of this patch is that it fixes #21081 and #21133. Annoyingly, I discovered that more precise demand signatures for join points can transform a program into a lazier program if that join point gets floated to the top-level, see #21392. There is no simple fix at the moment, but !5349 might. Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392 bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue. Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by 0.4% in the geometric mean and by 2% in T16875. Metric Increase: MultiLayerModulesTH_OneShot Metric Decrease: T16875 - - - - - 948c7e40 by Andreas Klebinger at 2022-05-04T09:57:34-04:00 CoreLint - When checking for levity polymorphism look through more ticks. For expressions like `(scc<cc_name> primOp#) arg1` we should also look at arg1 to determine if we call primOp# at a fixed runtime rep. This is what corePrep already does but CoreLint didn't yet. This patch will bring them in sync in this regard. It also uses tickishFloatable in CorePrep instead of CorePrep having it's own slightly differing definition of when a tick is floatable. - - - - - 85bc73bd by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Support Unicode properly - - - - - 063d485e by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Replace LaTeX documentation syntax with Haddock The LaTeX documentation generator does not seem to have been used for quite some time, so the LaTeX-to-Haddock preprocessing step has become a pointless complication that makes documenting the contents of GHC.Prim needlessly difficult. This commit replaces the LaTeX syntax with the Haddock it would have been converted into, anyway, though with an additional distinction: it uses single quotes in places to instruct Haddock to generate hyperlinks to bindings. This improves the quality of the generated output. - - - - - d61f7428 by Ben Gamari at 2022-05-04T09:58:50-04:00 rts/ghc.mk: Only build StgCRunAsm.S when it is needed Previously the make build system unconditionally included StgCRunAsm.S in the link, meaning that the RTS would require an execstack unnecessarily. Fixes #21478. - - - - - 934a90dd by Simon Peyton Jones at 2022-05-04T16:15:34-04:00 Improve error reporting in generated code Our error reporting in generated code (via desugaring before typechecking) only worked when the generated code was just a simple call. This commit makes it work in nested cases. - - - - - 445d3657 by sheaf at 2022-05-04T16:16:12-04:00 Ensure Any is not levity-polymorphic in FFI The previous patch forgot to account for a type such as Any @(TYPE (BoxedRep l)) for a quantified levity variable l. - - - - - ddd2591c by Ben Gamari at 2022-05-04T16:16:48-04:00 Update supported LLVM versions Pull forward minimum version to match 9.2. (cherry picked from commit c26faa54c5fbe902ccb74e79d87e3fa705e270d1) - - - - - f9698d79 by Ben Gamari at 2022-05-04T16:16:48-04:00 testsuite/T7275: Use sed -r Darwin requires the `-r` flag to be compatible with GNU sed. (cherry picked from commit 512338c8feec96c38ef0cf799f3a01b77c967c56) - - - - - 8635323b by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Use ld.lld on ARMv7/Linux Due to #16177. Also cleanup some code style issues. (cherry picked from commit cc1c3861e2372f464bf9e3c9c4d4bd83f275a1a6) - - - - - 4f6370c7 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Always preserve artifacts, even in failed jobs (cherry picked from commit fd08b0c91ea3cab39184f1b1b1aafcd63ce6973f) - - - - - 6f662754 by Ben Gamari at 2022-05-04T16:16:48-04:00 configure: Make sphinx version check more robust It appears that the version of sphinx shipped on CentOS 7 reports a version string of `Sphinx v1...`. Accept the `v`. (cherry picked from commit a9197a292fd4b13308dc6664c01351c7239357ed) - - - - - 0032dc38 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Don't run make job in release pipelines (cherry picked from commit 16d6a8ff011f2194485387dcca1c00f8ddcdbdeb) - - - - - 27f9aab3 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab/ci: Fix name of bootstrap compiler directory Windows binary distributions built with Hadrian have a target platform suffix in the name of their root directory. Teach `ci.sh` about this fact. (cherry picked from commit df5752f39671f6d04d8cd743003469ae5eb67235) - - - - - b528f0f6 by Krzysztof Gogolewski at 2022-05-05T09:05:43-04:00 Fix several note references, part 2 - - - - - 691aacf6 by Adam Sandberg Ericsson at 2022-05-05T09:06:19-04:00 adjustors: align comment about number of integer like arguments with implementation for Amd4+MinGW implementation - - - - - f050557e by Simon Jakobi at 2022-05-05T12:47:32-04:00 Remove two uses of IntMap.size IntMap.size is O(n). The new code should be slightly more efficient. The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be described formally as the transformation: (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n ==> (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk) - - - - - 7da90ae3 by Tom Ellis at 2022-05-05T12:48:09-04:00 Explain that 'fail s' should run in the monad itself - - - - - 610d0283 by Matthew Craven at 2022-05-05T12:48:47-04:00 Add a test for the bracketing in rules for (^) - - - - - 016f9ca6 by Matthew Craven at 2022-05-05T12:48:47-04:00 Fix broken rules for (^) with known small powers - - - - - 9372aaab by Matthew Craven at 2022-05-05T12:48:47-04:00 Give the two T19569 tests different names - - - - - 61901b32 by Andreas Klebinger at 2022-05-05T12:49:23-04:00 SpecConstr: Properly create rules for call patterns representing partial applications The main fix is that in addVoidWorkerArg we now add the argument to the front. This fixes #21448. ------------------------- Metric Decrease: T16875 ------------------------- - - - - - 71278dc7 by Teo Camarasu at 2022-05-05T12:50:03-04:00 add since annotations for instances of ByteArray - - - - - 962ff90b by sheaf at 2022-05-05T12:50:42-04:00 Start 9.6.1-notes Updates the documentation notes to start tracking changes for the 9.6.1 release (instead of 9.4). - - - - - aacb15a3 by Matthew Pickering at 2022-05-05T20:24:01-04:00 ci: Add job to check that jobs.yaml is up-to-date There have been quite a few situations where jobs.yaml has been out of date. It's better to add a CI job which checks that it's right. We don't want to use a staged pipeline because it obfuscates the structure of the pipeline. - - - - - be7102e5 by Ben Gamari at 2022-05-05T20:24:37-04:00 rts: Ensure that XMM registers are preserved on Win64 Previously we only preserved the bottom 64-bits of the callee-saved 128-bit XMM registers, in violation of the Win64 calling convention. Fix this. Fixes #21465. - - - - - 73b22ff1 by Ben Gamari at 2022-05-05T20:24:37-04:00 testsuite: Add test for #21465 - - - - - e2ae9518 by Ziyang Liu at 2022-05-06T19:22:22-04:00 Allow `let` just before pure/return in ApplicativeDo The following is currently rejected: ```haskell -- F is an Applicative but not a Monad x :: F (Int, Int) x = do a <- pure 0 let b = 1 pure (a, b) ``` This has bitten me multiple times. This MR contains a simple fix: only allow a "let only" segment to be merged with the next (and not the previous) segment. As a result, when the last one or more statements before pure/return are `LetStmt`s, there will be one more segment containing only those `LetStmt`s. Note that if the `let` statement mentions a name bound previously, then the program is still rejected, for example ```haskell x = do a <- pure 0 let b = a + 1 pure (a, b) ``` or the example in #18559. To support this would require a more complex approach, but this is IME much less common than the previous case. - - - - - 0415449a by Matthew Pickering at 2022-05-06T19:22:58-04:00 template-haskell: Fix representation of OPAQUE pragmas There is a mis-match between the TH representation of OPAQUE pragmas and GHC's internal representation due to how OPAQUE pragmas disallow phase annotations. It seemed most in keeping to just fix the wired in name issue by adding a special case to the desugaring of INLINE pragmas rather than making TH/GHC agree with how the representation should look. Fixes #21463 - - - - - 4de887e2 by Simon Peyton Jones at 2022-05-06T19:23:34-04:00 Comments only: Note [AppCtxt] - - - - - 6e69964d by Matthew Pickering at 2022-05-06T19:24:10-04:00 Fix name of windows release bindist in doc-tarball job - - - - - ced4689e by Matthew Pickering at 2022-05-06T19:24:46-04:00 ci: Generate source-tarball in release jobs We need to distribute the source tarball so we should generate it in the CI pipeline. - - - - - 3c91de21 by Rob at 2022-05-08T13:40:53+02:00 Change Specialise to use OrdList. Fixes #21362 Metric Decrease: T16875 - - - - - 67072c31 by Simon Jakobi at 2022-05-08T12:23:43-04:00 Tweak GHC.CmmToAsm.CFG.delEdge mapAdjust is more efficient than mapAlter. - - - - - 374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00 Respect -po when heap profiling (#21446) - - - - - 1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00 add test case for #21446 - - - - - c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00 avoid hadrian/bindist/Makefile install_docs error when --docs=none When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated. Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index to avoid the error: /usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory make: *** [Makefile:195: install_docs] Error 1 - - - - - 158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00 Correct base's changelog for 4.16.1.0 This commit reaffects the new Ix instances of the foreign integral types from base 4.17 to 4.16.1.0 closes #21529 - - - - - a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00 STG: only print cost-center if asked to - - - - - 50347ded by Gergo ERDI at 2022-05-10T11:43:33+00:00 Improve "Glomming" note Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order references, and thus needing to glom, is not a cause for concern when its root cause is rewrite rules. - - - - - df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00 update INSTALL - - - - - dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00 driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode It seems like it was just an oversight to use the incorrect DynFlags (global rather than local) when implementing these two options. Using the local flags allows users to request these intermediate files get cleaned up, which works fine in --make mode because 1. Interface files are stored in memory 2. Object files are only cleaned at the end of session (after link) Fixes #21349 - - - - - 35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00 configure: Check for ffi.h As noted in #21485, we checked for ffi.h yet then failed to throw an error if it is missing. Fixes #21485. - - - - - bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00 Check for uninferrable variables in tcInferPatSynDecl This fixes #21479 See Note [Unquantified tyvars in a pattern synonym] While doing this, I found that some error messages pointed at the pattern synonym /name/, rather than the /declaration/ so I widened the SrcSpan to encompass the declaration. - - - - - 142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00 hadrian: Fix split-sections transformer The splitSections transformer has been broken since -dynamic-too support was implemented in hadrian. This is because we actually build the dynamic way when building the dynamic way, so the predicate would always fail. The fix is to just always pass `split-sections` even if it doesn't do anything for a particular way. Fixes #21138 - - - - - 699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. Closes #21135 - - - - - 21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00 Use the wrapper for an unlifted binding We assumed the wrapper for an unlifted binding is the identity, but as #21516 showed, that is no always true. Solution is simple: use it. - - - - - 68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00 docs: Fix path to GHC API docs in index.html In the make bindists we generate documentation in docs/ghc-<VER> but the hadrian bindists generate docs/ghc/ so the path to the GHC API docs was wrong in the index.html file. Rather than make the hadrian and make bindists the same it was easier to assume that if you're using the mkDocs script that you're using hadrian bindists. Fixes #21509 - - - - - 9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00 hadrian: Don't pass -j to haddock This has high potential for oversubcribing as many haddock jobs can be spawned in parralel which will each request the given number of capabilities. Once -jsem is implemented (#19416, !5176) we can expose that haddock via haddock and use that to pass a semaphore. Ticket #21136 - - - - - fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00 hadrian: Only copy and install libffi headers when using in-tree libffi When passed `--use-system-libffi` then we shouldn't copy and install the headers from the system package. Instead the headers are expected to be available as a runtime dependency on the users system. Fixes #21485 #21487 - - - - - 5b791ed3 by mikael at 2022-05-11T08:22:13-04:00 FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10. - - - - - 8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00 Make floating-point abs IEEE 754 compliant The old code used by via-C backend didn't handle the sign bit of NaN. See #21043. - - - - - 4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00 EPA: do statement with leading semicolon has wrong anchor The code do; a <- doAsync; b Generated an incorrect Anchor for the statement list that starts after the first semicolon. This commit fixes it. Closes #20256 - - - - - e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00 Specialiser: saturate DFuns correctly Ticket #21489 showed that the saturation mechanism for DFuns (see Note Specialising DFuns) should use both UnspecType and UnspecArg. We weren't doing that; but this MR fixes that problem. No test case because it's hard to tickle, but it showed up in Gergo's work with GHC-as-a-library. - - - - - fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00 gitlab-ci: Check for dynamic msys2 dependencies Both #20878 and #21196 were caused by unwanted dynamic dependencies being introduced by boot libraries. Ensure that we catch this in CI by attempting to run GHC in an environment with a minimal PATH. - - - - - 3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00 Add back Debian9 CI jobs We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 not being at EOL until April 2023 and they still need tinfo5. Fixes #21469 - - - - - dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00 rts: Drop setExecutable Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been dead code. Drop it. - - - - - 32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00 Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat This missing guard gave rise to #21519. - - - - - 2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00 Add mention of -hi to RTS --help Fixes #21546 - - - - - a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00 Decouple dynflags in Cmm parser (related to #17957) - - - - - 3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00 Remove Module argument from initCmmParserConfig - - - - - 2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00 Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config - - - - - b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00 Decouple dynflags in GHC.Core.Opt.Arity (related to #17957) Metric Decrease: T16875 - - - - - 3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00 Update extending_ghc for TcPlugin changes The documentation still mentioned Derived constraints and an outdated datatype TcPluginResult. - - - - - 668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00 Fix printing of brackets in multiplicities (#20315) Change mulArrow to allow for printing of correct application precedence where necessary and update callers of mulArrow to reflect this. As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type. Fixes #20315 - - - - - 30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00 rts: Add debug output on ocResolve failure This makes it easier to see how resolution failures nest. - - - - - 53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00 rts/PEi386: Fix handling of weak symbols Previously we would flag the symbol as weak but failed to set its address, which must be computed from an "auxiliary" symbol entry the follows the weak symbol. Fixes #21556. - - - - - 5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00 testsuite: Add tests for #21556 - - - - - 49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00 Re-export augment and build from GHC.List Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127 - - - - - aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00 Comments only around HsWrapper - - - - - 27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00 hadrian: Introduce linting flavour transformer (+lint) The linting flavour enables -dlint uniformly across anything build by the stage1 compiler. -dcmm-lint is not currently enabled because it fails on i386 (see #21563) - - - - - 3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00 hadrian: Uniformly enable -dlint with enableLinting transformer This fixes some bugs where * -dcore-lint was being passed when building stage1 libraries with the boot compiler * -dcore-lint was not being passed when building executables. Fixes #20135 - - - - - 3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00 Make closure macros EXTERN_INLINE to make debugging easier Implements #21424. The RTS macros get_itbl and friends are extremely helpful during debugging. However only a select few of those were available in the compiled RTS as actual symbols as the rest were INLINE macros. This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites but allow us to use their compiled counterparts during debugging. This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell since `get_fun_itbl` will now be available as symbol! - - - - - 93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00 packaging: Introduce CI job for generating hackage documentation This adds a CI job (hackage-doc-tarball) which generates the necessary tarballs for uploading libraries and documentation to hackage. The release script knows to download this folder and the upload script will also upload the release to hackage as part of the release. The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs There are two modes, preparation and upload. * The `prepare` mode takes a link to a bindist and creates a folder containing the source and doc tarballs ready to upload to hackage. * The `upload` mode takes the folder created by prepare and performs the upload to hackage. Fixes #21493 Related to #21512 - - - - - 65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00 Add arity to the INLINE pragmas for pattern synonyms The lack of INLNE arity was exposed by #21531. The fix is simple enough, if a bit clumsy. - - - - - 43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00 Misc cleanup - Remove groupWithName (unused) - Use the RuntimeRepType synonym where possible - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM No functional changes. - - - - - 8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00 TcPlugin: access to irreducible givens + fix passed ev_binds_var - - - - - fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00 driver: Introduce pgmcxx Here we introduce proper support for compilation of C++ objects. This includes: * logic in `configure` to detect the C++ toolchain and propagating this information into the `settings` file * logic in the driver to use the C++ toolchain when compiling C++ sources - - - - - 43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Build T20918 with HC, not CXX - - - - - 0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00 Introduce package to capture dependency on C++ stdlib Here we introduce a new "virtual" package into the initial package database, `system-cxx-std-lib`. This gives users a convenient, platform agnostic way to link against C++ libraries, addressing #20010. Fixes #20010. - - - - - 03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Add tests for system-cxx-std-lib package Test that we can successfully link against C++ code both in GHCi and batch compilation. See #20010 - - - - - 5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00 OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420) - - - - - eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00 Adjust flags for pprTrace We were using defaultSDocContext for pprTrace, which suppresses lots of useful infomation. This small MR adds GHC.Utils.Outputable.traceSDocContext and uses it for pprTrace and pprTraceUserWarning. traceSDocContext is a global, and hence not influenced by flags, but that seems unavoidable. But I made the sdocPprDebug bit controlled by unsafeHasPprDebug, since we have the latter for exactly this purpose. Fixes #21569 - - - - - d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00 Fix bad interaction between withDict and the Specialiser This MR fixes a bad bug, where the withDict was inlined too vigorously, which in turn made the type-class Specialiser generate a bogus specialisation, because it saw the same overloaded function applied to two /different/ dictionaries. Solution: inline `withDict` later. See (WD8) of Note [withDict] in GHC.HsToCore.Expr See #21575, which is fixed by this change. - - - - - 70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00 Bump time submodule to 1.12.2 This bumps the time submodule to the 1.12.2 release. Fixes #21571 - - - - - 2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00 Remove unused test files (#21582) Those files were moved to the perf/ subtree in 11c9a469, and then accidentally reintroduced in 680ef2c8. - - - - - cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00 CafAnal: Improve code clarity Here we implement a few measures to improve the clarity of the CAF analysis implementation. Specifically: * Use CafInfo instead of Bool since the former is more descriptive * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact CAFs * Add numerous comments - - - - - b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00 codeGen: Ensure that static datacon apps are included in SRTs When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT filters out recursive references, as described in Note [recursive SRTs]. However, doing so for static functions would be unsound, for the reason described in Note [Invalid optimisation: shortcutting]. However, the same argument applies to static data constructor applications, as we discovered in #20959. Fix this by ensuring that static data constructor applications are included in recursive SRTs. The approach here is not entirely satisfactory, but it is a starting point. Fixes #20959. - - - - - 0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00 Add test for #21558 This is now fixed on master and 9.2 branch. Closes #21558 - - - - - ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00 Don't store LlvmConfig into DynFlags LlvmConfig contains information read from llvm-passes and llvm-targets files in GHC's top directory. Reading these files is done only when needed (i.e. when the LLVM backend is used) and cached for the whole compiler session. This patch changes the way this is done: - Split LlvmConfig into LlvmConfig and LlvmConfigCache - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no good reason to store it in DynFlags. As it is fixed per session, we store it in the session state instead (HscEnv). - Initializing LlvmConfigCache required some changes to driver functions such as newHscEnv. I've used the opportunity to untangle initHscEnv from initGhcMonad (in top-level GHC module) and to move it to GHC.Driver.Main, close to newHscEnv. - I've also made `cmmPipeline` independent of HscEnv in order to remove the call to newHscEnv in regalloc_unit_tests. - - - - - 828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00 Give all EXTERN_INLINE closure macros prototypes - - - - - cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Introduce [sg]etFinalizerExceptionHandler This introduces a global hook which is called when an exception is thrown during finalization. - - - - - 372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Throw exceptions raised while closing finalized Handles Fixes #21336. - - - - - 3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00 testsuite: Add tests for #21336 - - - - - 297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00 Add release flavour and use it for the release jobs The release flavour is essentially the same as the perf flavour currently but also enables `-haddock`. I have hopefully updated all the relevant places where the `-perf` flavour was hardcoded. Fixes #21486 - - - - - a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Don't build sphinx documentation on centos The centos docker image lacks the sphinx builder so we disable building sphinx docs for these jobs. Fixes #21580 - - - - - 209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Use correct syntax when args list is empty This seems to fail on the ancient version of bash present on CentOS - - - - - 02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00 hadrian: Don't attempt to build dynamic profiling libraries We only support building static profiling libraries, the transformer was requesting things like a dynamic, threaded, debug, profiling RTS, which we have never produced nor distributed. Fixes #21567 - - - - - 35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00 configure: Check CC_STAGE0 for --target support We previously only checked the stage 1/2 compiler for --target support. We got away with this for quite a while but it eventually caught up with us in #21579, where `bytestring`'s new NEON implementation was unbuildable on Darwin due to Rosetta's seemingly random logic for determining which executable image to execute. This lead to a confusing failure to build `bytestring`'s cbits, when `clang` tried to compile NEON builtins while targetting x86-64. Fix this by checking CC_STAGE0 for --target support. Fixes #21579. - - - - - 0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator analysis of `CmmGraph` This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper around two existing algorithms in GHC: the Lengauer-Tarjan dominator analysis from the X86 back end and the reverse postorder ordering from the Cmm Dataflow framework. Issue #20726 proposes that we evaluate some alternatives for dominator analysis, but for the time being, the best path forward is simply to use the existing analysis on `CmmGraph`s. This commit addresses a bullet in #21200. - - - - - 54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator-tree function - - - - - 05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add HasDebugCallStack; remove unneeded extensions - - - - - 0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00 document fields of `DominatorSet` - - - - - 8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00 nonmoving: Fix documentation of GC statistics fields These were previously incorrect. Fixes #21553. - - - - - c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00 Remove pprTrace from pushCoercionIntoLambda (#21555) This firstly caused spurious output to be emitted (as evidenced by #21555) but even worse caused a massive coercion to be attempted to be printed (> 200k terms) which would invariably eats up all the memory of your computer. The good news is that removing this trace allows the program to compile to completion, the bad news is that the program exhibits a core lint error (on 9.0.2) but not any other releases it seems. Fixes #21577 and #21555 - - - - - a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00 docs: Fix LlvmVersion in manpage (#21280) - - - - - 36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00 validate: Use $make rather than make In the validate script we are careful to use the $make variable as this stores whether we are using gmake, make, quiet mode etc. There was just this one place where we failed to use it. Fixes #21598 - - - - - 4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00 Change `Backend` type and remove direct dependencies With this change, `Backend` becomes an abstract type (there are no more exposed value constructors). Decisions that were formerly made by asking "is the current back end equal to (or different from) this named value constructor?" are now made by interrogating the back end about its properties, which are functions exported by `GHC.Driver.Backend`. There is a description of how to migrate code using `Backend` in the user guide. Clients using the GHC API can find a backdoor to access the Backend datatype in GHC.Driver.Backend.Internal. Bumps haddock submodule. Fixes #20927 - - - - - ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00 Respect DESTDIR in hadrian bindist Makefile, fixes #19646 - - - - - 7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00 Test DESTDIR in test_hadrian() - - - - - ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00 Consider the stage of typeable evidence when checking stage restriction We were considering all Typeable evidence to be "BuiltinInstance"s which meant the stage restriction was going unchecked. In-fact, typeable has evidence and so we need to apply the stage restriction. This is complicated by the fact we don't generate typeable evidence and the corresponding DFunIds until after typechecking is concluded so we introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which records whether the evidence is going to be local or not. Fixes #21547 - - - - - ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00 Modularize GHC.Core.Opt.LiberateCase Progress towards #17957 - - - - - bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00 Improve FloatOut and SpecConstr This patch addresses a relatively obscure situation that arose when chasing perf regressions in !7847, which itself is fixing It does two things: * SpecConstr can specialise on ($df d1 d2) dictionary arguments * FloatOut no longer checks argument strictness See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr. A test case is difficult to construct, but it makes a big difference in nofib/real/eff/VSM, at least when we have the patch for #21286 installed. (The latter stops worker/wrapper for dictionary arguments). There is a spectacular, but slightly illusory, improvement in runtime perf on T15426. I have documented the specifics in T15426 itself. Metric Decrease: T15426 - - - - - 1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00 Make debug a `Bool` not an `Int` in `StgToCmmConfig` We don't need any more resolution than this. Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer conveying any "level" information. - - - - - e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00 EPA : Remove duplicate comments in DataFamInstD The code data instance Method PGMigration = MigrationQuery Query -- ^ Run a query against the database | MigrationCode (Connection -> IO (Either String ())) -- ^ Run any arbitrary IO code Resulted in two instances of the "-- ^ Run a query against the database" comment appearing in the Exact Print Annotations when it was parsed. Ensure only one is kept. Closes #20239 - - - - - e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00 EPA: Comment Order Reversed Make sure comments captured in the exact print annotations are in order of increasing location Closes #20718 - - - - - 4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Add test for T21455 - - - - - e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Allow passing -po outside profiling way Resolves #21455 - - - - - 3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00 Fix haddock_*_perf tests on non-GNU-grep systems Using regexp pattern requires `egrep` and straight up `+`. The haddock_parser_perf and haddock_renamer_perf tests now pass on OpenBSD. They previously incorrectly parsed the files and awk complained about invalid syntax. - - - - - 1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00 hadrian/bindist: Drop redundant include of install.mk `install.mk` is already included by `config.mk`. Moreover, `install.mk` depends upon `config.mk` to set `RelocatableBuild`, making this first include incorrect. - - - - - f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00 Remove -z wxneeded for OpenBSD With all the recent W^X fixes in the loader this workaround is not necessary any longer. I verified that the only tests failing for me on OpenBSD 7.1-current are the same (libc++ related) before and after this commit (with --fast). - - - - - 7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00 Use UnionListsOrd instead of UnionLists in most places. This should get rid of most, if not all "Overlong lists" errors and fix #20016 - - - - - 81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00 Fix #21563 by using Word64 for 64bit shift code. We use the 64bit shifts only on 64bit platforms. But we compile the code always so compiling it on 32bit caused a lint error. So use Word64 instead. - - - - - 2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00 Fix compilation with -haddock on GHC <= 8.10 -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors when it encounters invalid haddock syntax. This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b enabled -haddock by default on many flavours. Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem managed to slip throught the cracks. - - - - - cfb9faff by sheaf at 2022-05-24T22:15:12-04:00 Hadrian: don't add "lib" for relocatable builds The conditional in hadrian/bindist/Makefile depended on the target OS, but it makes more sense to use whether we are using a relocatable build. (Currently this only gets set to true on Windows, but this ensures that the logic stays correctly coupled.) - - - - - 9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00 Remove HscEnv from GHC.HsToCore.Usage (related to #17957) Metric Decrease: T16875 - - - - - 2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00 SimpleOpt: beta-reduce through casts The simple optimiser would sometimes fail to beta-reduce a lambda when there were casts in between the lambda and its arguments. This can cause problems because we rely on representation-polymorphic lambdas getting beta-reduced away (for example, those that arise from newtype constructors with representation-polymorphic arguments, with UnliftedNewtypes). - - - - - e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00 Desugar RecordUpd in `tcExpr` This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule - - - - - 2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00 update README - - - - - 3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00 Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602) - - - - - ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00 Add Haddocks for `WwOpts` - - - - - da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00 Avoid global compiler state for `GHC.Core.Opt.WorkWrap` Progress towards #17957 - - - - - 3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00 Optimiser: avoid introducing bad rep-poly The functions `pushCoValArg` and `pushCoercionIntoLambda` could introduce bad representation-polymorphism. Example: type RR :: RuntimeRep type family RR where { RR = IntRep } type F :: TYPE RR type family F where { F = Int# } co = GRefl F (TYPE RR[0]) :: (F :: TYPE RR) ~# (F |> TYPE RR[0] :: TYPE IntRep) f :: F -> () `pushCoValArg` would transform the unproblematic application (f |> (co -> <()>)) (arg :: F |> TYPE RR[0]) into an application in which the argument does not have a fixed `RuntimeRep`: f ((arg |> sym co) :: (F :: TYPE RR)) - - - - - b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00 executablePath test: fix file extension treatment The executablePath test strips the file extension (if any) when comparing the query result with the expected value. This is to handle platforms where GHC adds a file extension to the output program file (e.g. .exe on Windows). After the initial check, the file gets deleted (if supported). However, it tries to delete the *stripped* filename, which is incorrect. The test currently passes only because Windows does not allow deleting the program while any process created from it is alive. Make the test program correct in general by deleting the *non-stripped* executable filename. - - - - - afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00 fix executablePath test for NetBSD executablePath support for NetBSD was added in a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not updated. Update the test so that it works for NetBSD. This requires handling some quirks: - The result of getExecutablePath could include "./" segments. Therefore use System.FilePath.equalFilePath to compare paths. - The sysctl(2) call returns the original executable name even after it was deleted. Add `canQueryAfterDelete :: [FilePath]` and adjust expectations for the post-delete query accordingly. Also add a note to the `executablePath` haddock to advise that NetBSD behaves differently from other OSes when the file has been deleted. Also accept a decrease in memory usage for T16875. On Windows, the metric is -2.2% of baseline, just outside the allowed ±2%. I don't see how this commit could have influenced this metric, so I suppose it's something in the CI environment. Metric Decrease: T16875 - - - - - d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00 Factor out `initArityOps` to `GHC.Driver.Config.*` module We want `DynFlags` only mentioned in `GHC.Driver`. - - - - - 44bb7111 by romes at 2022-05-26T16:27:57+00:00 TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs - - - - - 88e58600 by sheaf at 2022-05-26T17:38:43-04:00 Add tests for eta-expansion of data constructors This patch adds several tests relating to the eta-expansion of data constructors, including UnliftedNewtypes and DataTypeContexts. - - - - - d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00 Generalize breakTyVarCycle to work with TyFamLHS The function breakTyVarCycle_maybe has been installed in a dark corner of GHC to catch some gremlins (a.k.a. occurs-check failures) who lurk there. But it previously only caught gremlins of the form (a ~ ... F a ...), where some of our intrepid users have spawned gremlins of the form (G a ~ ... F (G a) ...). This commit improves breakTyVarCycle_maybe (and renames it to breakTyEqCycle_maybe) to catch the new gremlins. Happily, the change is remarkably small. The gory details are in Note [Type equality cycles]. Test cases: typecheck/should_compile/{T21515,T21473}. - - - - - ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00 [base] Fix the links in the Data.Data module fix #21658 fix #21657 fix #21657 - - - - - 3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00 Use a class to check validity of withDict This moves handling of the magic 'withDict' function from the desugarer to the typechecker. Details in Note [withDict]. I've extracted a part of T16646Fail to a separate file T16646Fail2, because the new error in 'reify' hides the errors from 'f' and 'g'. WithDict now works with casts, this fixes #21328. Part of #19915 - - - - - b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00 Fix FreeVars computation for mdo Commit acb188e0 introduced a regression in the computation of free variables in mdo statements, as the logic in GHC.Rename.Expr.segmentRecStmts was slightly different depending on whether the recursive do block corresponded to an mdo statement or a rec statment. This patch restores the previous computation for mdo blocks. Fixes #21654 - - - - - 0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00 T16875: Stabilise (temporarily) by increasing acceptance threshold The theory is that on windows there is some difference in the environment between pipelines on master and merge requests which affects all tests equally but because T16875 barely allocates anything it is the test which is affected the most. See #21557 - - - - - 6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00 make: Fix make maintainer-clean deleting a file tracked by source control Fixes #21659 - - - - - fbf2f254 by Bodigrim at 2022-05-28T21:01:58-04:00 Expand documentation of hIsTerminalDevice - - - - - 0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00 export IsList from GHC.IsList it is still re-exported from GHC.Exts - - - - - 91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00 MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR ARM64_RELOC_SUBTRACTOR relocations are paired with an AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2 The linker was doing it in two steps, basically: *addend <- *addend - sym2 *addend <- *addend + sym1 The first operation was likely to overflow. For example when the relocation target was 32-bit and both sym1/sym2 were 64-bit addresses. With the small memory model, (sym1-sym2) would fit in 32 bits but (*addend-sym2) may not. Now the linker does it in one step: *addend <- *addend + sym1 - sym2 - - - - - acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Some fixes to SRT documentation - reordered the 3 SRT implementation cases from the most general to the most specific one: USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD - added requirements for each - found and documented a confusion about "SRT inlining" not supported with MachO. (It is fixed in the following commit) - - - - - 5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Enable USE_INLINE_SRT_FIELD on ARM64 It was previously disabled because of: - a confusion about "SRT inlining" (see removed comment in this commit) - a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR relocation: fixed by a previous commit. - - - - - 59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00 ci: Make sure to exit promptly if `make install` fails. Due to the vageries of bash, you have to explicitly handle the failure and exit when in a function. This failed to exit promptly when !8247 was failing. See #21358 for the general issue - - - - - 5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00 Split GHC.HsToCore.Foreign.Decl This is preliminary work for JavaScript support. It's better to put the code handling the desugaring of Prim, C and JavaScript declarations into separate modules. - - - - - 6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00 Bump hadrian to LTS-19.8 (GHC 9.0.2) - - - - - f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00 Hadrian: remove unused code - - - - - 2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Eta reduction with casted function We want to be able to eta-reduce \x y. ((f x) |> co) y by pushing 'co' inwards. A very small change accommodates this See Note [Eta reduction with casted function] - - - - - f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Do arity trimming at bindings, rather than in exprArity Sometimes there are very large casts, and coercionRKind can be slow. - - - - - 610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make findRhsArity take RecFlag This avoids a fixpoint iteration for the common case of non-recursive bindings. - - - - - 80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Comments and white space - - - - - 0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make PrimOpId record levity This patch concerns #20155, part (1) The general idea is that since primops have curried bindings (currently in PrimOpWrappers.hs) we don't need to eta-expand them. But we /do/ need to eta-expand the levity-polymorphic ones, because they /don't/ have bindings. This patch makes a start in that direction, by identifying the levity-polymophic primops in the PrimOpId IdDetails constructor. For the moment, I'm still eta-expanding all primops (by saying that hasNoBinding returns True for all primops), because of the bug reported in #20155. But I hope that before long we can tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding. - - - - - 6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: * Move state-hack stuff from GHC.Types.Id (where it never belonged) to GHC.Core.Opt.Arity (which seems much more appropriate). * Add a crucial mkCast in the Cast case of GHC.Core.Opt.Arity.eta_expand; helps with T18223 * Add clarifying notes about eta-reducing to PAPs. See Note [Do not eta reduce PAPs] * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity, where it properly belongs. See Note [Eta reduce PAPs] * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for when eta-expansion is wanted, to make wantEtaExpansion, and all that same function in GHC.Core.Opt.Simplify.simplStableUnfolding. It was previously inconsistent, but it's doing the same thing. * I did a substantial refactor of ArityType; see Note [ArityType]. This allowed me to do away with the somewhat mysterious takeOneShots; more generally it allows arityType to describe the function, leaving its clients to decide how to use that information. I made ArityType abstract, so that clients have to use functions to access it. * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called mkLam before) aware of the floats that the simplifier builds up, so that it can still do eta-reduction even if there are some floats. (Previously that would not happen.) That means passing the floats to rebuildLam, and an extra check when eta-reducting (etaFloatOk). * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info in the idDemandInfo of the binder, as well as the CallArity info. The occurrence analyser did this but we were failing to take advantage here. In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity; see Note [Combining arityType with demand info], and functions idDemandOneShots and combineWithDemandOneShots. (These changes partly drove my refactoring of ArityType.) * In GHC.Core.Opt.Arity.findRhsArity * I'm now taking account of the demand on the binder to give extra one-shot info. E.g. if the fn is always called with two args, we can give better one-shot info on the binders than if we just look at the RHS. * Don't do any fixpointing in the non-recursive case -- simple short cut. * Trim arity inside the loop. See Note [Trim arity inside the loop] * Make SimpleOpt respect the eta-reduction flag (Some associated refactoring here.) * I made the CallCtxt which the Simplifier uses distinguish between recursive and non-recursive right-hand sides. data CallCtxt = ... | RhsCtxt RecFlag | ... It affects only one thing: - We call an RHS context interesting only if it is non-recursive see Note [RHS of lets] in GHC.Core.Unfold * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification. See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep. Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg Metrics: compile_time/bytes allocated Test Metric Baseline New value Change --------------------------------------------------------------------------------------- MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,743,297,692 2,619,762,992 -4.5% GOOD T18223(normal) ghc/alloc 1,103,161,360 972,415,992 -11.9% GOOD T3064(normal) ghc/alloc 201,222,500 184,085,360 -8.5% GOOD T8095(normal) ghc/alloc 3,216,292,528 3,254,416,960 +1.2% T9630(normal) ghc/alloc 1,514,131,032 1,557,719,312 +2.9% BAD parsing001(normal) ghc/alloc 530,409,812 525,077,696 -1.0% geo. mean -0.1% Nofib: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- banner +0.0% +0.4% -8.9% -8.7% 0.0% exact-reals +0.0% -7.4% -36.3% -37.4% 0.0% fannkuch-redux +0.0% -0.1% -1.0% -1.0% 0.0% fft2 -0.1% -0.2% -17.8% -19.2% 0.0% fluid +0.0% -1.3% -2.1% -2.1% 0.0% gg -0.0% +2.2% -0.2% -0.1% 0.0% spectral-norm +0.1% -0.2% 0.0% 0.0% 0.0% tak +0.0% -0.3% -9.8% -9.8% 0.0% x2n1 +0.0% -0.2% -3.2% -3.2% 0.0% -------------------------------------------------------------------------------- Min -3.5% -7.4% -58.7% -59.9% 0.0% Max +0.1% +2.2% +32.9% +32.9% 0.0% Geometric Mean -0.0% -0.1% -14.2% -14.8% -0.0% Metric Decrease: MultiLayerModulesTH_OneShot T18223 T3064 T15185 T14766 Metric Increase: T9630 - - - - - cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00 hadrian: Fix building from source-dist without alex/happy This fixes two bugs which were adding dependencies on alex/happy when building from a source dist. * When we try to pass `--with-alex` and `--with-happy` to cabal when configuring but the builders are not set. This is fixed by making them optional. * When we configure, cabal requires alex/happy because of the build-tool-depends fields. These are now made optional with a cabal flag (build-tool-depends) for compiler/hpc-bin/genprimopcode. Fixes #21627 - - - - - a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test the bootstrap without ALEX/HAPPY on path - - - - - 0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test bootstrapping in release jobs - - - - - d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label - - - - - 18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00 rts: Remove explicit timescale for deprecating -h flag We originally planned to remove the flag in 9.4 but there's actually no great rush to do so and it's probably less confusing (forever) to keep the message around suggesting an explicit profiling option. Fixes #21545 - - - - - eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00 Enable -dlint in hadrian lint transformer Now #21563 is fixed we can properly enable `-dlint` in CI rather than a subset of the flags. - - - - - 0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00 upload-ghc-libs: Allow candidate-only upload - - - - - 83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00 Avoid using DynFlags in GHC.Linker.Unit (#17957) - - - - - 5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00 hadrian: Introduce new package database for executables needed to build stage0 These executables (such as hsc2hs) are built using the boot compiler and crucially, most libraries from the global package database. We also move other build-time executables to be built in this stage such as linters which also cleans up which libraries end up in the global package database. This allows us to remove hacks where linters-common is removed from the package database when a bindist is created. This fixes issues caused by infinite recursion due to bytestring adding a dependency on template-haskell. Fixes #21634 - - - - - 0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00 Build stage1 with -V as well This helps tracing errors which happen when building stage1 - - - - - 15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00 Revert "packaging: Build perf builds with -split-sections" This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f. Split sections causes segfaults in profiling way with old toolchains (deb9) and on windows (#21670) Fixes #21670 - - - - - d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00 Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard Progress towards #17957 Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other modules as thoroughly as I usually do. This does mean that risk of `DynFlags` "creeping back in" is higher than it usually is. After we do the same process to the other Core passes, and then figure out what we want to do about `CoreM`, we can finish the job started here. That is a good deal more work, however, so it certainly makes sense to land this now. - - - - - a720322f by romes at 2022-06-01T07:44:44-04:00 Restore Note [Quasi-quote overview] - - - - - 392ce3fc by romes at 2022-06-01T07:44:44-04:00 Move UntypedSpliceFlavour from L.H.S to GHC.Hs UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr` but was defined in the client-independent L.H.S.Expr. - - - - - 7975202b by romes at 2022-06-01T07:44:44-04:00 TTG: Rework and improve splices This commit redefines the structure of Splices in the AST. We get rid of `HsSplice` which used to represent typed and untyped splices, quasi quotes, and the result of splicing either an expression, a type or a pattern. Instead we have `HsUntypedSplice` which models an untyped splice or a quasi quoter, which works in practice just like untyped splices. The `HsExpr` constructor `HsSpliceE` which used to be constructed with an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The former is directly constructed with an `HsExpr` and the latter now takes an `HsUntypedSplice`. Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now take an `HsUntypedSplice` instead of a `HsSplice` (remember only /untyped splices/ can be spliced as types or patterns). The result of splicing an expression, type, or pattern is now comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`, `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult (HsExpr GhcRn)` Overall the TTG extension points are now better used to make invalid states unrepresentable and model the progression between stages better. See Note [Lifecycle of an untyped splice, and PendingRnSplice] and Note [Lifecycle of an typed splice, and PendingTcSplice] for more details. Updates haddock submodule Fixes #21263 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - 320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00 Add test for #21619 Fixes #21619 - - - - - ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00 Pure Haskell implementation of GHC.Unicode Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/). Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691. - Remove current Unicode cbits. - Add generator for Unicode property files from Unicode Character Database. - Generate internal modules. - Update GHC.Unicode. - Add unicode003 test for general categories and case mappings. - Add Python scripts to check 'base' Unicode tests outputs and characters properties. Fixes #21375 ------------------------- Metric Decrease: T16875 Metric Increase: T4029 T18304 haddock.base ------------------------- - - - - - 514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00 typos - - - - - 9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00 source-dist: Copy in files created by ./boot Since we started producing source dists with hadrian we stopped copying in the files created by ./boot which adds a dependency on python3 and autoreconf. This adds back in the files which were created by running configure. Fixes #21673 #21672 and #21626 - - - - - a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00 ci: Don't try to run ./boot when testing bootstrap of source dist - - - - - e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00 Language.Haskell.Syntax: Fix docs for PromotedConsT etc. Fixes ghc/ghc#21675. - - - - - 87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump bytestring, process, and text submodules Metric Decrease: T5631 Metric Increase: T18223 (cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af) - - - - - 24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump Cabal submodule To current `master`. (cherry picked from commit fbb59c212415188486aafd970eafef170516356a) - - - - - 5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00 hadrian/tool-args: Write output to intermediate file rather than via stdout This allows us to see the output of hadrian while it is doing the setup. - - - - - 468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00 Make -fcompact-unwind the default This is a follow-up to !7247 (closed) making the inclusion of compact unwinding sections the default. Also a slight refactoring/simplification of the flag handling to add -fno-compact-unwind. - - - - - 819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00 hadrian bootstrap: add plans for 9.0.2 and 9.2.3 - - - - - 9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00 ci: Add matrix for bootstrap sources - - - - - ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00 HsToCore.Coverage: Improve haddocks - - - - - f065804e by John Ericson at 2022-06-02T15:42:59+00:00 Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller No need to inline traversing a maybe for `mkModBreaks`. And better to make each function do one thing and let the caller deside when than scatter the decision making and make the caller seem more imperative. - - - - - d550d907 by John Ericson at 2022-06-02T15:42:59+00:00 Rename `HsToCore.{Coverage -> Ticks}` The old name made it confusing why disabling HPC didn't disable the entire pass. The name makes it clear --- there are other reasons to add ticks in addition. - - - - - 6520da95 by John Ericson at 2022-06-02T15:42:59+00:00 Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq` As proposed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676, `GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and backend-specific (only for the bytecode interpreter), and mix entry writing is just for HPC. With this split we separate out those interpreter- and HPC-specific its, and keep the main `GHC.HsToCore.Ticks` agnostic. Also, instead of passing the reversed list and count around, we use `SizedSeq` which abstracts over the algorithm. This is much nicer to avoid noise and prevents bugs. (The bugs are not just hypothetical! I missed up the reverses on an earlier draft of this commit.) - - - - - 1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00 GHC.HsToCore.Breakpoints: Slightly improve perf We have the length already, so we might as well use that rather than O(n) recomputing it. - - - - - 5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00 HsToCore.Coverage: Purge DynFlags Finishes what !7467 (closed) started. Progress towards #17957 - - - - - 9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00 Deprecate TypeInType extension This commit fixes #20312 It deprecates "TypeInType" extension according to the following proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst It has been already implemented. The migration strategy: 1. Disable TypeInType 2. Enable both DataKinds and PolyKinds extensions Metric Decrease: T16875 - - - - - f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00 Diagnostics conversions, part 6 (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and `GHC.Tc.Gen.Sig`. - - - - - 04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00 Ensure floated dictionaries are in scope (again) In the Specialiser, we missed one more call to bringFloatedDictsIntoScope (see #21391). This omission led to #21689. The problem is that the call to `rewriteClassOps` needs to have in scope any dictionaries floated out of the arguments we have just specialised. Easy fix. - - - - - a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00 Don't print the number of deps in count-deps tests It is redundant information and a source of needless version control conflicts when multiple MRs are changing the deps list. Just printing the list and not also its length is fine. - - - - - a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00 Core.Lint: Reduce `DynFlags` and `HscEnv` Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com> - - - - - 56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00 Fix a CSE shadowing bug. We used to process the rhs of non-recursive bindings and their body using the same env. If we had something like let x = ... x ... this caused trouble because the two xs refer to different binders but we would substitute both for a new binder x2 causing out of scope errors. We now simply use two different envs for the rhs and body in cse_bind. It's all explained in the Note [Separate envs for let rhs and body] Fixes #21685 - - - - - 28880828 by sheaf at 2022-06-09T09:12:19-04:00 Typecheck remaining ValArgs in rebuildHsApps This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it to tcRemainingValArgs. The logic is moved to rebuildHsApps, which ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg. This patch also refactors the treatment of stupid theta for data constructors, changing the place we drop stupid theta arguments from dsConLike to mkDataConRep (now the datacon wrapper drops these arguments). We decided not to implement PHASE 2 of the FixedRuntimeRep plan for these remaining ValArgs. Future directions are outlined on the wiki: https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs Fixes #21544 and #21650 - - - - - 1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00 Add test for T21682 Fixes #21682 - - - - - 8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00 Document dataToTag# primop - - - - - 7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00 Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115 - - - - - 46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00 Fix TcRnPragmaWarning meaning - - - - - 69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00 getProcessCPUTime: Fix the getrusage fallback to account for system CPU time clock_gettime reports the combined total or user AND system time so in order to replicate it with getrusage we need to add both system and user time together. See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime Some sample measurements when building Cabal with this patch t1: rusage t2: clock_gettime t1: 62347518000; t2: 62347520873 t1: 62395687000; t2: 62395690171 t1: 62432435000; t2: 62432437313 t1: 62478489000; t2: 62478492465 t1: 62514990000; t2: 62514992534 t1: 62515479000; t2: 62515480327 t1: 62515485000; t2: 62515486344 Fixes #21656 - - - - - 722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00 Use <br> instead of newline character - - - - - dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00 Use (fixed_lev = True) in mkDataTyConRhs - - - - - ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00 hadrian: Fix testing stage1 compiler There were various issues with testing the stage1 compiler.. 1. The wrapper was not being built 2. The wrapper was picking up the stage0 package database and trying to load prelude from that. 3. The wrappers never worked on windows so just don't support that for now. Fixes #21072 - - - - - ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00 validate: Ensure that $make variable is set Currently the `$make` variable is used without being set in `validate`'s Hadrian path, which uses make to install the binary distribution. Fix this. Fixes #21687. - - - - - 59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00 CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv` The call sites in `Driver.Main` are duplicative, but this is good, because the next step is to remove `InteractiveContext` from `Core.Lint` into `Core.Lint.Interactive`. Also further clean up `Core.Lint` to use a better configuration record than the one we initially added. - - - - - aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00 hadrian: Run xattr -rc . on bindist tarball Fixes #21506. - - - - - cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00 configure: Hide spurious warning from ld Previously the check_for_gold_t22266 configure check could result in spurious warnings coming from the linker being blurted to stderr. Suppress these by piping stderr to /dev/null. - - - - - e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00 cmm: Add surface syntax for MO_MulMayOflo - - - - - bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00 configure: Don't attempt to override linker on Darwin Configure's --enable-ld-override functionality is intended to ensure that we don't rely on ld.bfd, which tends to be slow and buggy, on Linux and Windows. However, on Darwin the lack of sensible package management makes it extremely easy for users to have awkward mixtures of toolchain components from, e.g., XCode, the Apple Command-Line Tools package, and homebrew. This leads to extremely confusing problems like #21712. Here we avoid this by simply giving up on linker selection on Darwin altogether. This isn't so bad since the Apple ld64 linker has decent performance and AFAICT fairly reliable. Closes #21712. - - - - - 25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00 replace quadratic nub to fight byte code gen perf explosion Despite this code having been present in the core-to-bytecode implementation, I have observed it in the wild starting with 9.2, causing enormous slowdown in certain situations. My test case produces the following profiles: Before: ``` total time = 559.77 secs (559766 ticks @ 1000 us, 1 processor) total alloc = 513,985,665,640 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes elem_by Data.OldList libraries/base/Data/OldList.hs:429:1-7 67.6 92.9 378282 477447404296 eqInt GHC.Classes libraries/ghc-prim/GHC/Classes.hs:275:8-14 12.4 0.0 69333 32 $c>>= GHC.Data.IOEnv <no location info> 6.9 0.6 38475 3020371232 ``` After: ``` total time = 89.83 secs (89833 ticks @ 1000 us, 1 processor) total alloc = 39,365,306,360 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes $c>>= GHC.Data.IOEnv <no location info> 43.6 7.7 39156 3020403424 doCase GHC.StgToByteCode compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53) 2.5 7.4 2246 2920777088 ``` - - - - - aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00 hadrian: Don't install `include/` directory in bindist. The install_includes for the RTS package used to be put in the top-level ./include folder but this would lead to confusing things happening if you installed multiple GHC versions side-by-side. We don't need this folder anymore because install-includes is honoured properly by cabal and the relevant header files already copied in by the cabal installation process. If you want to depend on the header files for the RTS in a Haskell project then you just have to depend on the `rts` package and the correct include directories will be provided for you. If you want to depend on the header files in a standard C project then you should query ghc-pkg to get the right paths. ``` ghc-pkg field rts include-dirs --simple-output ``` Fixes #21609 - - - - - 03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00 Enable eventlogs on nightly perf job - - - - - ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00 Repair dead link in TH haddocks Closes #21724 - - - - - 99ff3818 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian: allow configuring Hsc2Hs This patch adds the ability to pass options to Hsc2Hs as Hadrian key/value settings, in the same way as cabal configure options, using the syntax: *.*.hsc2hs.run.opts += ... - - - - - 9c575f24 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian bootstrap: look up hsc2hs Hadrian bootstrapping looks up where to find ghc_pkg, but the same logic was not in place for hsc2hs which meant we could fail to find the appropriate hsc2hs executabe when bootstrapping Hadrian. This patch adds that missing logic. - - - - - 229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Add (broken) test for #21622 - - - - - cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Don't Box NULL pointers Previously we could construct a `Box` of a NULL pointer from the `link` field of `StgWeak`. Now we take care to avoid ever introducing such pointers in `collect_pointers` and ensure that the `link` field is represented as a `Maybe` in the `Closure` type. Fixes #21622 - - - - - 31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00 winio: Add support to console handles to handleToHANDLE - - - - - 711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Add SMUL[LH] instructions These will be needed to fix #21624. - - - - - d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Fix syntax of OpRegShift operands Previously this produced invalid assembly containing a redundant comma. - - - - - a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00 ncg/aarch64: Fix implementation of IntMulMayOflo The code generated for IntMulMayOflo was previously wrong as it depended upon the overflow flag, which the AArch64 MUL instruction does not set. Fix this. Fixes #21624. - - - - - 26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00 testsuite: Add test for #21624 Ensuring that mulIntMayOflo# behaves as expected. - - - - - 94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00 CprAnal: Set signatures of DFuns to top The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal that is observable in a debug build. The CPR signature of a recursive DFunId was never updated and hence the optimistic arity 0 bottom signature triggered a mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any code because WW doesn't exploit bottom CPR signatures. - - - - - b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00 CorePrep: Don't speculatively evaluate recursive calls (#20836) In #20836 we have optimised a terminating program into an endless loop, because we speculated the self-recursive call of a recursive DFun. Now we track the set of enclosing recursive binders in CorePrep to prevent speculation of such self-recursive calls. See the updates to Note [Speculative evaluation] for details. Fixes #20836. - - - - - 49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00 Simplify: Take care with eta reduction in recursive RHSs (#21652) Similar to the fix to #20836 in CorePrep, we now track the set of enclosing recursive binders in the SimplEnv and SimpleOptEnv. See Note [Eta reduction in recursive RHSs] for details. I also updated Note [Arity robustness] with the insights Simon and I had in a call discussing the issue. Fixes #21652. Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation of a large list literal at the top-level that didn't happen before (presumably because it was too interesting to float to the top-level). There's not much we can do about that. Metric Increase: T16577 - - - - - 2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00 Ignore .hie-bios - - - - - e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00 Instantiate top level foralls in partial type signatures The main fix for #21667 is the new call to tcInstTypeBnders in tcHsPartialSigType. It was really a simple omission before. I also moved the decision about whether we need to apply the Monomorphism Restriction, from `decideGeneralisationPlan` to `tcPolyInfer`. That removes a flag from the InferGen constructor, which is good. But more importantly, it allows the new function, checkMonomorphismRestriction called from `tcPolyInfer`, to "see" the `Types` involved rather than the `HsTypes`. And that in turn matters because we invoke the MR for partial signatures if none of the partial signatures in the group have any overloading context; and we can't answer that question for HsTypes. See Note [Partial type signatures and the monomorphism restriction] in GHC.Tc.Gen.Bind. This latter is really a pre-existing bug. - - - - - 262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00 Make Outputable instance for InlineSig print the InlineSpec Fix ghc/ghc#21739 Squash fix ghc/ghc#21739 - - - - - b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00 Add NO_BOOT to hackage_doc_tarball job We were attempting to boot a src-tarball which doesn't work as ./boot is not included in the source tarball. This slipped through as the job is only run on nightly. - - - - - d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00 HsToken for @-patterns and TypeApplications (#19623) One more step towards the new design of EPA. - - - - - 159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00 linker: only keep rtl exception tables if they have been relocated - - - - - da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00 Ticky:Make json info a separate field. - - - - - 1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00 Revert "Ticky:Make json info a separate field." This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862. This was pushed directly without review. - - - - - f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00 Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags These flags affect the behaviour of local let floating. If `-flocal-float-out` is disabled (the default) then we disable all local floating. ``` …(let x = let y = e in (a,b) in body)... ===> …(let y = e; x = (a,b) in body)... ``` Further to this, top-level local floating can be disabled on it's own by passing -fno-local-float-out-top-level. ``` x = let y = e in (a,b) ===> y = e; x = (a,b) ``` Note that this is only about local floating, ie, floating two adjacent lets past each other and doesn't say anything about the global floating pass which is controlled by `-fno-float`. Fixes #13663 - - - - - 4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00 Check for Int overflows in Data.Array.Byte - - - - - 2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00 Add a basic test for ByteArray's Monoid instance - - - - - fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00 Rename `copyByteArray` to `unsafeCopyByteArray` - - - - - ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00 testsuite: Add test for #21719 Happily, this has been fixed since 9.2. - - - - - 19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Use lookupNameCache instead of lookupOrigIO - - - - - 4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Break out thNameToGhcNameIO (ref. #21730) - - - - - eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00 Add laws for 'toInteger' and 'toRational' CLC discussion here: https://github.com/haskell/core-libraries-committee/issues/58 - - - - - c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00 Correct documentation of defaults of the `-V` RTS option - - - - - b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00 Transcribe discussion from #21483 into a Note In #21483 I had a discussion with Simon Marlow about the memory retention behaviour of -Fd. I have just transcribed that conversation here as it elucidates the potentially subtle assumptions which led to the design of the memory retention behaviours of -Fd. Fixes #21483 - - - - - 980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00 eventlog: Don't leave dangling pointers hanging around Previously we failed to reset pointers to various eventlog buffers to NULL after freeing them. In principle we shouldn't look at them after they are freed but nevertheless it is good practice to set them to a well-defined value. - - - - - 575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00 runhaskell - - - - - e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00 re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45 - - - - - 5d45aa97 by Gergo ERDI at 2022-06-22T22:00:46-04:00 When specialising, look through floatable ticks. Fixes #21697. - - - - - 531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00 TagCheck.hs: Properly check if arguments are boxed types. For one by mistake I had been checking against the kind of runtime rep instead of the boxity. This uncovered another bug, namely that we tried to generate the checking code before we had associated the function arguments with a register, so this could never have worked to begin with. This fixes #21729 and both of the above issues. - - - - - c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00 Use correct arch for the FreeBSD triple in gen-data-layout.sh Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798 Relevant upstream issue: #15718 - - - - - 75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00 Bump nofib submodule. Allows the shake runner to build with 9.2.3 among other things. Fixes #21772 - - - - - 0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00 Bump ghc-prim and base versions To 0.9.0 and 4.17.0 respectively. Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm, terminfo, text, unix, haddock, and hsc2hs submodules. (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095) - - - - - 4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00 testsuite: Use normalise_version more consistently Previously several tests' output were unnecessarily dependent on version numbers, particularly of `base`. Fix this. - - - - - d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00 linters: Fix lint-submodule-refs when crashing trying to find plausible branches - - - - - 38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 hadrian: Improve haddocks for ghcDebugAssertions - - - - - ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 Don't mark lambda binders as OtherCon We used to put OtherCon unfoldings on lambda binders of workers and sometimes also join points/specializations with with the assumption that since the wrapper would force these arguments once we execute the RHS they would indeed be in WHNF. This was wrong for reasons detailed in #21472. So now we purge evaluated unfoldings from *all* lambda binders. This fixes #21472, but at the cost of sometimes not using as efficient a calling convention. It can also change inlining behaviour as some occurances will no longer look like value arguments when they did before. As consequence we also change how we compute CBV information for arguments slightly. We now *always* determine the CBV convention for arguments during tidy. Earlier in the pipeline we merely mark functions as candidates for having their arguments treated as CBV. As before the process is described in the relevant notes: Note [CBV Function Ids] Note [Attaching CBV Marks to ids] Note [Never put `OtherCon` unfoldigns on lambda binders] ------------------------- Metric Decrease: T12425 T13035 T18223 T18223 T18923 MultiLayerModulesTH_OneShot Metric Increase: WWRec ------------------------- - - - - - 06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00 Add suggestions for unrecognised pragmas (#21589) In case of a misspelled pragma, offer possible corrections as to what the user could have meant. Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589 - - - - - 3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00 Remove the traces of i386-*-openbsd, long live amd64 OpenBSD will not ship any ghc packages on i386 starting with 7.2 release. This means there will not be a bootstrap compiler easily available. The last available binaries are ghc-8.10.6 which is already not supported as bootstrap for HEAD. See here for more information: https://marc.info/?l=openbsd-ports&m=165060700222580&w=2 - - - - - 58530271 by Bodigrim at 2022-06-27T08:03:34-04:00 Add Foldable1 and Bifoldable1 type classes Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9 Instances roughly follow https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1 but the API of `Foldable1` was expanded in comparison to `semigroupoids`. Compatibility shim is available from https://github.com/phadej/foldable1 (to be released). Closes #13573. - - - - - a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00 add levity polymorphism to addrToAny# - - - - - f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00 add tests for addrToAny# levity - - - - - 07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00 hadrian: Update main README page This README had some quite out-of-date content about the build system so I did a complete pass deleting old material. I also made the section about flavours more prominent and mentioned flavour transformers. - - - - - 79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00 testsuite: Hide output from test compilations with verbosity==2 Previously the output from test compilations used to determine whether, e.g., profiling libraries are available was shown with verbosity levels >= 2. However, the default level is 2, meaning that most users were often spammed with confusing errors. Fix this by bumping the verbosity threshold for this output to >=3. Fixes #21760. - - - - - 995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00 configure: Only probe for LD in FIND_LD Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD rather early in `configure`. However, it turns out that this breaks `configure`'s `ld`-override logic, which assumes that `LD` was set by the user and aborts. Fixes #21778. - - - - - b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00 `.hs-boot` make rules: add missing order-only dependency on target directory Noticed missing target directory dependency as a build failure in `make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100): "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254 make: *** [Makefile:128: all] Error 2 shuffle=1656129254 Note that `cp` complains about inability to create target file. The change adds order-only dependency on a target directory (similar to the rest of rules in that file). The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build system megapatch`.) where upfront directory creation was never added to `.hs-boot` files. - - - - - 57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00 Mark AArch64/Darwin as requiring sign-extension Apple's AArch64 ABI requires that the caller sign-extend small integer arguments. Set platformCConvNeedsExtension to reflect this fact. Fixes #21773. - - - - - df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00 -ddump-llvm shouldn't imply -fllvm Previously -ddump-llvm would change the backend used, which contrasts with all other dump flags. This is quite surprising and cost me quite a bit of time. Dump flags should not change compiler behavior. Fixes #21776. - - - - - 70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Re-format argument handling logic Previously there were very long, hard to parse lines. Fix this. - - - - - 696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Sign-extend narrow C arguments The AArch64/Darwin ABI requires that function arguments narrower than 32-bits must be sign-extended by the caller. We neglected to do this, resulting in #20735. Fixes #20735. - - - - - c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00 testsuite: Add test for #20735 - - - - - 16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00 integer-gmp: Fix cabal file Evidently fields may not come after sections in a cabal file. - - - - - 03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00 ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist) before the change `make install` was failing as: ``` "mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc" make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'. Stop. ``` I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf` is created (somewhat manually), but not the .install varianlt of it. The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere. Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784 - - - - - eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00 Comments only, about join points This MR just adds some documentation about why casts destroy join points, following #21716. - - - - - 251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00 Cleanup BuiltInSyntax vs UserSyntax There was some confusion about whether FUN/TYPE/One/Many should be BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as BuiltInSyntax is for things which are directly constructed by the parser rather than going through normal renaming channels. I fixed all the obviously wrong places I could find and added a test for the original bug which was caused by this (#21752) Fixes #21752 #20695 #18302 - - - - - 0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00 template-haskell: Bump version to 2.19.0.0 Bumps text and exceptions submodules due to bounds. - - - - - bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00 Tiny tweak to `IOPort#` documentation The exclamation mark and bracket don’t seem to make sense here. I’ve looked through the history, and I don’t think they’re deliberate – possibly a copy-and-paste error. - - - - - 70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00 Remove `CoreOccurAnal` constructor of the `CoreToDo` type It was dead code since the last occurence in an expression context got removed in 71916e1c018dded2e68d6769a2dbb8777da12664. - - - - - d0722170 by nineonine at 2022-07-01T08:15:56-04:00 Fix panic with UnliftedFFITypes+CApiFFI (#14624) When declaring foreign import using CAPI calling convention, using unlifted unboxed types would result in compiler panic. There was an attempt to fix the situation in #9274, however it only addressed some of the ByteArray cases. This patch fixes other missed cases for all prims that may be used as basic foreign types. - - - - - eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00 rts: gc stats: account properly for copied bytes in sequential collections We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow] counters during sequential collections. As well, we were double counting for parallel collections. To fix this we add an `else` clause to the `if (is_par_gc())`. The par_* counters do not need to be updated in the sequential case because they must be 0. - - - - - f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00 desugar: Look through ticks when warning about possible literal overflow Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up between the appliation of `neg` to its argument. This defeated the special logic which looks for `NegApp ... (HsOverLit` to warn about possible overflow if a user writes a negative literal (without out NegativeLiterals) in their code. Fixes #21701 - - - - - f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00 ci: Fix definition of slow-validate flavour (so that -dlint) is passed In this embarassing sequence of events we were running slow-validate without -dlint. - - - - - bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00 Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411 - - - - - 9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00 Data.Foldable1: Remove references to Foldable-specific note ...as discussed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455. - - - - - 3a8970ac by romes at 2022-07-03T14:11:31-04:00 TTG: Move HsModule to L.H.S Move the definition of HsModule defined in GHC.Hs to Language.Haskell.Syntax with an added TTG parameter and corresponding extension fields. This is progress towards having the haskell-syntax package, as described in #21592 - - - - - f9f80995 by romes at 2022-07-03T14:11:31-04:00 TTG: Move ImpExp client-independent bits to L.H.S.ImpExp Move the GHC-independent definitions from GHC.Hs.ImpExp to Language.Haskell.Syntax.ImpExp with the required TTG extension fields such as to keep the AST independent from GHC. This is progress towards having the haskell-syntax package, as described in #21592 Bumps haddock submodule - - - - - c43dbac0 by romes at 2022-07-03T14:11:31-04:00 Refactor ModuleName to L.H.S.Module.Name ModuleName used to live in GHC.Unit.Module.Name. In this commit, the definition of ModuleName and its associated functions are moved to Language.Haskell.Syntax.Module.Name according to the current plan towards making the AST GHC-independent. The instances for ModuleName for Outputable, Uniquable and Binary were moved to the module in which the class is defined because these instances depend on GHC. The instance of Eq for ModuleName is slightly changed to no longer depend on unique explicitly and instead uses FastString's instance of Eq. - - - - - 2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00 Expand `Ord` instance for `Down` Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610 - - - - - 36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00 Add applyWhen to Data.Function per CLC prop Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233 - - - - - 3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00 hadrian: Don't read package environments in ghc-stage1 wrapper The stage1 compiler may be on the brink of existence and not have even a working base library. You may have installed packages globally with a similar stage2 compiler which will then lead to arguments such as --show-iface not even working because you are passing too many package flags. The solution is simple, don't read these implicit files. Fixes #21803 - - - - - aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00 Ticky:Make json info a separate field. Fixes #21233 - - - - - 74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00 Add docs:<pkg> command to hadrian to build docs for just one package - - - - - 418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00 upload-docs: propagate publish correctly in upload_sdist - - - - - ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00 docs-upload: Fix upload script when no packages are listed - - - - - d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00 hadrian: Add --haddock-base-url option for specifying base-url when generating docs The motiviation for this flag is to be able to produce documentation which is suitable for uploading for hackage, ie, the cross-package links work correctly. There are basically three values you want to set this to: * off - default, base_url = ../%pkg% which works for local browsing * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation. The `%pkg%` string is a template variable which is replaced with the package identifier for the relevant package. This is one step towards fixing #21749 - - - - - 41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00 Add nightly job for generating docs suitable for hackage upload - - - - - 620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00 ghci: Support :set prompt in multi repl This adds supports for various :set commands apart from `:set <FLAG>` in multi repl, this includes `:set prompt` and so-on. Fixes #21796 - - - - - b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00 Vendor filepath inside template-haskell Adding filepath as a dependency of template-haskell means that it can't be reinstalled if any build-plan depends on template-haskell. This is a temporary solution for the 9.4 release. A longer term solution is to split-up the template-haskell package into the wired-in part and a non-wired-in part which can be reinstalled. This was deemed quite risky on the 9.4 release timescale. Fixes #21738 - - - - - c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00 Factor fields of `CoreDoSimplify` into separate data type This avoids some partiality. The work @mmhat is doing cleaning up and modularizing `Core.Opt` will build on this nicely. - - - - - d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00 https urls - - - - - 803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00 options and typos - - - - - 5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00 grammar - - - - - 4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00 sources - - - - - c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00 Fix lint warnings in bootstrap.py - - - - - 86ced2ad by romes at 2022-07-06T01:36:23-04:00 Restore Eq instance of ImportDeclQualifiedStyle Fixes #21819 - - - - - 3547e264 by romes at 2022-07-06T13:50:27-04:00 Prune L.H.S modules of GHC dependencies Move around datatypes, functions and instances that are GHC-specific out of the `Language.Haskell.Syntax.*` modules to reduce the GHC dependencies in them -- progressing towards #21592 Creates a module `Language.Haskell.Syntax.Basic` to hold basic definitions required by the other L.H.S modules (and don't belong in any of them) - - - - - e4eea07b by romes at 2022-07-06T13:50:27-04:00 TTG: Move CoreTickish out of LHS.Binds Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and move them to the extension point instance, according to the plan outlined in #21592 to separate the base AST from the GHC specific bits. - - - - - acc1816b by romes at 2022-07-06T13:50:27-04:00 TTG for ForeignImport/Export Add a TTG parameter to both `ForeignImport` and `ForeignExport` and, according to #21592, move the GHC-specific bits in them and in the other AST data types related to foreign imports and exports to the TTG extension point. - - - - - 371c5ecf by romes at 2022-07-06T13:50:27-04:00 TTG for HsTyLit Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText` fields to the extension point and out of the base AST. Progress towards #21592 - - - - - fd379d1b by romes at 2022-07-06T13:50:27-04:00 Remove many GHC dependencies from L.H.S Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC imports according to the plan in the linked issue. Moves more GHC-specific declarations to `GHC.*` and brings more required GHC-independent declarations to `Language.Haskell.Syntax.*` (extending e.g. `Language.Haskell.Syntax.Basic`). Progress towards #21592 Bump haddock submodule for !8308 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00 Fix exact printing of the HsRule name Prior to this branch, the HsRule name was XRec pass (SourceText,RuleName) and there is an ExactPrint instance for (SourceText, RuleName). The SourceText has moved to a different location, so synthesise the original to trigger the correct instance when printing. We need both the SourceText and RuleName when exact printing, as it is possible to have a NoSourceText variant, in which case we fall back to the FastString. - - - - - 665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00 driver: Fix issue with module loops and multiple home units We were attempting to rehydrate all dependencies of a particular module, but we actually only needed to rehydrate those of the current package (as those are the ones participating in the loop). This fixes loading GHC into a multi-unit session. Fixes #21814 - - - - - bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00 Remove a bogus #define from ClosureMacros.h - - - - - fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00 winio: make consoleReadNonBlocking not wait for any events at all. - - - - - 42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00 rts: allow NULL to be used as an invalid StgStablePtr - - - - - 3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00 RTS: Add stack marker to StgCRunAsm.S Every object file must be properly marked for non-executable stack, even if it contains no code. - - - - - a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00 Bump unix submodule Adds `config.sub` to unix's `.gitignore`, fixing #19574. - - - - - 3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00 ghci: Fix most calls to isLoaded to work in multi-mode The most egrarious thing this fixes is the report about the total number of loaded modules after starting a session. Ticket #20889 - - - - - fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00 Enable :edit command in ghci multi-mode. This works after the last change to isLoaded. Ticket #20888 - - - - - 46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00 Fix a scoping bug in the Specialiser In the call to `specLookupRule` in `already_covered`, in `specCalls`, we need an in-scope set that includes the free vars of the arguments. But we simply were not guaranteeing that: did not include the `rule_bndrs`. Easily fixed. I'm not sure how how this bug has lain for quite so long without biting us. Fixes #21828. - - - - - 6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Edit Note [idArity varies independently of dmdTypeDepth] ...and refer to it in GHC.Core.Lint.lintLetBind. Fixes #21452 - - - - - 89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Tiny documentation wibbles (comments only) - - - - - 61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix readme - - - - - 61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix bootstrap - - - - - 8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00 tarball - - - - - e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Fix scopes for deriving clauses and instance signatures (#18425) - - - - - c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Record location of filled in default method bindings This is useful for hie files to reconstruct the evidence that default methods depend on. - - - - - 9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00 testsuite: Factor out common parts from hiefile tests - - - - - 6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00 Hadrian: update documentation of settings The documentation for key-value settings was a bit out of date. This patch updates it to account for `cabal.configure.opts` and `hsc2hs.run.opts`. The user-settings document was also re-arranged, to make the key-value settings more prominent (as it doesn't involve changing the Hadrian source code, and thus doesn't require any recompilation of Hadrian). - - - - - a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00 Fix potential space leak that arise from ModuleGraphs retaining references to previous ModuleGraphs, in particular the lazy `mg_non_boot` field. This manifests in `extendMG`. Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which is only called in two places in the compiler, and should only be called at most once for every home unit: GHC.Driver.Make: mainModuleSrcPath :: Maybe String mainModuleSrcPath = do ms <- mgLookupModule mod_graph (mainModIs hue) ml_hs_file (ms_location ms) GHCI.UI: listModuleLine modl line = do graph <- GHC.getModuleGraph let this = GHC.mgLookupModule graph modl Instead `mgLookupModule` can be a linear function that looks through the entire list of `ModuleGraphNodes` Fixes #21816 - - - - - dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00 rts: Fix AdjustorPool bitmap manipulation Previously the implementation of bitmap_first_unset assumed that `__builtin_clz` would accept `uint8_t` however it apparently rather extends its argument to `unsigned int`. To fix this we simply revert to a naive implementation since handling the various corner cases with `clz` is quite tricky. This should be fine given that AdjustorPool isn't particularly hot. Ideally we would have a single, optimised bitmap implementation in the RTS but I'll leave this for future work. Fixes #21838. - - - - - ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00 Change GHCi bytecode return convention for unlifted datatypes. This changes the bytecode return convention for unlifted algebraic datatypes to be the same as for lifted types, i.e. ENTER/PUSH_ALTS instead of RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED Fixes #20849 - - - - - 5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00 Compute record-dot-syntax types Ensures type information for record-dot-syntax is included in HieASTs. See #21797 - - - - - 89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00 Add record-dot-syntax test - - - - - 4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00 Document RuntimeRep polymorphism limitations of catch#, et al As noted in #21868, several primops accepting continuations producing RuntimeRep-polymorphic results aren't nearly as polymorphic as their types suggest. Document this limitation and adapt the `UnliftedWeakPtr` test to avoid breaking this limitation in `keepAlive#`. - - - - - 4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00 Make keepAlive# out-of-line This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203 - - - - - 1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00 Suppress extra output from configure check for c++ libraries - - - - - 3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00 rel-notes: Drop mention of #21745 fix Since we have backported the fix to 9.4.1. - - - - - b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00 Align the behaviour of `dopt` and `log_dopt` Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying function `log_dopt`) were different as the latter did not take the verbosity level into account. This led to problems during the refactoring as we cannot simply replace calls to `dopt` with calls to `logHasDumpFlag`. In addition to that a subtle bug in the GHC module was fixed: `setSessionDynFlags` did not update the logger and as a consequence the verbosity value of the logger was not set appropriately. Fixes #21861 - - - - - 28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00 rts: forkOn context switches the target capability Fixes #21824 - - - - - f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Eliminate orphan Outputable instances Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and `OutputableP` instances for the Cmm AST. This makes it significantly easier to use the Cmm pretty-printers in tracing output without incurring module import cycles. - - - - - f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Move toBlockList to GHC.Cmm - - - - - fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00 compiler: Add haddock sections to GHC.Utils.Panic - - - - - 097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00 configure: Don't override Windows CXXFLAGS At some point we used the clang distribution from msys2's `MINGW64` environment for our Windows toolchain. This defaulted to using libgcc and libstdc++ for its runtime library. However, we found for a variety of reasons that compiler-rt, libunwind, and libc++ were more reliable, consequently we explicitly overrode the CXXFLAGS to use these. However, since then we have switched to use the `CLANG64` packaging, which default to these already. Consequently we can drop these arguments, silencing some redundant argument warnings from clang. Fixes #21669. - - - - - e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Check that there are no NULL ctors - - - - - 616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Introduce support for invoking finalizers on unload Addresses #20494. - - - - - cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add T20494 - - - - - 03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Rename finit field to fini fini is short for "finalizer", which does not contain a "t". - - - - - 033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Refactor handling of oc->info Previously we would free oc->info after running initializers. However, we can't do this is we want to also run finalizers. Moreover, freeing oc->info so early was wrong for another reason: we will need it in order to unregister the exception tables (see the call to `RtlDeleteFunctionTable`). In service of #20494. - - - - - f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Add finalization support This implements #20494 for the PEi386 linker. Happily, this also appears to fix `T9405`, resolving #21361. - - - - - 2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00 Loader: Implement gnu-style -l:$path syntax Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic. - - - - - 5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00 Statically-link against libc++ on Windows Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435. - - - - - 8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run It turns out that PE objects may have multiple `.ctors`/`.dtors` sections but the RTS linker had assumed that there was only one. Fix this. Fixes #21618. - - - - - fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Respect dtor/ctor priority Previously we would run constructors and destructors in arbitrary order despite explicit priorities. Fixes #21847. - - - - - 1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add test for #21618 and #21847 - - - - - 6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Fix exception unwind unregistration RtlDeleteFunctionTable expects a pointer to the .pdata section yet we passed it the .xdata section. Happily, this fixes #21354. - - - - - d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Drop dead code - - - - - d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Use section flags to identify initializers - - - - - fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Introduce finalizer support - - - - - 5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl - - - - - 6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker/Elf: Work around GCC 6 init/fini behavior It appears that GCC 6t (at least on i386) fails to give init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY section types, instead marking them as SHT_PROGBITS. This caused T20494 to fail on Debian. - - - - - 5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Mark T13366Cxx as unbroken on Darwin - - - - - 1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Fix resolution of __dso_handle on Darwin Darwin expects a leading underscore. - - - - - a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Clean up section kinds - - - - - aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Ensure that __cxa_finalize is called on code unload - - - - - 028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00 testsuite: Fix T11829 on Centos 7 It appears that Centos 7 has a more strict C++ compiler than most distributions since std::runtime_error is defined in <stdexcept> rather than <exception>. In T11829 we mistakenly imported the latter. - - - - - a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00 hadrian: Rename documentation directories for consistency with make * Rename `docs` to `doc` * Place pdf documentation in `doc/` instead of `doc/pdfs/` Fixes #21164. - - - - - b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00 Fix incorrect proof of applyWhen’s properties - - - - - eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00 hadrian: Add multi:<pkg> and multi targets for starting a multi-repl This patch adds support to hadrian for starting a multi-repl containing all the packages which stage0 can build. In particular, there is the new user-facing command: ``` ./hadrian/ghci-multi ``` which when executed will start a multi-repl containing the `ghc` package and all it's dependencies. This is implemented by two new hadrian targets: ``` ./hadrian/build multi:<pkg> ``` Construct the arguments for a multi-repl session where the top-level package is <pkg>. For example, `./hadrian/ghci-multi` is implemented using `multi:ghc` target. There is also the `multi` command which constructs a repl for everything in stage0 which we can build. - - - - - 19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00 changelog typo - - - - - af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00 typos - - - - - 415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00 Refactor SpecConstr to use treat bindings uniformly This patch, provoked by #21457, simplifies SpecConstr by treating top-level and nested bindings uniformly (see the new scBind). * Eliminates the mysterious scTopBindEnv * Refactors scBind to handle top-level and nested definitions uniformly. * But, for now at least, continues the status quo of not doing SpecConstr for top-level non-recursive bindings. (In contrast we do specialise nested non-recursive bindings, although the original paper did not; see Note [Local let bindings].) I tried the effect of specialising top-level non-recursive bindings (which is now dead easy to switch on, unlike before) but found some regressions, so I backed off. See !8135. It's a pure refactoring. I think it'll do a better job in a few cases, but there is no regression test. - - - - - d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00 Rule matching: Don't compute the FVs if we don't look at them. - - - - - 5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 White space only in FamInstEnv - - - - - ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make transferPolyIdInfo work for CPR I don't know why this hasn't bitten us before, but it was plain wrong. - - - - - 9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Inline mapAccumLM This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically. - - - - - d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make SetLevels honour floatConsts This fix, in the definition of profitableFloat, is just for consistency. `floatConsts` should do what it says! I don't think it'll affect anything much, though. - - - - - d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Refactor wantToUnboxArg a bit * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg and similarly wantToUnboxResult to canUnboxResult. * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg, avoiding some yukky duplication. I decided it was clearer to give it a new data type for its return type, because I nedeed the FD_RecBox case which was not otherwise readiliy expressible. * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload * Get rid of the Unlift constructor of UnboxingDecision, eliminate two panics, and two arguments to canUnboxArg (new name). Much nicer now. - - - - - 6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00 Allow running memInventory when the concurrent nonmoving gc is enabled If the nonmoving gc is enabled and we are using a threaded RTS, we now try to grab the collector mutex to avoid memInventory and the collection racing. Before memInventory was disabled. - - - - - aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00 gitignore: don't ignore all aclocal.m4 files While GHC's own aclocal.m4 is generated by the aclocal tool, other packages' aclocal.m4 are committed in the repository. Previously `.gitignore` included an entry which covered *any* file named `aclocal.m4`, which lead to quite some confusion (e.g. see #21740). Fix this by modifying GHC's `.gitignore` to only cover GHC's own `aclocal.m4`. - - - - - 4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00 Add mapAccumM, forAccumM to Data.Traversable Approved by Core Libraries Committee in https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433 - - - - - bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00 configure: Use AC_PATH_TOOL to detect tools Previously we used AC_PATH_PROG which, as noted by #21601, does not look for tools with a target prefix, breaking cross-compilation. Fixes #21601. - - - - - e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00 driver: Fix implementation of -S We were failing to stop before running the assembler so the object file was also created. Fixes #21869 - - - - - e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00 rts/ProfHeap: Ensure new Censuses are zeroed When growing the Census array ProfHeap previously neglected to zero the new part of the array. Consequently `freeEra` would attempt to free random words that often looked suspiciously like pointers. Fixes #21880. - - - - - 81d65f7f by sheaf at 2022-07-21T15:37:22+02:00 Make withDict opaque to the specialiser As pointed out in #21575, it is not sufficient to set withDict to inline after the typeclass specialiser, because we might inline withDict in one module and then import it in another, and we run into the same problem. This means we could still end up with incorrect runtime results because the typeclass specialiser would assume that distinct typeclass evidence terms at the same type are equal, when this is not necessarily the case when using withDict. Instead, this patch introduces a new magicId, 'nospec', which is only inlined in CorePrep. We make use of it in the definition of withDict to ensure that the typeclass specialiser does not common up distinct typeclass evidence terms. Fixes #21575 - - - - - 9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00 Refactored Simplify pass * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify namespace and GHC.Core.Opt.Stats. Also removed services from configuration records. * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration. * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm` and moved the Simplify driver to GHC.Core.Opt.Simplify. * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env. * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment in GHC.Core.Opt.Simplify.Monad. * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions for those in a new module GHC.Driver.Config.Core.Opt.Simplify. Also added initialization functions for `SimplMode` to that module. * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types and the counting types and functions (`SimplCount` and `Tick`) to new module GHC.Core.Opt.Stats. * Added getter functions for the fields of `SimplMode`. The pedantic bottoms option and the platform are retrieved from the ArityOpts and RuleOpts and the getter functions allow us to retrieve values from `SpecEnv` without the knowledge where the data is stored exactly. * Moved the coercion optimization options from the top environment to `SimplMode`. This way the values left in the top environment are those dealing with monadic functionality, namely logging, IO related stuff and counting. Added a note "The environments of the Simplify pass". * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead. * Prep work before removing `InteractiveContext` from `HscEnv`. - - - - - 2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00 Make the specialiser deal better with specialised methods This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368. - - - - - ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00 ghc-boot: Clean up UTF-8 codecs In preparation for moving the UTF-8 codecs into `base`: * Move them to GHC.Utils.Encoding.UTF8 * Make names more consistent * Add some Haddocks - - - - - e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00 base: Introduce GHC.Encoding.UTF8 Here we copy a subset of the UTF-8 implementation living in `ghc-boot` into `base`, with the intent of dropping the former in the future. For this reason, the `ghc-boot` copy is now CPP-guarded on `MIN_VERSION_base(4,18,0)`. Naturally, we can't copy *all* of the functions defined by `ghc-boot` as some depend upon `bytestring`; we rather just copy those which only depend upon `base` and `ghc-prim`. Further consolidation? ---------------------- Currently GHC ships with at least five UTF-8 implementations: * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this can be used at a number of types including `Addr#`, `ByteArray#`, `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this can be removed in GHC 9.6+2, when the copies in `base` will become available to `ghc-boot`. * the copy of the `ghc-boot` definition now exported by `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`, `ByteArray#`, and `ForeignPtr` * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`; this is specialised at `Addr#`. * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`; this is specialised at `Addr#` but, unlike the above, supports recovery in the presence of partial codepoints (since in IO contexts codepoints may be broken across buffers) * the implementation provided by the `text` library This does seem a tad silly. On the other hand, these implementations *do* materially differ from one another (e.g. in the types they support, the detail in errors they can report, and the ability to recover from partial codepoints). Consequently, it's quite unclear that further consolidate would be worthwhile. - - - - - f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00 Add a Note summarising GHC's UTF-8 implementations GHC has a somewhat dizzying array of UTF-8 implementations. This note describes why this is the case. - - - - - 72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00 upload_ghc_libs: Fix path to documentation The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35 but this one occurrence was note updated. Finally closes #21164. - - - - - a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00 Add test for #21871 This adds a test for #21871, which was fixed by the No Skolem Info rework (MR !7105). Fixes #21871 - - - - - 6379f942 by sheaf at 2022-07-22T08:18:46-04:00 Add test for #21360 The way record updates are typechecked/desugared changed in MR !7981. Because we desugar in the typechecker to a simple case expression, the pattern match checker becomes able to spot the long-distance information and avoid emitting an incorrect pattern match warning. Fixes #21360 - - - - - ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00 Hadrian: don't try to build "unix" on Windows - - - - - dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Implement DeepSubsumption This MR adds the language extension -XDeepSubsumption, implementing GHC proposal #511. This change mitigates the impact of GHC proposal The changes are highly localised, by design. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. The main changes are: * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010, but off in Haskell2021. -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change. -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds: it makes type inference more complicated and less predictable, but it may be convenient in practice. * The main changes are in: * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result type. Without deep subsumption, unifyExpectedType would be sufficent. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. * There are no changes to Quick Look at all. * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to GHC.Magic.Dict * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where we'd forgotten to take the free vars of the multiplicity of an Id. * I also had to fix tcSplitNestedSigmaTys When I did the shallow-subsumption patch commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f Date: Sun Feb 2 18:23:11 2020 +0000 Simple subsumption I changed tcSplitNestedSigmaTys to not look through function arrows any more. But that was actually an un-forced change. This function is used only in * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect All to do with validity checking and error messages. Acutally its fine to look under function arrows here, and quite useful a test DeepSubsumption05 (a test motivated by a build failure in the `lens` package) shows. The fix is easy. I added Note [tcSplitNestedSigmaTys]. - - - - - e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption - - - - - 67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add DeepSubsumption08 - - - - - 5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Fix the interaction of operator sections and deep subsumption Fixes DeepSubsumption08 - - - - - 918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00 Add DeepSubsumption09 - - - - - 2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00 Default implementation for mempty/(<>) Approved by: https://github.com/haskell/core-libraries-committee/issues/61 This adds a default implementation for `mempty` and `(<>)` along with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid` instances can be defined in terms of `sconcat` / `mconcat`. The description for each class has also been updated to include the equivalent set of laws for the `sconcat`-only / `mconcat`-only instances. - - - - - 73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00 ci: Disable (broken) perf-nofib See #21859 - - - - - c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00 Docs: clarify ConstraintKinds infelicity GHC doesn't consistently require the ConstraintKinds extension to be enabled, as it allows programs such as type families returning a constraint without this extension. MR !7784 fixes this infelicity, but breaking user programs was deemed to not be worth it, so we document it instead. Fixes #21061. - - - - - 5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00 More improvements to worker/wrapper This patch fixes #21888, and simplifies finaliseArgBoxities by eliminating the (recently introduced) data type FinalDecision. A delicate interaction meant that this patch commit d1c25a48154236861a413e058ea38d1b8320273f Date: Tue Jul 12 16:33:46 2022 +0100 Refactor wantToUnboxArg a bit make worker/wrapper go into an infinite loop. This patch fixes it by narrowing the handling of case (B) of Note [Boxity for bottoming functions], to deal only the arguemnts that are type variables. Only then do we drop the trimBoxity call, which is what caused the bug. I also * Added documentation of case (B), which was previously completely un-mentioned. And a regression test, T21888a, to test it. * Made unboxDeeplyDmd stop at lazy demands. It's rare anyway for a bottoming function to have a lazy argument (mainly when the data type is recursive and then we don't want to unbox deeply). Plus there is Note [No lazy, Unboxed demands in demand signature] * Refactored the Case equation for dmdAnal a bit, to do less redundant pattern matching. - - - - - b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00 Fix a small buglet in tryEtaReduce Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was making an ill-formed cast. It didn't matter, because the subsequent guard discarded it; but still worth fixing. Spurious warnings are distracting. - - - - - 3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00 Fix #21889, GHCi misbehaves with Ctrl-C on Windows On Windows, we create multiple levels of wrappers for GHCi which ultimately execute ghc --interactive. In order to handle console events properly, each of these wrappers must call FreeConsole() in order to hand off event processing to the child process. See #14150. In addition to this, FreeConsole must only be called from interactive processes (#13411). This commit makes two changes to fix this situation: 1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole` if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi. 2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`: Before: ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe After: ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe - - - - - 79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00 docs: Fix documentation of \cases Fixes #21902. - - - - - e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00 ghc-cabal: allow Cabal 3.8 to unbreak make build When bootstrapping GHC 9.4.*, the build will fail when configuring ghc-cabal as part of the make based build system due to this upper bound, as Cabal has been updated to a 3.8 release. Reference #21914, see especially https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699 - - - - - 726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Fix isEvaldUnfolding and isValueUnfolding This fixes (1) in #21831. Easy, obviously correct. - - - - - 5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Switch off eta-expansion in rules and unfoldings I think this change will make little difference except to reduce clutter. But that's it -- if it causes problems we can switch it on again. - - - - - d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Teach SpecConstr about typeDeterminesValue This patch addresses #21831, point 2. See Note [generaliseDictPats] in SpecConstr I took the opportunity to refactor the construction of specialisation rules a bit, so that the rule name says what type we are specialising at. Surprisingly, there's a 20% decrease in compile time for test perf/compiler/T18223. I took a look at it, and the code size seems the same throughout. I did a quick ticky profile which seemed to show a bit less substitution going on. Hmm. Maybe it's the "don't do eta-expansion in stable unfoldings" patch, which is part of the same MR as this patch. Anyway, since it's a move in the right direction, I didn't think it was worth looking into further. Metric Decrease: T18223 - - - - - 65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Add a 'notes' file in testsuite/tests/perf/compiler This file is just a place to accumlate notes about particular benchmarks, so that I don't keep re-inventing the wheel. - - - - - 61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00 Get the in-scope set right in FamInstEnv.injectiveBranches There was an assert error, as Gergo pointed out in #21896. I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs. And also to GHC.Core.Unify.niFixTCvSubst. I also took the opportunity to get a couple more InScopeSets right, and to change some substTyUnchecked into substTy. This MR touches a lot of other files, but only because I also took the opportunity to introduce mkInScopeSetList, and use it. - - - - - 4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00 Add location to cc phase - - - - - 96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00 Avoid as pipeline when compiling c - - - - - 2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00 testsuite: Skip test cases involving -S when testing unregisterised GHC We no longer generate .s files anyway. Metric Decrease: MultiLayerModules T10421 T13035 T13701 T14697 T16875 T18140 T18304 T18923 T9198 - - - - - 82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00 testsuite: introduce nonmoving_thread_sanity way (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae) - - - - - 4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Track segment state It can often be useful during debugging to be able to determine the state of a nonmoving segment. Introduce some state, enabled by DEBUG, to track this. (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f) - - - - - 54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Don't scavenge objects which weren't evacuated This fixes a rather subtle bug in the logic responsible for scavenging objects evacuated to the non-moving generation. In particular, objects can be allocated into the non-moving generation by two ways: a. evacuation out of from-space by the garbage collector b. direct allocation by the mutator Like all evacuation, objects moved by (a) must be scavenged, since they may contain references to other objects located in from-space. To accomplish this we have the following scheme: * each nonmoving segment's block descriptor has a scan pointer which points to the first object which has yet to be scavenged * the GC tracks a set of "todo" segments which have pending scavenging work * to scavenge a segment, we scavenge each of the unmarked blocks between the scan pointer and segment's `next_free` pointer. We skip marked blocks since we know the allocator wouldn't have allocated into marked blocks (since they contain presumably live data). We can stop at `next_free` since, by definition, the GC could not have evacuated any objects to blocks above `next_free` (otherwise `next_free wouldn't be the first free block). However, this neglected to consider objects allocated by path (b). In short, the problem is that objects directly allocated by the mutator may become unreachable (but not swept, since the containing segment is not yet full), at which point they may contain references to swept objects. Specifically, we observed this in #21885 in the following way: 1. the mutator (specifically in #21885, a `lockCAF`) allocates an object (specifically a blackhole, which here we will call `blkh`; see Note [Static objects under the nonmoving collector] for the reason why) on the non-moving heap. The bitmap of the allocated block remains 0 (since allocation doesn't affect the bitmap) and the containing segment's (which we will call `blkh_seg`) `next_free` is advanced. 2. We enter the blackhole, evaluating the blackhole to produce a result (specificaly a cons cell) in the nursery 3. The blackhole gets updated into an indirection pointing to the cons cell; it is pushed to the generational remembered set 4. we perform a GC, the cons cell is evacuated into the nonmoving heap (into segment `cons_seg`) 5. the cons cell is marked 6. the GC concludes 7. the CAF and blackhole become unreachable 8. `cons_seg` is filled 9. we start another GC; the cons cell is swept 10. we start a new GC 11. something is evacuated into `blkh_seg`, adding it to the "todo" list 12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks between `scan` and `next_free`, which includes `blkh`). We attempt to evacuate `blkh`'s indirectee, which is the previously-swept cons cell. This is unsafe, since the indirectee is no longer a valid heap object. The problem here was that the scavenging logic *assumed* that (a) was the only source of allocations into the non-moving heap and therefore *all* unmarked blocks between `scan` and `next_free` were evacuated. However, due to (b) this is not true. The solution is to ensure that that the scanned region only encompasses the region of objects allocated during evacuation. We do this by updating `scan` as we push the segment to the todo-segment list to point to the block which was evacuated into. Doing this required changing the nonmoving scavenging implementation's update of the `scan` pointer to bump it *once*, instead of after scavenging each block as was done previously. This is because we may end up evacuating into the segment being scavenged as we scavenge it. This was quite tricky to discover but the result is quite simple, demonstrating yet again that global mutable state should be used exceedingly sparingly. Fixes #21885 (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060) - - - - - 25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00 testsuite: Skip a few tests as in the nonmoving collector Residency monitoring under the non-moving collector is quite conservative (e.g. the reported value is larger than reality) since otherwise we would need to block on concurrent collection. Skip a few tests that are sensitive to residency. (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70) - - - - - 42147534 by sternenseemann at 2022-07-26T16:26:53-04:00 hadrian: add flag disabling selftest rules which require QuickCheck The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699. - - - - - 9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00 Regression test for #21848 - - - - - ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00 driver: Don't create LinkNodes when -no-link is enabled Fixes #21866 - - - - - fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00 Docs: fix mistaken claim about kind signatures This patch fixes #21806 by rectifying an incorrect claim about the usage of kind variables in the header of a data declaration with a standalone kind signature. It also adds some clarifications about the number of parameters expected in GADT declarations and in type family declarations. - - - - - 2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00 testsuite: Correctly set withNativeCodeGen Fixes #21918 - - - - - f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00 Fix since annotations in GHC.Stack.CloneStack Fixes #21894 - - - - - aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00 Add -dsuppress-coercion-types to make coercions even smaller. Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)`` simply print `` `cast` <Co:11> :: ... `` - - - - - 97655ad8 by sheaf at 2022-08-02T19:27:29-04:00 User's guide: fix typo in hasfield.rst Fixes #21950 - - - - - 35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00 Remove TCvSubst and use Subst for both term and type-level subst This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types). - - - - - b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00 Fix TH + defer-type-errors interaction (#21920) Previously, we had to disable defer-type-errors in splices because of #7276. But this fix is no longer necessary, the test T7276 no longer segfaults and is now correctly deferred. - - - - - fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00 Add a note about about W/W for unlifting strict arguments This fixes #21236. - - - - - fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force safeInferred to avoid retaining extra copy of DynFlags This will only have a (very) modest impact on memory but we don't want to retain old copies of DynFlags hanging around so best to force this value. - - - - - 0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force name selectors to ensure no reference to Ids enter the NameCache I observed some unforced thunks in the NameCache which were retaining a whole Id, which ends up retaining a Type.. which ends up retaining old copies of HscEnv containing stale HomeModInfo. - - - - - 0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Fix leaks in --make mode when there are module loops This patch fixes quite a tricky leak where we would end up retaining stale ModDetails due to rehydrating modules against non-finalised interfaces. == Loops with multiple boot files It is possible for a module graph to have a loop (SCC, when ignoring boot files) which requires multiple boot files to break. In this case we must perform the necessary hydration steps before and after compiling modules which have boot files which are described above for corectness but also perform an additional hydration step at the end of the SCC to remove space leaks. Consider the following example: ┌───────┐ ┌───────┐ │ │ │ │ │ A │ │ B │ │ │ │ │ └─────┬─┘ └───┬───┘ │ │ ┌────▼─────────▼──┐ │ │ │ C │ └────┬─────────┬──┘ │ │ ┌────▼──┐ ┌───▼───┐ │ │ │ │ │ A-boot│ │ B-boot│ │ │ │ │ └───────┘ └───────┘ A, B and C live together in a SCC. Say we compile the modules in order A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps (because A has a boot file). Therefore C will be hydrated relative to A, and the ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again, and so B will reference C/A,B, its interface will be hydrated relative to both A and B. Now there is a space leak because say C is a very big module, there are now two different copies of ModDetails kept alive by modules A and B. The way to avoid this space leak is to rehydrate an entire SCC together at the end of compilation so that all the ModDetails point to interfaces for .hs files. In this example, when we hydrate A, B and C together then both A and B will refer to C/A,B. See #21900 for some more discussion. ------------------------------------------------------- In addition to this simple case, there is also the potential for a leak during parallel upsweep which is also fixed by this patch. Transcibed is Note [ModuleNameSet, efficiency and space leaks] Note [ModuleNameSet, efficiency and space leaks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During unsweep the results of compiling modules are placed into a MVar, to find the environment the module needs to compile itself in the MVar is consulted and the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking module dependencies and recreating the HUG from scratch each time is very expensive. In serial mode (-j1), this all works out fine because a module can only be compiled after its dependencies have finished compiling and not interleaved with compiling module loops. Therefore when we create the finalised or no loop interfaces, the HUG only contains finalised interfaces. In parallel mode, we have to be more careful because the HUG variable can contain non-finalised interfaces which have been started by another thread. In order to avoid a space leak where a finalised interface is compiled against a HPT which contains a non-finalised interface we have to restrict the HUG to only the visible modules. The visible modules is recording in the ModuleNameSet, this is propagated upwards whilst compiling and explains which transitive modules are visible from a certain point. This set is then used to restrict the HUG before the module is compiled to only the visible modules and thus avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance because a union occurs for each edge in the module graph. Therefore the set is represented directly as an IntSet which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. See test "jspace" for an example which used to trigger this problem. Fixes #21900 - - - - - 1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Store interfaces in ModIfaceCache more directly I realised hydration was completely irrelavant for this cache because the ModDetails are pruned from the result. So now it simplifies things a lot to just store the ModIface and Linkable, which we can put into the cache straight away rather than wait for the final version of a HomeModInfo to appear. - - - - - 6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00 cmm: Remove unused ReadOnlyData16 We don't actually emit rodata16 sections anywhere. - - - - - 16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00 findExternalRules: Don't needlessly traverse the list of rules. - - - - - 52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00 Remove backported items from 9.6 release notes They have been backported to 9.4 in commits 5423d84bd9a28f, 13c81cb6be95c5, 67ccbd6b2d4b9b. - - - - - 78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00 ci: Fix pages job The job has been failing because we don't bundle haddock docs anymore in the docs dist created by hadrian. Fixes #21789 - - - - - 037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00 codeGen/X86: Don't clobber switch variable in switch generation Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was safe to clobber the switch variable when generating code for a jump table since we were at the end of a block. However, this assumption is wrong; the register could be live in the jump target. Fixes #21968. - - - - - 50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00 Fix equality operator in jspace test - - - - - e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Improve BUILD_PAP comments - - - - - 41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Make dropTail comment a haddock comment - - - - - ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Add one more sanity check in stg_restore_cccs - - - - - 1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00 StgToCmm: Fix isSimpleScrut when profiling is enabled. When profiling is enabled we must enter functions that might represent thunks in order for their sccs to show up in the profile. We might allocate even if the function is already evaluated in this case. So we can't consider any potential function thunk to be a simple scrut when profiling. Not doing so caused profiled binaries to segfault. - - - - - fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Change `-fprof-late` to insert cost centres after unfolding creation. The former behaviour of adding cost centres after optimization but before unfoldings are created is not available via the flag `prof-late-inline` instead. I also reduced the overhead of -fprof-late* by pushing the cost centres into lambdas. This means the cost centres will only account for execution of functions and not their partial application. Further I made LATE_CC cost centres it's own CC flavour so they now won't clash with user defined ones if a user uses the same string for a custom scc. LateCC: Don't put cost centres inside constructor workers. With -fprof-late they are rarely useful as the worker is usually inlined. Even if the worker is not inlined or we use -fprof-late-linline they are generally not helpful but bloat compile and run time significantly. So we just don't add sccs inside constructor workers. ------------------------- Metric Decrease: T13701 ------------------------- - - - - - f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00 gitlab-ci: Fix hadrian bootstrapping of release pipelines Previously we would attempt to test hadrian bootstrapping in the `validate` build flavour. However, `ci.sh` refuses to run validation builds during release pipelines, resulting in job failures. Fix this by testing bootstrapping in the `release` flavour during release pipelines. We also attempted to record perf notes for these builds, which is redundant work and undesirable now since we no longer build in a consistent flavour. - - - - - c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00 compiler: Eliminate two uses of foldr in favor of foldl' These two uses constructed maps, which is a case where foldl' is generally more efficient since we avoid constructing an intermediate O(n)-depth stack. - - - - - d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00 rts: Fix code style - - - - - 57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00 genprimopcode: Drop ArrayArray# references As ArrayArray# no longer exists - - - - - 7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00 base: Organize Haddocks in GHC.Conc.Sync - - - - - aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00 Add primop to list threads A user came to #ghc yesterday wondering how best to check whether they were leaking threads. We ended up using the eventlog but it seems to me like it would be generally useful if Haskell programs could query their own threads. - - - - - 6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00 rts: Move thread labels into TSO This eliminates the thread label HashTable and instead tracks this information in the TSO, allowing us to use proper StgArrBytes arrays for backing the label and greatly simplifying management of object lifetimes when we expose them to the user with the coming `threadLabel#` primop. - - - - - 1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00 Add a primop to query the label of a thread - - - - - 43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00 base: Share finalization thread label For efficiency's sake we float the thread label assigned to the finalization thread to the top-level, ensuring that we only need to encode the label once. - - - - - 1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00 users-guide: Add release notes entry for thread introspection support - - - - - 09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix binary distribution install attributes Previously we would use plain `cp` to install various parts of the binary distribution. However, `cp`'s behavior w.r.t. file attributes is quite unclear; for this reason it is much better to rather use `install`. Fixes #21965. - - - - - 2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix installation of system-cxx-std-lib package conf - - - - - 7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00 gitlab-ci: Bump Docker images To give the ARMv7 job access to lld, fixing #21875. - - - - - afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Don't use mk/config.mk.in Ultimately we want to drop mk/config.mk so here I extract the bits needed by the Hadrian bindist installation logic into a Hadrian-specific file. While doing this I fixed binary distribution installation, #21901. - - - - - b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Fix naming of cross-compiler wrappers - - - - - 78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00 hadrian: Extend xattr Darwin hack to cover /lib As noted in #21506, it is now necessary to remove extended attributes from `/lib` as well as `/bin` to avoid SIP issues on Darwin. Fixes #21506. - - - - - 20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00 NCG(x86): Compile add+shift as lea if possible. - - - - - 742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00 dataToTag#: Skip runtime tag check if argument is infered tagged This addresses one part of #21710. - - - - - 1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00 rts: remove redundant stg_traceCcszh This out-of-line primop has no Haskell wrapper and hasn't been used anywhere in the tree. Furthermore, the code gets in the way of !7632, so it should be garbage collected. - - - - - a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00 Document a divergence from the report in parsing function lhss. GHC is happy to parse `(f) x y = x + y` when it should be a parse error based on the Haskell report. Seems harmless enough so we won't fix it but it's documented now. Fixes #19788 - - - - - 5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00 gitlab-ci: Add release job for aarch64/debian 11 - - - - - 5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Introduce validation job for aarch64 cross-compilation Begins to address #11958. - - - - - e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00 Bump process submodule - - - - - ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Add basic support for cross-compiler testiing Here we add a simple qemu-based test for cross-compilers. - - - - - 50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00 rts: Ensure that Array# card arrays are initialized In #19143 I noticed that newArray# failed to initialize the card table of newly-allocated arrays. However, embarrassingly, I then only fixed the issue in newArrayArray# and, in so doing, introduced the potential for an integer underflow on zero-length arrays (#21962). Here I fix the issue in newArray#, this time ensuring that we do not underflow in pathological cases. Fixes #19143. - - - - - e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00 testsuite: Add test for #21962 - - - - - c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00 gitlab-ci: Don't use coreutils on Darwin In general we want to ensure that the tested environment is as similar as possible to the environment the user will use. In the case of Darwin, this means we want to use the system's BSD command-line utilities, not coreutils. This would have caught #21974. - - - - - 1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00 hadrian: Fix bindist installation on Darwin It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does. - - - - - 681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00 hadrian: Fix access mode of installed package registration files Previously hadrian's bindist Makefile would modify package registrations placed by `install` via a shell pipeline and `mv`. However, the use of `mv` means that if umask is set then the user may otherwise end up with package registrations which are inaccessible. Fix this by ensuring that the mode is 0644. - - - - - e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00 Cleanups around pretty-printing * Remove hack when printing OccNames. No longer needed since e3dcc0d5 * Remove unused `pprCmms` and `instance Outputable Instr` * Simplify `pprCLabel` (no need to pass platform) * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by ImmLit, but that can take just a String instead. * Remove instance `Outputable CLabel` - proper output of labels needs a platform, and is done by the `OutputableP` instance - - - - - 66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00 rts/linker: Resolve iconv_* on FreeBSD FreeBSD's libiconv includes an implementation of the iconv_* functions in libc. Unfortunately these can only be resolved using dlvsym, which is how the RTS linker usually resolves such functions. To fix this we include an ad-hoc special case for iconv_*. Fixes #20354. - - - - - 5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00 system-cxx-std-lib: Add support for FreeBSD libcxxrt - - - - - ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00 gitlab-ci: Bump to use freebsd13 runners - - - - - d71a2051 by sheaf at 2022-08-09T13:47:28-04:00 Fix size_up_alloc to account for UnliftedDatatypes The size_up_alloc function mistakenly considered any type that isn't lifted to not allocate anything, which is wrong. What we want instead is to check the type isn't boxed. This accounts for (BoxedRep Unlifted). Fixes #21939 - - - - - 76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. - - - - - 7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. - - - - - dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00 Updates language extension documentation Adding a 'Status' field with a few values: - Deprecated - Experimental - InternalUseOnly - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98' Those values are pulled from the existing descriptions or elsewhere in the documentation. While at it, include the :implied by: where appropriate, to provide more detail. Fixes #21475 - - - - - 823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00 hadrian RunRest: add type signature for stageNumber avoids warning seen on 9.4.1: src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults] • Defaulting the following constraints to type ‘Integer’ (Show a0) arising from a use of ‘show’ at src/Settings/Builders/RunTest.hs:264:53-84 (Num a0) arising from a use of ‘stageNumber’ at src/Settings/Builders/RunTest.hs:264:59-83 • In the second argument of ‘(++)’, namely ‘show (stageNumber (C.stage ctx))’ In the second argument of ‘($)’, namely ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’ In the expression: arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | 264 | , arg "-e", arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compilation tested locally - - - - - f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00 Add support for external static plugins (#20964) This patch adds a new command-line flag: -fplugin-library=<file-path>;<unit-id>;<module>;<args> used like this: -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"] It allows a plugin to be loaded directly from a shared library. With this approach, GHC doesn't compile anything for the plugin and doesn't load any .hi file for the plugin and its dependencies. As such GHC doesn't need to support two environments (one for plugins, one for target code), which was the more ambitious approach tracked in #14335. Fix #20964 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Fix ARMv7 build It appears that the CI refactoring carried out in 5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some critical configuration: setting the build/host/target platforms and forcing use of a non-broken linker. - - - - - 596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Run ARMv7 jobs when ~ARM label is used - - - - - 7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00 hadrian: Don't attempt to install documentation if doc/ doesn't exist Previously we would attempt to install documentation even if the `doc` directory doesn't exist (e.g. due to `--docs=none`). This would result in the surprising side-effect of the entire contents of the bindist being installed in the destination documentation directory. Fix this. Fixes #21976. - - - - - 67575f20 by normalcoder at 2022-08-10T15:38:34-04:00 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - - - - - 45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00 Note [Trimming auto-rules]: State that this improves compiler perf. - - - - - 5c24b1b3 by Bodigrim at 2022-08-10T22:41:50-04:00 Document that threadDelay / timeout are susceptible to overflows on 32-bit machines - - - - - ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule - - - - - dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00 Revert "gitlab-ci: Add release job for aarch64/debian 11" This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46. The job was not tested before being merged and fails CI (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392) Ticket #22005 - - - - - ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00 typo - - - - - cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00 CmmToLlvm: Don't aliasify builtin LLVM variables Our aliasification logic would previously turn builtin LLVM variables into aliases, which apparently confuses LLVM. This manifested in initializers failing to be emitted, resulting in many profiling failures with the LLVM backend. Fixes #22019. - - - - - dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00 run_ci: remove monoidal-containers Fixes #21492 MonoidalMap is inlined and used to implement Variables, as before. The top-level value "jobs" is reimplemented as a regular Map, since it doesn't use the monoidal union anyway. - - - - - 64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00 CmmToAsm/AArch64: correct a typo - - - - - f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00 Fix #21979 - compact-share failing with -O I don't have good reason to believe the optimization level should affect if sharing works or not here. So limit the test to the normal way. - - - - - 68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix reference to dead llvm-version substitution Fixes #22052. - - - - - 28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix incorrect reference to `:extension: role - - - - - 71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Add :ghc-flag: reference - - - - - 385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00 hadrian: Place manpage in docroot This relocates it from docs/ to doc/ - - - - - 84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00 Bump haddock submodule Includes merge of `main` into `ghc-head` as well as some Haddock users guide fixes. - - - - - 59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00 base: Add changelog entries from ghc-9.2 Closes #21922. - - - - - a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00 relnotes: Add "included libraries" section As noted in #21988, some users rely on this. - - - - - a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Rephrase the rewrite rule documentation Previously the wording was a tad unclear. Fix this. Closes #21114. - - - - - 3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00 Implement Response File support for HPC This is an improvement to HPC authored by Richard Wallace (https://github.com/purefn) and myself. I have received permission from him to attempt to upstream it. This improvement was originally implemented as a patch to HPC via input-output-hk/haskell.nix: https://github.com/input-output-hk/haskell.nix/pull/1464 Paraphrasing Richard, HPC currently requires all inputs as command line arguments. With large projects this can result in an argument list too long error. I have only seen this error in Nix, but I assume it can occur is a plain Unix environment. This MR adds the standard response file syntax support to HPC. For example you can now pass a file to the command line which contains the arguments. ``` hpc @response_file_1 @response_file_2 ... The contents of a Response File must have this format: COMMAND ... example: report my_library.tix --include=ModuleA --include=ModuleB ``` Updates hpc submodule Co-authored-by: Richard Wallace <rwallace at thewallacepack.net> Fixes #22050 - - - - - 436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00 ghc-heap: Fix decoding of TSO closures An extra field was added to the TSO structure in 6d1700b6 but the decoding logic in ghc-heap was not updated for this new field. Fixes #22046 - - - - - a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00 driver: Honour -x option The -x option is used to manually specify which phase a file should be started to be compiled from (even if it lacks the correct extension). I just failed to implement this when refactoring the driver. In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to preprocess source files using GHC. I added a test to exercise this case. Fixes #22044 - - - - - e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00 Be more careful in chooseInferredQuantifiers This fixes #22065. We were failing to retain a quantifier that was mentioned in the kind of another retained quantifier. Easy to fix. - - - - - 714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00 testsuite: Add test for #21583 - - - - - 989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00 compiler: Drop --build-id=none hack Since 2011 the object-joining implementation has had a hack to pass `--build-id=none` to `ld` when supported, seemingly to work around a linker bug. This hack is now unnecessary and may break downstream users who expect objects to have valid build-ids. Remove it. Closes #22060. - - - - - 519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00 Make ru_fn field strict to avoid retaining Ids It's better to perform this projection from Id to Name strictly so we don't retain an old Id (hence IdInfo, hence Unfolding, hence everything etc) - - - - - 7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force `getOccFS bndr` to avoid retaining reference to Bndr. This is another symptom of #19619 - - - - - 4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force unfoldings when they are cleaned-up in Tidy and CorePrep If these thunks are not forced then the entire unfolding for the binding is live throughout the whole of CodeGen despite the fact it should have been discarded. Fixes #22071 - - - - - 2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00 haddock docs: Fix links from identifiers to dependent packages When implementing the base_url changes I made the pretty bad mistake of zipping together two lists which were in different orders. The simpler thing to do is just modify `haddockDependencies` to also return the package identifier so that everything stays in sync. Fixes #22001 - - - - - 9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00 Revert "Refactor SpecConstr to use treat bindings uniformly" This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729. This refactoring introduced quite a severe residency regression (900MB live from 650MB live when compiling mmark), see #21993 for a reproducer and more discussion. Ticket #21993 - - - - - 9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00 tc: warn about lazy annotations on unlifted arguments (fixes #21951) - - - - - e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00 Fix #22048 where we failed to drop rules for -fomit-interface-pragmas. Now we also filter the local rules (again) which fixes the issue. - - - - - 51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00 Print constraints in quotes (#21167) This patch improves the uniformity of error message formatting by printing constraints in quotes, as we do for types. Fix #21167 - - - - - ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00 19217 Implicitly quantify type variables in :kind command - - - - - 9939e95f by MorrowM at 2022-08-21T16:51:38-04:00 Recognize file-header pragmas in GHCi (#21507) - - - - - fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00 hadrian: Fix bootstrapping with ghc-9.4 The error was that we were trying to link together containers from boot package library (which depends template-haskell in boot package library) template-haskell from in-tree package database So the fix is to build containers in stage0 (and link against template-haskell built in stage0). Fixes #21981 - - - - - b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00 Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942. * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence * `ParensT` constructor is now always printed parenthesized * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down * using `>=` instead of former `>` to match the Core type printing logic * some test outputs have changed, losing extraneous parentheses - - - - - fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00 Fix and test for issue #21723 - - - - - 33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00 Test for issue #21942 - - - - - c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00 Updated the changelog - - - - - 80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00 hadrian: Don't duplicate binaries on installation Previously we used `install` on symbolic links, which ended up copying the target file rather than installing a symbolic link. Fixes #22062. - - - - - b929063e by M Farkas-Dyck at 2022-08-24T02:37:01-04:00 Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Closes #22092. - - - - - 112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00 driver: don't actually merge objects when ar -L works - - - - - a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00 rts: Consistently use MiB in stats output Previously we would say `MB` even where we meant `MiB`. - - - - - a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223 - - - - - 909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00 upload_ghc_libs: Add means of passing Hackage credentials - - - - - 28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00 Scrub some partiality in `CommonBlockElim`. - - - - - 54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00 hadrian: Fix whitespace Previously this region of Settings.Packages was incorrectly indented. - - - - - c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00 validate: Drop --legacy flag In preparation for removal of the legacy `make`-based build system. - - - - - 822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00 gitlab-ci: Drop make build validation jobs In preparation for removal of the `make`-based build system - - - - - 6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop make build system Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html - - - - - dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00 Remove testsuite/tests/perf/haddock/.gitignore As noted in #16802, this is no longer needed. Closes #16802. - - - - - fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop hc-build script This has not worked for many, many years and relied on the now-removed `make`-based build system. - - - - - 659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mkdirhier This is only used by nofib's dead `dist` target - - - - - 4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mk/{build,install,config}.mk.in - - - - - 46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00 compiler: Drop comment references to make - - - - - d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add inits1 and tails1 to Data.List.NonEmpty See https://github.com/haskell/core-libraries-committee/issues/67 - - - - - 8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add since annotations and changelog entries - - - - - 6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00 Fix redundant import This fixes a build error on x86_64-linux-alpine3_12-validate. See the function 'loadExternalPlugins' defined in this file. - - - - - 4786acf7 by sheaf at 2022-08-26T15:05:23-04:00 Pmc: consider any 2 dicts of the same type equal This patch massages the keys used in the `TmOracle` `CoreMap` to ensure that dictionaries of coherent classes give the same key. That is, whenever we have an expression we want to insert or lookup in the `TmOracle` `CoreMap`, we first replace any dictionary `$dict_abcd :: ct` with a value of the form `error @ct`. This allows us to common-up view pattern functions with required constraints whose arguments differed only in the uniques of the dictionaries they were provided, thus fixing #21662. This is a rather ad-hoc change to the keys used in the `TmOracle` `CoreMap`. In the long run, we would probably want to use a different representation for the keys instead of simply using `CoreExpr` as-is. This more ambitious plan is outlined in #19272. Fixes #21662 Updates unix submodule - - - - - f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00 Remove label style from printing context Previously, the SDocContext used for code generation contained information whether the labels should use Asm or C style. However, at every individual call site, this is known statically. This removes the parameter to 'PprCode' and replaces every 'pdoc' used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'. The OutputableP instance is now used only for dumps. The output of T15155 changes, it now uses the Asm style (which is faithful to what actually happens). - - - - - 1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00 boot: cleanup legacy args Cleanup legacy boot script args, following removal of the legacy make build system. - - - - - 95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00 Improve SpecConstr for evals As #21763 showed, we were over-specialising in some cases, when the function involved was doing a simple 'eval', but not taking the value apart, or branching on it. This MR fixes the problem. See Note [Do not specialise evals]. Nofib barely budges, except that spectral/cichelli allocates about 3% less. Compiler bytes-allocated improves a bit geo. mean -0.1% minimum -0.5% maximum +0.0% The -0.5% is on T11303b, for what it's worth. - - - - - 565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Revert "Revert "Refactor SpecConstr to use treat bindings uniformly"" This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8. This commit was originally reverted due to an increase in space usage. This was diagnosed as because the SCE increased in size and that was being retained by another leak. See #22102 - - - - - 82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Avoid retaining bindings via ModGuts held on the stack It's better to overwrite the bindings fields of the ModGuts before starting an iteration as then all the old bindings can be collected as soon as the simplifier has processed them. Otherwise we end up with the old bindings being alive until right at the end of the simplifier pass as the mg_binds field is only modified right at the end. - - - - - 64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00 Force imposs_deflt_cons in filterAlts This fixes a pretty serious space leak as the forced thunk would retain `Alt b` values which would then contain reference to a lot of old bindings and other simplifier gunk. The OtherCon unfolding was not forced on subsequent simplifier runs so more and more old stuff would be retained until the end of simplification. Fixing this has a drastic effect on maximum residency for the mmark package which goes from ``` 45,005,401,056 bytes allocated in the heap 17,227,721,856 bytes copied during GC 818,281,720 bytes maximum residency (33 sample(s)) 9,659,144 bytes maximum slop 2245 MiB total memory in use (0 MB lost due to fragmentation) ``` to ``` 45,039,453,304 bytes allocated in the heap 13,128,181,400 bytes copied during GC 331,546,608 bytes maximum residency (40 sample(s)) 7,471,120 bytes maximum slop 916 MiB total memory in use (0 MB lost due to fragmentation) ``` See #21993 for some more discussion. - - - - - a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Use Solo to avoid retaining the SCE but to avoid performing the substitution The use of Solo here allows us to force the selection into the SCE to obtain the Subst but without forcing the substitution to be applied. The resulting thunk is placed into a lazy field which is rarely forced, so forcing it regresses peformance. - - - - - 161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00 Fix a nasty loop in Tidy As the remarkably-simple #22112 showed, we were making a black hole in the unfolding of a self-recursive binding. Boo! It's a bit tricky. Documented in GHC.Iface.Tidy, Note [tidyTopUnfolding: avoiding black holes] - - - - - 68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnIllegalHsigDefaultMethods TcRnBadGenericMethod TcRnWarningMinimalDefIncomplete TcRnDefaultMethodForPragmaLacksBinding TcRnIgnoreSpecialisePragmaOnDefMethod TcRnBadMethodErr TcRnNoExplicitAssocTypeOrDefaultDeclaration - - - - - cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00 Fix a bug in anyInRnEnvR This bug was a subtle error in anyInRnEnvR, introduced by commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06 Author: Andreas Klebinger <klebinger.andreas at gmx.at> Date: Sat Jul 9 01:19:52 2022 +0200 Rule matching: Don't compute the FVs if we don't look at them. The net result was #22028, where a rewrite rule would wrongly match on a lambda. The fix to that function is easy. - - - - - 0154bc80 by sheaf at 2022-08-30T06:05:41-04:00 Various Hadrian bootstrapping fixes - Don't always produce a distribution archive (#21629) - Use correct executable names for ghc-pkg and hsc2hs on windows (we were missing the .exe file extension) - Fix a bug where we weren't using the right archive format on Windows when unpacking the bootstrap sources. Fixes #21629 - - - - - 451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00 ci: Attempt using normal submodule cloning strategy We do not use any recursively cloned submodules, and this protects us from flaky upstream remotes. Fixes #22121 - - - - - 9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: stray "--" - - - - - 3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: syntatic -> syntactic - - - - - 7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00 Add a missing trimArityType This buglet was exposed by #22114, a consequence of my earlier refactoring of arity for join points. - - - - - e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump binary submodule to 0.8.9.1 - - - - - 4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump stm submodule to 2.5.1.0 - - - - - 837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00 users-guide: Document system-cxx-std-lib - - - - - f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00 Update submodule containers to 0.6.6 - - - - - 4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00 Update submodule process to 1.6.15.0 - - - - - 1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00 Bump directory submodule to 1.3.7.1 - - - - - 7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00 Bump text submodule to 2.0.1 - - - - - fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00 Bump deepseq submodule to 1.4.8.0 - - - - - a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00 Add dates to base, ghc-prim changelogs - - - - - 2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00 Update autoconf scripts Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983 - - - - - e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00 Bump bytestring submodule to 0.11.3.1 - - - - - f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00 Update submodule Cabal to tag Cabal-v3.8.1.0 closes #21931 - - - - - e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00 Refine in-tree compiler args for --test-compiler=stage1 Some of the logic to calculate in-tree arguments was not correct for the stage1 compiler. Namely we were not correctly reporting whether we were building static or dynamic executables and whether debug assertions were enabled. Fixes #22096 - - - - - 6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00 Make ghcDebugAssertions into a Stage predicate (Stage -> Bool) We also care whether we have debug assertions enabled for a stage one compiler, but the way which we turned on the assertions was quite different from the stage2 compiler. This makes the logic for turning on consistent across both and has the advantage of being able to correct determine in in-tree args whether a flavour enables assertions or not. Ticket #22096 - - - - - 15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00 Add regression test for #21550 This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5 "Use local instances with least superclass depth" - - - - - 7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00 Minor cleanup - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused), isCoVar_maybe (duplicated by getCoVar_maybe) - Replace a few occurrences of voidPrimId with (# #). void# is a deprecated synonym for the unboxed tuple. - Use showSDoc in :show linker. This makes it consistent with the other :show commands - - - - - 31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00 Fix bootstrap with ghc-9.0 It turns out Solo is a very recent addition to base, so for older GHC versions we just defined it inline here the one place we use it in the compiler. - - - - - d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00 DmdAnal: Don't panic in addCaseBndrDmd (#22039) Rather conservatively return Top. See Note [Untyped demand on case-alternative binders]. I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and `fieldBndrDmds`. Fixes #22039. - - - - - 25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00 gitlab-ci: Ensure that ghc derivation is in scope Previously the lint-ci job attempted to use cabal-install (specifically `cabal update`) without a GHC in PATH. However, cabal-install-3.8 appears to want GHC, even for `cabal update`. - - - - - f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00 typo - - - - - fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00 typos - - - - - a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00 whitespace - - - - - 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 4f7fe1d4 by Ben Gamari at 2022-11-04T17:08:33-04:00 rts/Messages: Refactor - - - - - 6c675fb5 by Ben Gamari at 2022-11-04T17:08:33-04:00 Ordering fixes - - - - - df3ddc5c by Ben Gamari at 2022-11-04T17:08:33-04:00 eventlog: Silence spurious data race - - - - - c638a173 by Ben Gamari at 2022-11-04T17:08:33-04:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 0127e431 by Ben Gamari at 2022-11-04T17:08:33-04:00 Add TSAN support in hand-written Cmm - - - - - b2270667 by Ben Gamari at 2022-11-04T17:08:33-04:00 rts: Squash data races in blackhole claim logic Fixes #20128 and #20129. - - - - - 25fd6534 by Ben Gamari at 2022-11-04T17:08:46-04:00 Fix barrier ordering - - - - - 8 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/darwin/toolchain.nix - + .gitlab/gen_ci.hs - + .gitlab/generate_jobs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77354e2186dafcde0eb536ed445065da8a65bd1d...25fd6534ddd9e732f649c573d699132cc25bd6d6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77354e2186dafcde0eb536ed445065da8a65bd1d...25fd6534ddd9e732f649c573d699132cc25bd6d6 You're receiving 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 Nov 4 22:44:07 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 04 Nov 2022 18:44:07 -0400 Subject: [Git][ghc/ghc][wip/tsan/cmm] 2 commits: fix it Message-ID: <636595b782805_11c7e2103bab184768f8@gitlab.mail> Ben Gamari pushed to branch wip/tsan/cmm at Glasgow Haskell Compiler / GHC Commits: d822b9ec by Ben Gamari at 2022-11-04T18:43:25-04:00 fix it - - - - - 2ea74e0d by Ben Gamari at 2022-11-04T18:43:33-04:00 hadrian: Don't specify TSAN_ENABLED in +thread_sanitizer This is implied by the CPP guards in TSANUtils.h - - - - - 2 changed files: - hadrian/src/Flavour.hs - rts/include/Cmm.h Changes: ===================================== hadrian/src/Flavour.hs ===================================== @@ -181,9 +181,9 @@ splitSections = splitSectionsIf (/=ghc) -- there is little benefit. enableThreadSanitizer :: Flavour -> Flavour -enableThreadSanitizer = addArgs $ mconcat +enableThreadSanitizer = addArgs $ notStage0 ? mconcat [ builder (Ghc CompileHs) ? arg "-optc-fsanitize=thread" - , builder (Ghc CompileCWithGhc) ? (arg "-optc-fsanitize=thread" <> arg "-DTSAN_ENABLED") + , builder (Ghc CompileCWithGhc) ? (arg "-optc-fsanitize=thread") , builder (Ghc LinkHs) ? arg "-optl-fsanitize=thread" , builder (Cc CompileC) ? (arg "-fsanitize=thread" <> arg "-DTSAN_ENABLED") , builder (Cabal Flags) ? arg "thread-sanitizer" ===================================== rts/include/Cmm.h ===================================== @@ -600,9 +600,9 @@ W_[p] = value #define ACQUIRE_LOAD_WORD(out, p) \ - prim_read_barrier \ + prim_read_barrier; \ TSAN_ACQUIRE(p); \ - out = W_[p]; + out = W_[p] /* Getting/setting the info pointer of a closure */ #define SET_INFO(p,info) StgHeader_info(p) = info View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/25fd6534ddd9e732f649c573d699132cc25bd6d6...2ea74e0d1b3f785b318d6d2681b2f5cfe505faeb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/25fd6534ddd9e732f649c573d699132cc25bd6d6...2ea74e0d1b3f785b318d6d2681b2f5cfe505faeb You're receiving 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 Nov 5 00:09:24 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 04 Nov 2022 20:09:24 -0400 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] Minor refactor around FastStrings Message-ID: <6365a9b45bd3a_11c7e2103bab18482928@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 8a2febd2 by Krzysztof Gogolewski at 2022-11-04T20:09:16-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - 30 changed files: - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Validity.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a2febd20ba4843f77b7286c981019b65a3cfe69 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a2febd20ba4843f77b7286c981019b65a3cfe69 You're receiving 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 Nov 5 00:37:54 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 04 Nov 2022 20:37:54 -0400 Subject: [Git][ghc/ghc][wip/tsan/codegen] 2351 commits: Fix #19931 Message-ID: <6365b0625b778_11c7e219fb717448924d@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: e8f7734d by John Ericson at 2021-07-21T22:51:41+00:00 Fix #19931 The issue was the renderer for x86 addressing modes assumes native size registers, but we were passing in a possibly-smaller index in conjunction with a native-sized base pointer. The easist thing to do is just extend the register first. I also changed the other NGC backends implementing jump tables accordingly. On one hand, I think PowerPC and Sparc don't have the small sub-registers anyways so there is less to worry about. On the other hand, to the extent that's true the zero extension can become a no-op. I should give credit where it's due: @hsyl20 really did all the work for me in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4717#note_355874, but I was daft and missed the "Oops" and so ended up spending a silly amount of time putting it all back together myself. The unregisterised backend change is a bit different, because here we are translating the actual case not a jump table, and the fix is to handle right-sized literals not addressing modes. But it makes sense to include here too because it's the same change in the subsequent commit that exposes both bugs. - - - - - 024020c3 by John Ericson at 2021-07-21T22:52:52+00:00 Use fix-sized equality primops for fixed size boxed types These are the last to be converted. - - - - - fd7e272e by Sylvain Henry at 2021-07-23T21:05:41-04:00 Perf: fix strictness in OccurAnal This patch enhances OccurAnal perf by using a dedicated WithUsageDetails datatype instead of a tuple (similarly to what has been done in demand-analysis) with strict fields. OccEnv is also passed strictly with more strict fields as it improves results even more. T9198 flukes isn't reproducible locally (cf https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5667#note_364358) Metric Decrease: ManyConstructors T10421 T12150 T12425 T12707 T13056 T13253 T13253-spj T15164 T16577 T18282 T18698a T18698b T1969 T4801 T5642 T9020 T9233 T9630 T9675 T9961 WWRec T12227 T13035 T18304 T6048 T12234 T783 T20049 Metric Increase: T9198 - - - - - ba302877 by sheaf at 2021-07-23T21:06:18-04:00 Add nontrivial type-checking plugin tests Three new tests for type-checking plugins: - TcPlugin_Nullary, solving a nullary class constraint - TcPlugin_Args, providing evidence for a (unary) class constraint using arguments supplied to the plugin - TcPlugin_TyFam, solving an equality constraint to rewrite a type-family application More extensive descriptions of the plugins can be found in their respective defining modules. - - - - - 5d670abd by sheaf at 2021-07-23T21:06:56-04:00 Generalise reallyUnsafePtrEquality# and use it fixes #9192 and #17126 updates containers submodule 1. Changes the type of the primop `reallyUnsafePtrEquality#` to the most general version possible (heterogeneous as well as levity-polymorphic): > reallyUnsafePtrEquality# > :: forall {l :: Levity} {k :: Levity} > (a :: TYPE (BoxedRep l)) (b :: TYPE (BoxedRep k)) > . a -> b -> Int# 2. Adds a new internal module, `GHC.Ext.PtrEq`, which contains pointer equality operations that are now subsumed by `reallyUnsafePtrEquality#`. These functions are then re-exported by `GHC.Exts` (so that no function goes missing from the export list of `GHC.Exts`, which is user-facing). More specifically, `GHC.Ext.PtrEq` defines: - A new function: * reallyUnsafePtrEquality :: forall (a :: Type). a -> a -> Int# - Library definitions of ex-primops: * `sameMutableArray#` * `sameSmallMutableArray` * `sameMutableByteArray#` * `sameMutableArrayArray#` * `sameMutVar#` * `sameTVar#` * `sameMVar#` * `sameIOPort#` * `eqStableName#` - New functions for comparing non-mutable arrays: * `sameArray#` * `sameSmallArray#` * `sameByteArray#` * `sameArrayArray#` These were requested in #9192. Generally speaking, existing libraries that use `reallyUnsafePtrEquality#` will continue to work with the new, levity-polymorphic version. But not all! Some (`containers`, `unordered-containers`, `dependent-map`) contain the following: > unsafeCoerce# reallyUnsafePtrEquality# a b If we make `reallyUnsafePtrEquality#` levity-polymorphic, this code fails the current GHC representation-polymorphism checks. We agreed that the right solution here is to modify the library; in this case by deleting the call to `unsafeCoerce#`, since `reallyUnsafePtrEquality#` is now type-heterogeneous too. - - - - - 4beb12db by Matthew Pickering at 2021-07-23T21:07:31-04:00 Add test for #13157 Closes #13157 - - - - - 509445b5 by Matthew Pickering at 2021-07-23T21:08:05-04:00 Check the buffer size *before* calling the continuation in withEncodedCString This fixes a very subtle bug in withEncodedCString where a reference would be kept to the whole continuation until the continuation had finished executing. This was because the call to tryFillBufferAndCall could fail, if the buffer was already full and so the `go` helper would be recursively called on failure which necessitated keeping a reference to `act`. The failure could only happen during the initial checking phase of the function but not during the call to the continuation. Therefore the fix is to first perform the size check, potentially recursively and then finally calling tail calling the continuation. In the real world, this broke writing lazy bytestrings because a reference to the head of the bytestring would be retained in the continuation until the whole string had been written to a file. Fixes #20107 - - - - - 6c79981e by Fendor at 2021-07-23T21:08:42-04:00 Introduce FinderLocations for decoupling Finder from DynFlags - - - - - b26a7065 by Matthew Pickering at 2021-07-23T21:09:17-04:00 Fix a few retainer leaks of TcGblEnv Methodology: Create a -hi profile and then search for TcGblEnv then use ghc-debug to work out why they are being retained and remove the reason. Retaining TcGblEnv is dangerous because it contains pointers to things such as a TypeEnv which is updated throughout compilation. I found two places which were retaining a TcGblEnv unecessarily. Also fix a few places where an OccName was retaining an Id. - - - - - efaad7ad by Matthew Pickering at 2021-07-23T21:09:17-04:00 Stop ug_boring_info retaining a chain of old CoreExpr It was noticed in #20134 that each simplifier iteration used an increasing amount of memory and that a certain portion of memory was not released until the simplfier had completely finished. I profiled the program using `-hi` profiling and observed that there was a thunk arising in the computation of `ug_boring_ok`. On each iteration `ug_boring_ok` would be updated, but not forced, which would leave a thunk in the shape of ug_boring_ok = inlineBoringOk expr0 || inlineBoringOk expr2 || inlineBoringOk expr3 || ... which would retain all previous `expr` until `ug_boring_ok` was forced or discarded. Forcing this accumulator eagerly results in a flat profile over multiple simplifier runs. This reduces the maximum residency when compiling the test in #20134 from 2GB to 1.3G. ------------------------- Metric Decrease: T11545 ------------------------- - - - - - b6434ed3 by Ben Gamari at 2021-07-23T21:09:52-04:00 Cmm.Opt: Fix type of shift amount in constant folding Previously the `MO_S_Quot` constant folding rule would incorrectly pass the shift amount of the same width as the shifted value. However, the machop's type expects the shift amount to be a Word. Fixes #20142. - - - - - a31aa271 by Ben Gamari at 2021-07-23T21:09:52-04:00 testsuite: Add test for #20142 - - - - - 3801b35a by Moritz Angermann at 2021-07-25T09:41:46-04:00 [CI] absolutely no caching on darwin We failed at doing caching properly, so for now we won't do any caching at all. This is not safe in a concurrent setting, however all our darwin builders run with concurrency 1, and -j8, on 8 core m1 mac minis. - - - - - 1832676a by Moritz Angermann at 2021-07-25T09:41:46-04:00 [rts] Untag bq->bh prior to reading the info table In `checkBlockingQueues` we must always untag the `bh` field of an `StgBlockingQueue`. While at first glance it might seem a sensible assumption that `bh` will always be a blackhole and therefore never be tagged, the GC could shortcut the indirection and put a tagged pointer into the indirection. This blew up on aarch64-darwin with a misaligned access. `bh` pointed to an address that always ended in 0xa. On architectures that are a little less strict about alignment, this would have read a garbage info table pointer, which very, very unlikely would have been equal to `stg_BLACKHOLE_info` and therefore things accidentally worked. However, on AArch64, the read of the info table pointer resulted in a SIGBUS due to misaligned read. Fixes #20093. - - - - - 5b39a107 by Ben Gamari at 2021-07-25T17:30:52+00:00 hadrian: Don't add empty -I arguments Previously hadrian would add a -I$FfiIncludeDir flag to compiler invocations even if FfiIncludeDir was null, resulting in compilation errors. - - - - - 5f3991c7 by Sylvain Henry at 2021-07-26T04:55:03-04:00 RTS: try to fix timer races * Pthread based timer was initialized started while some other parts of the RTS assume it is initialized stopped, e.g. in hs_init_ghc: /* Start the "ticker" and profiling timer but don't start until the * scheduler is up. However, the ticker itself needs to be initialized * before the scheduler to ensure that the ticker mutex is initialized as * moreCapabilities will attempt to acquire it. */ * after a fork, don't start the timer before the IOManager is initialized: the timer handler (handle_tick) might call wakeUpRts to perform an idle GC, which calls wakeupIOManager/ioManagerWakeup Found while debugging #18033/#20132 but I couldn't confirm if it fixes them. - - - - - 0462750f by Fendor at 2021-07-27T04:46:42-04:00 Remove unused module GHC.Rename.Doc - - - - - 51ff0365 by Ben Gamari at 2021-07-27T04:47:16-04:00 rename: Avoid unnecessary map lookup Previously the -Wcompat-unqualified-imports warning would first check whether an import is of a covered module, incurring an map lookup, before checking the simple boolean predicate of whether it is qualified. This is more expensive than strictly necessary (although at the moment the warning is unused, so this will make little difference). - - - - - 167a01f7 by Ben Gamari at 2021-07-27T04:47:51-04:00 rts: Document CPP guards - - - - - 246f08ac by Ben Gamari at 2021-07-27T04:47:51-04:00 rts: Move libffi interfaces all to Adjustor Previously the libffi Adjustor implementation would use allocateExec to create executable mappings. However, allocateExec is also used elsewhere in GHC to allocate things other than ffi_closure, which is a use-case which libffi does not support. - - - - - 2ce48fe9 by Ben Gamari at 2021-07-27T04:47:51-04:00 rts: Break up adjustor logic - - - - - 3b07d827 by Ben Gamari at 2021-07-27T04:47:51-04:00 rts/adjustor: Drop redundant commments - - - - - 0e875c3f by Ben Gamari at 2021-07-27T04:47:51-04:00 rts: Introduce and use ExecPage abstraction Here we introduce a very thin abstraction for allocating, filling, and freezing executable pages to replace allocateExec. - - - - - f6e366c0 by Ben Gamari at 2021-07-27T04:47:51-04:00 rts: Drop allocateExec and friends All uses of these now use ExecPage. - - - - - dd3c9602 by Ben Gamari at 2021-07-27T04:47:51-04:00 hadrian: Always specify flag values explicitly Previously we would often allow cabal flags to default, making it harder than necessary to reason about the effective build configuration. - - - - - 63184a71 by Ben Gamari at 2021-07-27T04:47:51-04:00 rts: Don't declare libCffi as bundled when using system libffi Previously the rts's cabal file would claim that it bundled libffi, even if we are using the system's libffi. Fixes #19869. - - - - - 8c5c27f1 by Andreas Klebinger at 2021-07-27T04:48:26-04:00 Rename itimer to ticker in rts/posix for consistency. - - - - - 5457a124 by Andreas Klebinger at 2021-07-27T04:48:26-04:00 Use pthread if available on linux - - - - - b19f1a6a by Ben Gamari at 2021-07-27T04:49:00-04:00 rts/OSThreads: Ensure that we catch failures from pthread_mutex_lock Previously we would only catch EDEADLK errors. - - - - - 0090517a by Ben Gamari at 2021-07-27T04:49:00-04:00 rts/OSThreads: Improve error handling consistency Previously we relied on the caller to check the return value from broadcastCondition and friends, most of whom neglected to do so. Given that these functions should not fail anyways, I've opted to drop the return value entirely and rather move the result check into the OSThreads functions. This slightly changes the semantics of timedWaitCondition which now returns false only in the case of timeout, rather than any error as previously done. - - - - - 229b4e51 by Ben Gamari at 2021-07-27T04:49:36-04:00 rts: Fix inconsistent signatures for collect_pointers Fixes #20160. - - - - - c2893361 by Fraser Tweedale at 2021-07-27T04:50:13-04:00 doc: fix copy/paste error The `divInt#` implementation note has heading: See Note [divInt# implementation] This seems to be a copy/paste mistake. Remove "See" from the heading. - - - - - 4816d9b7 by Alina Banerjee at 2021-07-27T12:01:15-04:00 validate: fix #18477, improve syntax & add if-else checks for test outcomes/validation paths ShellCheck(https://github.com/koalaman/shellcheck/wiki) has been used to check the script. - - - - - 575f1f2f by Alina Banerjee at 2021-07-27T12:01:15-04:00 validate: add flags using Hadrian's user settings for ignoring changes in performance tests - - - - - 421110b5 by Alina Banerjee at 2021-07-27T12:01:15-04:00 validate: add a debug flag (in both Hadrian and legacy Make) for running tests - - - - - 9d8cb93e by Alina Banerjee at 2021-07-27T12:01:15-04:00 validate: update quick-validate flavour for validation with --fast - - - - - 07696269 by Alina Banerjee at 2021-07-27T12:01:15-04:00 validate: change test ghc based on BINDIST value (YES/NO) - - - - - 83a88988 by Alina Banerjee at 2021-07-27T12:01:15-04:00 validate: run stage1 tests using stage1 compiler when BINSTIST is false - - - - - 64b6bc23 by Alina Banerjee at 2021-07-27T12:01:15-04:00 validate: check both stage1, stage2 test failures for deciding success of entire test run - - - - - 74b79191 by Alina Banerjee at 2021-07-27T12:01:15-04:00 validate: Add note for BINDIST variable, GitLab validation; clean up comments - - - - - 888eadb9 by Matthew Pickering at 2021-07-27T12:01:51-04:00 packaging: Be more precise about which executables to copy and wrappers to create Exes ---- Before: The whole bin/ folder was copied which could contain random old/stale/testsuite executables After: Be precise Wrappers -------- Before: Wrappers were created for everything in the bin folder, including internal executables such as "unlit" After: Only create wrappers for the specific things which we want to include in the user's path. This makes the hadrian bindists match up more closely with the make bindists. - - - - - e4c25261 by Matthew Pickering at 2021-07-27T12:01:51-04:00 packaging: Give ghc-pkg the same version as ProjectVersion - - - - - 8e43dc90 by Matthew Pickering at 2021-07-27T12:01:51-04:00 hadrian: Update hsc2hs wrapper to match current master - - - - - 172fd5d1 by Matthew Pickering at 2021-07-27T12:01:51-04:00 hadrian: Remove special haddock copying rule - - - - - f481c189 by Matthew Pickering at 2021-07-27T12:01:51-04:00 packaging: Create both versioned and unversioned executables Before we would just copy the unversioned executable into the bindist. Now the actual executable is copied into the bindist and a version suffix is added. Then a wrapper or symlink is added which points to the versioned executable. Fixes #20074 - - - - - acc47bd2 by Matthew Pickering at 2021-07-27T12:01:51-04:00 packaging: Add note about wrappers - - - - - 5412730e by Matthew Pickering at 2021-07-27T12:01:51-04:00 packaging: Don't include configure scripts in windows bindist Fixes #19868 - - - - - 22a16b0f by Matthew Pickering at 2021-07-27T12:01:51-04:00 hadrian: Install windows bindist by copying in test_hadrian - - - - - 45f05554 by Matthew Pickering at 2021-07-27T12:01:51-04:00 hadrian: Add exe suffix to executables in testsuite - - - - - 957fe359 by Matthew Pickering at 2021-07-27T12:01:51-04:00 hadrian: Call ghc-pkg recache after copying package database into bindist The package.cache needs to have a later mod-time than all of the .conf files. This invariant can be destroyed by `cp -r` and so we run `ghc-pkg recache` to ensure the package database which is distributed is consistent. If you are installing a relocatable bindist, for example, on windows, you should preserve mtimes by using cp -a or run ghc-pkg recache after installing. - - - - - 7b0ceafb by Matthew Pickering at 2021-07-27T12:01:51-04:00 testsuite: Add more debug output on failure to call ghc-pkg - - - - - 0c4a0c3b by Simon Peyton Jones at 2021-07-27T12:02:25-04:00 Make CallStacks work better with RebindableSyntax As #19918 pointed out, the CallStack mechanism didn't work well with RebindableSyntax. This patch improves matters. See GHC.Tc.Types.Evidence Note [Overview of implicit CallStacks] * New predicate isPushCallStackOrigin distinguishes when a CallStack constraint should be solved "directly" or by pushing an item on the stack. * The constructor EvCsPushCall now has a FastString, which can describe not only a function call site, but also things like "the literal 42" or "an if-then-else expression". * I also fixed #20126 thus: exprCtOrigin (HsIf {}) = IfThenElseOrigin (Previously it was "can't happen".) - - - - - 6d2846f7 by Simon Peyton Jones at 2021-07-27T12:02:25-04:00 Eta expand through CallStacks This patch fixes #20103, by treating HasCallStack constraints as cheap when eta-expanding. See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity - - - - - 9bf8d530 by Simon Peyton Jones at 2021-07-27T12:03:00-04:00 Eliminate unnecessary unsafeEqualityProof This patch addresses #20143, which wants to discard unused calls to unsafeEqualityProof. There are two parts: * In exprOkForSideEffects, we want to know that unsafeEqualityProof indeed terminates, without any exceptions etc * But we can only discard the case if we know that the coercion variable is not used, which means we have to gather accurate occurrence info for CoVars. Previously OccurAnal only did a half hearted job of doing so; this patch finishes the job. See Note [Gather occurrences of coercion variables] in OccurAnal. Because the occurrence analyser does more work, there is a small compile-time cost but it's pretty small. The compiler perf tests are usually 0.0% but occasionally up to 0.3% increase. I'm just going to accept this -- gathering accurate occurrence information really seems like the Right Thing to do. There is an increase in `compile_time/peak_megabytes_allocated`, for T11545, or around 14%; but I can't reproduce it on my machine (it's the same before and after), and the peak-usage stats are vulnerable to when exactly the GC takes place, so I'm just going to accept it. Metric Increase: T11545 - - - - - cca08c2c by Krzysztof Gogolewski at 2021-07-27T12:03:35-04:00 Parser: suggest TemplateHaskell on $$(...) (#20157) - - - - - 20b352eb by Andreas Abel at 2021-07-27T12:04:12-04:00 Doc: tabs to spaces - - - - - ebcdf3fa by Andreas Abel at 2021-07-27T12:04:12-04:00 Doc: warnings: since: remove minor version number for uniformity New warnings are only released in major versions, it seems. One way or the other, a .1 minor version can always be dropped. - - - - - 0b403319 by Andreas Abel at 2021-07-27T12:04:12-04:00 Issue #18087: :since: for warnings of ghc 6/7/8 Added :since: fields to users_guide on warning, for warnings introduced starting GHC 6.0. The data was extracted from the HTML docs on warnings, see https://gitlab.haskell.org/ghc/ghc/-/issues/18087 and partially verified by consulting the change logs. - - - - - f27dba8b by Andreas Abel at 2021-07-27T12:04:12-04:00 Re #18087 !6238 Empty line in front of :since: Ack. @monoidal - - - - - c7c0964c by Krzysztof Gogolewski at 2021-07-27T21:35:17-04:00 Simplify FFI code Remains of the dotnet FFI, see a7d8f43718 and 1fede4bc95 - - - - - 97e0837d by Krzysztof Gogolewski at 2021-07-27T21:35:17-04:00 Remove some unused names The comment about 'parError' was obsolete. - - - - - cab890f7 by Krzysztof Gogolewski at 2021-07-27T21:35:17-04:00 Add a regression test for #17697 - - - - - 9da20e3d by Krzysztof Gogolewski at 2021-07-27T21:35:17-04:00 Don't abort on representation polymorphism check This is reverting a change introduced in linear types commit 40fa237e1da. Previously, we had to abort early, but thanks to later changes, this is no longer needed. There's no test, but the behavior should be better. The plan is to remove levity polymorphism checking in the desugarer anyway. - - - - - cddafcf6 by Sylvain Henry at 2021-07-27T21:35:55-04:00 PIC: test for cross-module references - - - - - 323473e8 by Sylvain Henry at 2021-07-28T06:16:58-04:00 Hadrian: disable profiled RTS with no_profiled_libs flavour transformer Hadrian uses the RTS ways to determine which iserv programs to embed into bindist. But profiled iserv program (and any other code) can't be built without profiling libs and Hadrian fails. So we disable the profiling RTS way with the no_profiled_libs flavour transformer. - - - - - 10678945 by Ben Gamari at 2021-07-28T06:17:32-04:00 rts: Don't rely on configuration when CLEANING=YES The make build system doesn't source config.mk when CLEANING=YES, consequently we previously failed to identify an appropriate adjustor implementation to use during cleaning. Fixes #20166. - - - - - f3256769 by Krzysztof Gogolewski at 2021-07-28T13:18:31-04:00 Docs: use :default: and :ghc-ticket: - - - - - dabe6113 by Krzysztof Gogolewski at 2021-07-28T13:18:31-04:00 Document DerivingVia unsafety (#19786) - - - - - 2625d48e by Krzysztof Gogolewski at 2021-07-28T13:18:31-04:00 Improve docs of bang patterns (#19068) - - - - - a57e4a97 by Krzysztof Gogolewski at 2021-07-28T13:18:31-04:00 Functor docs: link to free theorem explanation (#19300) - - - - - d43a9029 by Simon Peyton Jones at 2021-07-28T13:19:06-04:00 Fix smallEnoughToInline I noticed that smallEnoughToInline said "no" to UnfWhen guidance, which seems quite wrong -- those functions are particularly small. - - - - - 4e4ca28c by Simon Peyton Jones at 2021-07-28T13:19:06-04:00 Print out module name in "bailing out" message - - - - - 9dbab4fd by Simon Peyton Jones at 2021-07-28T13:19:06-04:00 Improve postInlineUnconditionally See Note [Use occ-anald RHS in postInlineUnconditionally]. This explains how to eliminate an extra round of simplification, which can happen if postInlineUnconditionally uses a RHS that is no occurrence-analysed. This opportunity has been there for ages; I discovered it when looking at a compile-time perf regression that happened because the opportunity wasn't exploited. - - - - - 25ca0b5a by Simon Peyton Jones at 2021-07-28T13:19:06-04:00 Extend the in-scope set to silence substExpr warnings substExpr warns if it finds a LocalId that isn't in the in-scope set. This patch extends the in-scope set to silence the warnings. (It has no effect on behaviour.) - - - - - a67e6814 by Simon Peyton Jones at 2021-07-28T13:19:06-04:00 White space, spelling, and a tiny refactor No change in behaviour - - - - - 05f54bb4 by Simon Peyton Jones at 2021-07-28T13:19:06-04:00 Make the occurrence analyser a bit stricter occAnalArgs and occAnalApp are very heavily used functions, so it pays to make them rather strict: fewer thunks constructed. All these thunks are ultimately evaluated anyway. This patch gives a welcome reduction compile time allocation of around 0.5% across the board. For T9961 it's a 2.2% reduction. Metric Decrease: T9961 - - - - - 2567d13b by Simon Peyton Jones at 2021-07-28T13:19:06-04:00 Inline less logging code When eyeballing calls of GHC.Core.Opt.Simplify.Monad.traceSmpl, I saw that lots of cold-path logging code was getting inlined into the main Simplifier module. So in GHC.Utils.Logger I added a NOINLINE on logDumpFile'. For logging, the "hot" path, up to and including the conditional, should be inlined, but after that we should inline as little as possible, to reduce code size in the caller. - - - - - a199d653 by Simon Peyton Jones at 2021-07-28T13:19:40-04:00 Simplify and improve the eta expansion mechanism Previously the eta-expansion would return lambdas interspersed with casts; now the cast is just pushed to the outside: #20153. This actually simplifies the code. I also improved mkNthCo to account for SymCo, so that mkNthCo n (SymCo (TyConAppCo tc cos)) would work well. - - - - - 299b7436 by Simon Peyton Jones at 2021-07-28T13:19:41-04:00 Improve performance of eta expansion Eta expansion was taking ages on T18223. This patch * Aggressively squash reflexive casts in etaInfoApp. See Note [Check for reflexive casts in eta expansion] These changes decreased compile-time allocation by 80%! * Passes the Simplifier's in-scope set to etaExpandAT, so we don't need to recompute it. (This alone saved 10% of compile time.) Annoyingly several functions in the Simplifier (namely makeTrivialBinding and friends) need to get SimplEnv, rather than SimplMode, but that is no big deal. Lots of small changes in compile-time allocation, less than 1% and in both directions. A couple of bigger changes, including the rather delicate T18223 T12425(optasm) ghc/alloc 98448216.0 97121224.0 -1.3% GOOD T18223(normal) ghc/alloc 5454689676.0 1138238008.0 -79.1% GOOD Metric Decrease: T12425 T18223 - - - - - 91eb1857 by Simon Peyton Jones at 2021-07-28T13:19:41-04:00 Fix a subtle scoping error in simplLazyBind In the call to prepareBinding (in simplLazyBind), I had failed to extend the in-scope set with the binders from body_floats1. As as result, when eta-expanding deep inside prepareBinding we made up an eta-binder that shadowed a variable free in body1. Yikes. It's hard to trigger this bug. It showed up when I was working on !5658, and I started using the in-scope set for eta-expansion, rather than taking free variables afresh. But even then it only showed up when compiling a module in Haddock utils/haddock/haddock-api/src/Haddock/Interface/Rename.hs Sadly Haddock is compiled without Core Lint, so we ultimately got a seg-fault. Lint nailed it fast once I realised that it was off. There is some other tiny refactoring in this patch. - - - - - 7dc0dc99 by CarrieMY at 2021-07-28T13:20:17-04:00 Fix type check error message grammar (fixes #20122) Remove trailing spaces - - - - - 3382b3d6 by CarrieMY at 2021-07-28T13:20:17-04:00 Update expected stderr for affected tests, which are not under Tc directory - - - - - 4a2ef3dd by Alfredo Di Napoli at 2021-07-28T13:20:52-04:00 Port more DriverUnknownMessage into richer DriverMessage constructors In order: * Introduce the `PsErrUnknownOptionsPragma` diagnostic message This commit changes the diagnostic emitted inside `GHC.Parser.Header.checkProcessArgsResult` from an (erroneous) and unstructured `DriverUnknownMessage` to a `PsErrUnknownOPtionsPragma`, i.e. a new data constructor of a `PsHeaderMessage`. * Add the `DriverUserDefinedRuleIgnored` diagnostic message * Add `DriverUserDefinedRuleIgnored` data constructor This commit adds (and use) a new data constructor to the `DriverMessage` type, replacing a `DriverUnknownMessage` with it. * Add and use `DriverCannotLoadInterfaceFile` constructor This commit introduces the DriverCannotLoadInterfaceFile constructor for the `DriverMessage` type and it uses it to replace and occurrence of `DriverUnknownMessage`. * Add and use the `DriverInferredSafeImport` constructor This commit adds a new `DriverInferredSafeImport` constructor to the `DriverMessage` type, and uses it in `GHC.Driver.Main` to replace one occurrence of `DriverUnknownMessage`. * Add and use `DriverCannotImportUnsafeModule` constructor This commit adds the `DriverCannotImportUnsafeModule` constructor to the `DriverMessage` type, and later using it to replace one usage of `DriverUnknownMessage` in the `GHC.Driver.Main` module. * Add and use `DriverMissingSafeHaskellMode` constructor * Add and use `DriverPackageNotTrusted` constructor * Introduce and use `DriverInferredSafeModule` constructor * Add and use `DriverMarkedTrustworthyButInferredSafe` constructor * Add and use `DriverCannotImportFromUntrustedPackage` - - - - - de262930 by Peter Trommler at 2021-07-29T13:12:10-04:00 Delete ToDo about incorrect optimisation [skip ci] On big-endian systems a narrow after a load cannot be replaced with a narrow load. - - - - - 296ed739 by Daniel Gröber at 2021-07-29T13:12:47-04:00 rts: Allow building with ASSERTs on in non-DEBUG way We have a couple of places where the conditions in asserts depend on code ifdefed out when DEBUG is off. I'd like to allow compiling assertions into non-DEBUG RTSen so that won't do. Currently if we remove the conditional around the definition of ASSERT() the build will not actually work due to a deadlock caused by initMutex not initializing mutexes with PTHREAD_MUTEX_ERRORCHECK because DEBUG is off. - - - - - e6731578 by Daniel Gröber at 2021-07-29T13:12:47-04:00 Add configure flag to enable ASSERTs in all ways Running the test suite with asserts enabled is somewhat tricky at the moment as running it with a GHC compiled the DEBUG way has some hundred failures from the start. These seem to be unrelated to assertions though. So this provides a toggle to make it easier to debug failing assertions using the test suite. - - - - - 4d5b4ed2 by Ben Gamari at 2021-07-29T13:13:21-04:00 compiler: Name generated locals more descriptively Previously `GHC.Types.Id.Make.newLocal` would name all locals `dt`, making it unnecessarily difficult to determine their origin. Noticed while looking at #19557. - - - - - 20173629 by Sergei Trofimovich at 2021-07-29T13:13:59-04:00 UNREG: implement 64-bit mach ops for 32-bit targets Noticed build failures like ``` ghc-stage1: panic! (the 'impossible' happened) GHC version 9.3.20210721: pprCallishMachOp_for_C: MO_x64_Ne not supported! ``` on `--tagget=hppa2.0-unknown-linux-gnu`. The change does not fix all 32-bit unreg target problems, but at least allows linking final ghc binaries. Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org> - - - - - 9b916e81 by Matthew Pickering at 2021-07-29T13:14:33-04:00 Add test for #18567 Closes #18567 - - - - - f4aea1a2 by Krzysztof Gogolewski at 2021-07-29T13:15:09-04:00 Reject pattern synonyms with linear types (#18806) - - - - - 54d6b201 by Shayne Fletcher at 2021-07-29T13:15:43-04:00 Improve preprocessor error message - - - - - 266a7452 by Ben Gamari at 2021-08-02T04:10:18-04:00 ghc: Introduce --run mode As described in #18011, this mode provides similar functionality to the `runhaskell` command, but doesn't require that the user know the path of yet another executable, simplifying interactions with upstream tools. - - - - - 7e8c578e by Simon Jakobi at 2021-08-02T04:10:52-04:00 base: Document overflow behaviour of genericLength - - - - - b4d39adb by Peter Trommler at 2021-08-02T04:11:27-04:00 PrimOps: Add CAS op for all int sizes PPC NCG: Implement CAS inline for 32 and 64 bit testsuite: Add tests for smaller atomic CAS X86 NCG: Catch calls to CAS C fallback Primops: Add atomicCasWord[8|16|32|64]Addr# Add tests for atomicCasWord[8|16|32|64]Addr# Add changelog entry for new primops X86 NCG: Fix MO-Cmpxchg W64 on 32-bit arch ghc-prim: 64-bit CAS C fallback on all archs - - - - - a4ca6caa by Baldur Blöndal at 2021-08-02T04:12:04-04:00 Add Generically (generic Semigroup, Monoid instances) and Generically1 (generic Functor, Applicative, Alternative, Eq1, Ord1 instances) to GHC.Generics. - - - - - 2114a8ac by Julian Ospald at 2021-08-02T04:12:41-04:00 Improve documentation of openTempFile args https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamew Specifically: > The null-terminated prefix string. The function uses up to the first > three characters of this string as the prefix of the file name. This > string must consist of characters in the OEM-defined character set. - - - - - 4ae1e53c by Sylvain Henry at 2021-08-02T04:12:41-04:00 Fix spelling - - - - - 022c7945 by Moritz Angermann at 2021-08-02T04:13:15-04:00 [AArch64/Darwin] fix packed calling conv alignment Apparently we need some padding as well. Fixes #20137 - - - - - 2de8f031 by Ben Gamari at 2021-08-02T04:13:15-04:00 testsuite: Add test for #20137 - - - - - 2e0f4ca1 by Adam Sandberg Ericsson at 2021-08-02T04:13:50-04:00 docs: rename the "Running a compiled program" section in the users guide This hopefully makes it easier to find the right section when scanning the table of contents. - - - - - f454c0ea by Ben Gamari at 2021-08-02T04:14:25-04:00 rts/OSThreads: Fix reference clock of timedWaitCondition Previously `timedWaitCondition` assumed that timeouts were referenced against `CLOCK_MONOTONIC`. This is wrong; by default `pthread_cond_timedwait` references against `CLOCK_REALTIME`, although this can be overridden using `pthread_condattr_setclock`. Fix this and add support for using `CLOCK_MONOTONIC` whenever possible as it is more robust against system time changes and is likely cheaper to query. Unfortunately, this is complicated by the fact that older versions of Darwin did not provide `clock_gettime`, which means we also need to introduce a fallback path using `gettimeofday`. Fixes #20144. - - - - - 7bad93a2 by Sylvain Henry at 2021-08-02T04:15:03-04:00 Only create callstack in DEBUG builds - - - - - 3968cd0c by Sylvain Henry at 2021-08-02T04:15:41-04:00 Constant-fold unpackAppendCString (fix #20174) Minor renaming: since 1ed0409010afeaa318676e351b833aea659bf93a rules get an InScopeEnv arg (containing an IdUnfoldingFun) instead of an IdUnfoldingFun directly, hence I've renamed the parameter from "id_unf" to "env" for clarity. - - - - - 901c79d8 by Sylvain Henry at 2021-08-02T04:15:41-04:00 Lookup string literals in top-level thunks (fix #16373) - - - - - 3e93a370 by Ben Gamari at 2021-08-02T04:16:16-04:00 validate: Look for python3 executable in python detection Previously we would only look for a `python` executable, but in general we should prefer `python3` and sometimes `python` doesn't exist. - - - - - 8631ccf2 by Krzysztof Gogolewski at 2021-08-02T04:16:51-04:00 Remove Semigroup instance for UniqDFM (#19654) The (<>) operator was not associative. Fortunately, the instance is not used anywhere, except to derive another unused instance for UniqDSet. - - - - - 20ef67a3 by Ben Gamari at 2021-08-02T04:17:26-04:00 hadrian: Drop --configure support Hadrian's `--configure` support has long been a point of contention. While it's convenient, it also introduces a fair bit of implementation complexity and quite a few non-trivial failure modes (see #19804, 17883, and #15948). Moreover, the feature is actively misleading to the user: `./configure` is the primary means for the user to inform the build system about the system environment and in general will require input from the user. This commits removes the feature, replacing the flag with a stub message informing the user of the deprecation. Closes #20167. - - - - - 13af2fee by Krzysztof Gogolewski at 2021-08-02T04:18:00-04:00 Disallow nonlinear fields in Template Haskell (#18378) - - - - - e1538184 by Shayne Fletcher at 2021-08-02T04:18:35-04:00 Supply missing case for '.' in - - - - - 34e35217 by Simon Peyton Jones at 2021-08-02T04:19:09-04:00 Catch type-checker exceptions when splicing In GHC.Tc.Gen.Splice.tcTopSpliceExpr we were forgetting to catch exceptions. As a result we missed the kind error in the unsolved constraints. This patch has an easy fix, which cures #20179 - - - - - c248e7cc by Jens Petersen at 2021-08-03T10:14:36-04:00 include README in hadrian.cabal [skip ci] - - - - - bbee89dd by Zubin Duggal at 2021-08-03T10:15:11-04:00 Remove hschooks.c and -no-hs-main for ghc-bin - - - - - 9807350a by Zubin Duggal at 2021-08-03T10:15:11-04:00 Properly escape arguments in ghc-cabal - - - - - d22ec8a9 by Ben Gamari at 2021-08-03T10:15:46-04:00 Bump process submodule - - - - - 694ec53b by Matthew Pickering at 2021-08-03T10:16:20-04:00 Remove eager forcing of RuleInfo in substRuleInfo substRuleInfo updates the IdInfo for an Id, therefore it is important to not force said IdInfo whilst updating it, otherwise we end up in an infinite loop. This is what happened in #20112 where `mkTick` forced the IdInfo being updated by checking the arity in isSaturatedConApp. The fix is to stop the expression being forced so early by removing the call to seqRuleInfo. The call sequence looked something like: * `substRecBndrs` * `substIdBndr` * `substIdInfo` * `substRuleInfo` * `substRule` * `substExpr` * `mkTick` * `isSaturatedConApp` * Look at `IdInfo` for thing we are currently substituting because the rule is attached to `transpose` and mentions it in the `RHS` of the rule. Which arose because the `transpose` Id had a rule attached where the RHS of the rule also mentioned `transpose`. This call to seqRuleInfo was introduced in 4e7d56fde0f44d38bbb9a6fc72cf9c603264899d where it was explained > I think there are now *too many* seqs, and they waste work, but I don't have > time to find which ones. We also observe that there is the ominous note on `substRule` about making sure substExpr is called lazily. > {- Note [Substitute lazily] > ~~~~~~~~~~~~~~~~~~~~~~~~~~~ > The functions that substitute over IdInfo must be pretty lazy, because > they are knot-tied by substRecBndrs. > > One case in point was #10627 in which a rule for a function 'f' > referred to 'f' (at a different type) on the RHS. But instead of just > substituting in the rhs of the rule, we were calling simpleOptExpr, which > looked at the idInfo for 'f'; result <<loop>>. > > In any case we don't need to optimise the RHS of rules, or unfoldings, > because the simplifier will do that. Before `seqRuleInfo` was removed, this note was pretty much ignored in the `substSpec` case because the expression was immediately forced after `substRule` was called. Unfortunately it's a bit tricky to add a test for this as the failure only manifested (for an unknown reason) with a dwarf enabled compiler *AND* compiling with -g3. Fortunatley there is currently a CI configuration which builds a dwarf compiler to test this. Also, for good measure, finish off the work started in 840df33685e8c746ade4b9d4d0eb7c764a773e48 which renamed SpecInfo to RuleInfo but then didn't rename 'substSpec' to 'substRuleInfo'. Fixes #20112 - - - - - c0e66524 by Krzysztof Gogolewski at 2021-08-03T10:16:55-04:00 Add "fast-ci" label, for skipping most builds (#19280) If "fast-ci" is present, only the following parts of full-build are run: - validate-x86_64-linux-deb9-debug - validate-x86_64-windows-hadrian - validate-x86_64-linux-deb9-unreg-hadrian - - - - - bd287400 by Andreas Klebinger at 2021-08-03T10:17:29-04:00 Improve documentation for HscTypes.usg_mod_hash - - - - - 5155eafa by Zubin Duggal at 2021-08-03T10:18:04-04:00 Handle OverloadedRecordDot in TH (#20185) - - - - - 9744c6f5 by Tito Sacchi at 2021-08-03T17:19:14-04:00 Correctly unload libs on GHCi with external iserv Fix #17669 `hostIsDynamic` is basically a compile-time constant embedded in the RTS. Therefore, GHCi didn't unload object files properly when used with an external interpreter built in a different way. - - - - - 3403c028 by Luite Stegeman at 2021-08-03T17:19:51-04:00 move bytecode preparation into the STG pipeline this makes it possible to combine passes to compute free variables more efficiently in a future change - - - - - 6ad25367 by Sylvain Henry at 2021-08-03T17:20:29-04:00 Fix ASSERTS_ENABLED CPP - - - - - 4f672677 by Sylvain Henry at 2021-08-03T17:21:07-04:00 Don't store tmpDir in Settings There was no point in doing this as indicated by the TODO. - - - - - 2c714f07 by Krzysztof Gogolewski at 2021-08-04T01:33:03-04:00 Disable -fdefer-type-errors for linear types (#20083) - - - - - 9b719549 by Krzysztof Gogolewski at 2021-08-04T01:33:38-04:00 Linear types: fix linting of multiplicities (#19165) The previous version did not substitute the type used in the scrutinee. - - - - - 1b6e646e by John Ericson at 2021-08-04T10:05:52-04:00 Make HsWrapper a Monoid See instance documentation for caviat. - - - - - ce7eeda5 by Matthew Pickering at 2021-08-04T10:06:26-04:00 hadrian: Create relative rather than absolute symlinks in binary dist folder The symlink structure now looks like: ``` lrwxrwxrwx 1 matt users 16 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/ghc -> ghc-9.3.20210721 -rwxr-xr-x 1 matt users 1750336 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/ghc-9.3.20210721 lrwxrwxrwx 1 matt users 22 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/ghc-iserv -> ghc-iserv-9.3.20210721 -rwxr-xr-x 1 matt users 31703176 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/ghc-iserv-9.3.20210721 lrwxrwxrwx 1 matt users 26 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/ghc-iserv-dyn -> ghc-iserv-dyn-9.3.20210721 -rwxr-xr-x 1 matt users 40808 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/ghc-iserv-dyn-9.3.20210721 lrwxrwxrwx 1 matt users 20 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/ghc-pkg -> ghc-pkg-9.3.20210721 -rwxr-xr-x 1 matt users 634872 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/ghc-pkg-9.3.20210721 lrwxrwxrwx 1 matt users 14 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/haddock -> haddock-2.24.0 -rwxr-xr-x 1 matt users 4336664 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/haddock-2.24.0 lrwxrwxrwx 1 matt users 9 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/hp2ps -> hp2ps-0.1 -rwxr-xr-x 1 matt users 49312 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/hp2ps-0.1 lrwxrwxrwx 1 matt users 8 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/hpc -> hpc-0.68 -rwxr-xr-x 1 matt users 687896 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/hpc-0.68 lrwxrwxrwx 1 matt users 13 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/hsc2hs -> hsc2hs-0.68.8 -rwxr-xr-x 1 matt users 729904 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/hsc2hs-0.68.8 lrwxrwxrwx 1 matt users 19 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/runghc -> runghc-9.3.20210721 -rwxr-xr-x 1 matt users 57672 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/runghc-9.3.20210721 lrwxrwxrwx 1 matt users 9 Aug 3 16:27 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/unlit -> unlit-0.1 -rwxr-xr-x 1 matt users 14896 Aug 3 15:00 _build/bindist/ghc-9.3.20210721-x86_64-unknown-linux/bin/unlit-0.1 ``` Fixes #20198 - - - - - 477bc2dd by Zubin Duggal at 2021-08-04T16:38:02-04:00 Fix GHCi completion (#20101) Updates haskeline submodule - - - - - 7a9d8803 by sheaf at 2021-08-04T16:38:40-04:00 Use Reductions to keep track of rewritings We define Reduction = Reduction Coercion !Type. A reduction of the form 'Reduction co new_ty' witnesses an equality ty ~co~> new_ty. That is, the rewriting happens left-to-right: the right-hand-side type of the coercion is the rewritten type, and the left-hand-side type the original type. Sticking to this convention makes the codebase more consistent, helping to avoid certain applications of SymCo. This replaces the parts of the codebase which represented reductions as pairs, (Coercion,Type) or (Type,Coercion). Reduction being strict in the Type argument improves performance in some programs that rewrite many type families (such as T9872). Fixes #20161 ------------------------- Metric Decrease: T5321Fun T9872a T9872b T9872c T9872d ------------------------- - - - - - 1f809093 by Bodigrim at 2021-08-05T07:14:04-04:00 Add Data.ByteArray, derived from primitive - - - - - 5d651c78 by Krzysztof Gogolewski at 2021-08-05T07:14:39-04:00 Minor fix to pretty-printing of linear types The function ppr_arrow_chain was not printing multiplicities. Also remove the Outputable instance: no longer used, and could cover bugs like those. - - - - - fb45e632 by Viktor Dukhovni at 2021-08-08T13:53:00-04:00 Rewrite of Traversable overview - - - - - 2bf417f6 by Viktor Dukhovni at 2021-08-08T13:53:00-04:00 Consistent use of coercion and TypeApplications This makes the implementations of: - mapAccumL - mapAccumR - fmapDefault - foldMapDefault more uniform and match the approach in the overview. - - - - - cf7e6c8d by Ben Gamari at 2021-08-09T08:10:11-04:00 testsuite: Add test for #20199 Ensures that Rts.h can be parsed as C++. - - - - - 080ffd4b by Ben Gamari at 2021-08-09T08:10:11-04:00 rts: Fix use of sized array in Heap.h Sized arrays cannot be used in headers that might be imported from C++. Fixes #20199. - - - - - b128a880 by Sylvain Henry at 2021-08-09T15:11:22-04:00 Ensure that newtype deriving strategy is used for CTypes - - - - - 74863638 by Sylvain Henry at 2021-08-09T15:11:23-04:00 Remove ad-hoc fromIntegral rules fromIntegral is defined as: {-# NOINLINE [1] fromIntegral #-} fromIntegral :: (Integral a, Num b) => a -> b fromIntegral = fromInteger . toInteger Before this patch, we had a lot of rewrite rules for fromIntegral, to avoid passing through Integer when there is a faster way, e.g.: "fromIntegral/Int->Word" fromIntegral = \(I# x#) -> W# (int2Word# x#) "fromIntegral/Word->Int" fromIntegral = \(W# x#) -> I# (word2Int# x#) "fromIntegral/Word->Word" fromIntegral = id :: Word -> Word Since we have added sized types and primops (Word8#, Int16#, etc.) and Natural, this approach didn't really scale as there is a combinatorial explosion of types. In addition, we really want these conversions to be optimized for all these types and in every case (not only when fromIntegral is explicitly used). This patch removes all those ad-hoc fromIntegral rules. Instead we rely on inlining and built-in constant-folding rules. There are not too many native conversions between Integer/Natural and fixed size types, so we can handle them all explicitly. Foreign.C.Types was using rules to ensure that fromIntegral rules "sees" through the newtype wrappers,e.g.: {-# RULES "fromIntegral/a->CSize" fromIntegral = \x -> CSize (fromIntegral x) "fromIntegral/CSize->a" fromIntegral = \(CSize x) -> fromIntegral x #-} But they aren't necessary because coercions due to newtype deriving are pushed out of the way. So this patch removes these rules (as fromIntegral is now inlined, they won't match anymore anyway). Summary: * INLINE `fromIntegral` * Add some missing constant-folding rules * Remove every fromIntegral ad-hoc rules (fix #19907) Fix #20062 (missing fromIntegral rules for sized primitives) Performance: - T12545 wiggles (tracked by #19414) Metric Decrease: T12545 T10359 Metric Increase: T12545 - - - - - db7098fe by John Ericson at 2021-08-09T15:11:58-04:00 Clean up whitespace in /includes I need to do this now or when I move these files the linter will be mad. - - - - - fc350dba by John Ericson at 2021-08-09T15:11:58-04:00 Make `PosixSource.h` installed and under `rts/` is used outside of the rts so we do this rather than just fish it out of the repo in ad-hoc way, in order to make packages in this repo more self-contained. - - - - - d5de970d by John Ericson at 2021-08-09T15:11:58-04:00 Move `/includes` to `/rts/include`, sort per package better In order to make the packages in this repo "reinstallable", we need to associate source code with a specific packages. Having a top level `/includes` dir that mixes concerns (which packages' includes?) gets in the way of this. To start, I have moved everything to `rts/`, which is mostly correct. There are a few things however that really don't belong in the rts (like the generated constants haskell type, `CodeGen.Platform.h`). Those needed to be manually adjusted. Things of note: - No symlinking for sake of windows, so we hard-link at configure time. - `CodeGen.Platform.h` no longer as `.hs` extension (in addition to being moved to `compiler/`) so as not to confuse anyone, since it is next to Haskell files. - Blanket `-Iincludes` is gone in both build systems, include paths now more strictly respect per-package dependencies. - `deriveConstants` has been taught to not require a `--target-os` flag when generating the platform-agnostic Haskell type. Make takes advantage of this, but Hadrian has yet to. - - - - - 8b9acc4d by Sylvain Henry at 2021-08-09T15:12:36-04:00 Hadrian: fix .cabal file `stack sdist` in the hadrian directory reported: Package check reported the following errors: To use the 'extra-doc-files' field the package needs to specify at least 'cabal-version: >= 1.18'. - - - - - 741fdf0e by David Simmons-Duffin at 2021-08-10T15:00:05-04:00 Add a Typeable constraint to fromStaticPtr, addressing #19729 - - - - - 130f94db by Artyom Kuznetsov at 2021-08-10T15:00:42-04:00 Refactor HsStmtContext and remove HsDoRn Parts of HsStmtContext were split into a separate data structure HsDoFlavour. Before this change HsDo used to have HsStmtContext inside, but in reality only parts of HsStmtContext were used and other cases were invariants handled with panics. Separating those parts into its own data structure helps us to get rid of those panics as well as HsDoRn type family. - - - - - 92b0037b by Sylvain Henry at 2021-08-10T15:01:20-04:00 Fix recomp021 locale `diff` uses the locale to print its message. - - - - - 7bff8bf5 by Sylvain Henry at 2021-08-10T15:01:58-04:00 Fix pprDeps Copy-paste error in 38faeea1a94072ffd9f459d9fe570f06bc1da84a - - - - - c65a7ffa by Moritz Angermann at 2021-08-11T06:49:38+00:00 Update HACKING.md - - - - - f5fdace5 by Sven Tennie at 2021-08-11T18:14:30-04:00 Optimize Info Table Provenance Entries (IPEs) Map creation and lookup Using a hash map reduces the complexity of lookupIPE(), making it non linear. On registration each IPE list is added to a temporary IPE lists buffer, reducing registration time. The hash map is built lazily on first lookup. IPE event output to stderr is added with tests. For details, please see Note [The Info Table Provenance Entry (IPE) Map]. A performance test for IPE registration and lookup can be found here: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5724#note_370806 - - - - - 100ffe75 by Alina Banerjee at 2021-08-11T18:15:05-04:00 Modify InlineSpec data constructor (helps fix #18138) The inl_inline field of the InlinePragma record is modified to store pragma source text by adding a data constructor of type SourceText. This can help in tracking the actual text of pragma names. Add/modify functions, modify type instance for InlineSpec type Modify parser, lexer to handle InlineSpec constructors containing SourceText Modify functions with InlineSpec type Extract pragma source from InlineSpec for SpecSig, InlineSig types Modify cvtInline function to add SourceText to InlineSpec type Extract name for InlineSig, SpecSig from pragma, SpectInstSig from source (fixes #18138) Extract pragma name for SpecPrag pragma, SpecSig signature Add Haddock annotation for inlinePragmaName function Add Haddock annotations for using helper functions in hsSigDoc Remove redundant ppr in pragma name for SpecSig, InlineSig; update comment Rename test to T18138 for misplaced SPECIALIZE pragma testcase - - - - - 7ad813a4 by Dr. ERDI Gergo at 2021-08-13T07:53:53-04:00 Move `ol_witness` to `OverLitTc` We also add a new `ol_from_fun` field to renamed (but not yet typechecked) OverLits. This has the nice knock-on effect of making total some typechecker functions that used to be partial. Fixes #20151 - - - - - c367b39e by Sylvain Henry at 2021-08-13T07:54:32-04:00 Refactoring module dependencies * Make mkDependencies pure * Use Sets instead of sorted lists Notable perf changes: MultiLayerModules(normal) ghc/alloc 4130851520.0 2981473072.0 -27.8% T13719(normal) ghc/alloc 4313296052.0 4151647512.0 -3.7% Metric Decrease: MultiLayerModules T13719 - - - - - 9d4ba36f by sheaf at 2021-08-13T14:40:16+02:00 Add rewriting to typechecking plugins Type-checking plugins can now directly rewrite type-families. The TcPlugin record is given a new field, tcPluginRewrite. The plugin specifies how to rewrite certain type-families with a value of type `UniqFM TyCon TcPluginRewriter`, where: type TcPluginRewriter = RewriteEnv -- Rewriter environment -> [Ct] -- Givens -> [TcType] -- type family arguments -> TcPluginM TcPluginRewriteResult data TcPluginRewriteResult = TcPluginNoRewrite | TcPluginRewriteTo { tcPluginRewriteTo :: Reduction , tcRewriterNewWanteds :: [Ct] } When rewriting an exactly-saturated type-family application, GHC will first query type-checking plugins for possible rewritings before proceeding. Includes some changes to the TcPlugin API, e.g. removal of the EvBindsVar parameter to the TcPluginM monad. - - - - - 0bf8e73a by Matthew Pickering at 2021-08-13T21:47:26-04:00 Revert "hadrian: Make copyFileLinked a bit more robust" This reverts commit d45e3cda669c5822aa213d42bf7f7c551b9d1bbf. - - - - - 9700b9a8 by Matthew Pickering at 2021-08-13T21:47:26-04:00 Create absolute symlink for test executables This is necessary because the symlink needs to be created between two arbritary filepaths in the build tree, it's hard to compute how to get between them relatively. As this symlink doesn't end up in a bindist then it's fine for it to be absolute. - - - - - a975583c by Matthew Pickering at 2021-08-13T21:48:03-04:00 hadrian: Also produce versioned wrapper scripts Since !6133 we are more consistent about producing versioned executables but we still didn't produce versioned wrappers. This patch adds the corresponding versioned wrappers to match the versioned executables in the relocatable bindist. I also fixed the ghci wrapper so that it wasn't overwritten during installation. The final bindir looks like: ``` lrwxrwxrwx 1 matt users 16 Aug 12 11:56 ghc -> ghc-9.3.20210809 -rwxr-xr-x 1 matt users 674 Aug 12 11:56 ghc-9.3.20210809 lrwxrwxrwx 1 matt users 17 Aug 12 11:56 ghci -> ghci-9.3.20210809 -rwxr-xr-x 1 matt users 708 Aug 12 11:56 ghci-9.3.20210809 lrwxrwxrwx 1 matt users 20 Aug 12 11:56 ghc-pkg -> ghc-pkg-9.3.20210809 -rwxr-xr-x 1 matt users 734 Aug 12 11:56 ghc-pkg-9.3.20210809 lrwxrwxrwx 1 matt users 14 Aug 12 11:56 haddock -> haddock-2.24.0 -rwxr-xr-x 1 matt users 682 Aug 12 11:56 haddock-2.24.0 lrwxrwxrwx 1 matt users 9 Aug 12 11:56 hp2ps -> hp2ps-0.1 -rwxr-xr-x 1 matt users 648 Aug 12 11:56 hp2ps-0.1 lrwxrwxrwx 1 matt users 8 Aug 12 11:56 hpc -> hpc-0.68 -rwxr-xr-x 1 matt users 646 Aug 12 11:56 hpc-0.68 lrwxrwxrwx 1 matt users 13 Aug 12 11:56 hsc2hs -> hsc2hs-0.68.8 -rwxr-xr-x 1 matt users 1.4K Aug 12 11:56 hsc2hs-0.68.8 lrwxrwxrwx 1 matt users 19 Aug 12 11:56 runghc -> runghc-9.3.20210809 -rwxr-xr-x 1 matt users 685 Aug 12 11:56 runghc-9.3.20210809 ``` Fixes #20225 - - - - - 1e896b47 by sheaf at 2021-08-15T09:00:29-04:00 Detect TypeError when checking for insolubility We detect insoluble Givens by making getInertInsols take into account TypeError constraints, on top of insoluble equalities such as Int ~ Bool (which it already took into account). This allows pattern matches with insoluble contexts to be reported as redundant (tyOracle calls tcCheckGivens which calls getInertInsols). As a bonus, we get to remove a workaround in Data.Typeable.Internal: we can directly use a NotApplication type family, as opposed to needing to cook up an insoluble equality constraint. Fixes #11503 #14141 #16377 #20180 - - - - - 71130bf8 by sheaf at 2021-08-15T09:01:06-04:00 Update TcPlugin_RewritePerf performance test This test exhibited inconsistent behaviour, with different CI runs having a 98% decrease in allocations. This commit addresses this problem by ensuring that we measure allocations of the whole collection of modules used in the test. ------------------------- Metric Increase: TcPlugin_RewritePerf ------------------------- - - - - - 0f6fb7d3 by Simon Peyton Jones at 2021-08-15T14:18:52+01:00 TypeError is OK on the RHS of a type synonym We should not complain about TypeError in type T = TypeError blah This fixes #20181 The error message for T13271 changes, because that test did indeed have a type synonym with TypeError on the RHS - - - - - 149bce42 by Krzysztof Gogolewski at 2021-08-15T16:13:35-04:00 Fix lookupIdSubst call during RULE matching As #20200 showed, there was a call to lookupIdSubst during RULE matching, where the variable being looked up wasn't in the InScopeSet. This patch fixes the problem at source, by dealing separately with nested and non-nested binders. As a result we can change the trace call in lookupIdSubst to a proper panic -- if it happens, we really want to know. - - - - - 7f217429 by Simon Peyton Jones at 2021-08-15T16:13:35-04:00 Use the right InScopeSet for findBest This is the right thing to do, easy to do, and fixes a second not-in-scope crash in #20200 (see !6302) The problem occurs in the findBest test, which compares two RULES. Repro case in simplCore/should_compile/T20200a - - - - - 31dc013f by Greg Steuck at 2021-08-15T21:09:23+00:00 Fix iconv detection in configure on OpenBSD This regressed in 544414ba604b13e0992ad87e90b8bdf45c43011c causing configure: error: iconv is required on non-Windows platforms More details: https://gitlab.haskell.org/ghc/ghc/-/commit/544414ba604b13e0992ad87e90b8bdf45c43011c#3bae3b74ae866493bd6b79df16cb638a5f2e0f87_106_106 - - - - - acb188e0 by Matthew Pickering at 2021-08-17T08:05:34-04:00 ghci: Fix rec statements in interactive prompt We desugar a recursive Stmt to somethign like (a,_,c) <- mfix (\(a,b,_) -> do { ... ; return (a,b,c) }) ...stuff after the rec... The knot-tied tuple must contain * All the variables that are used before they are bound in the `rec` block * All the variables that are used after the entire `rec` block In the case of GHCi, however, we don't know what variables will be used after the `rec` (#20206). For example, we might have ghci> rec { x <- e1; y <- e2 } ghci> print x ghci> print y So we have to assume that *all* the variables bound in the `rec` are used afterwards. We use `Nothing` in the argument to segmentRecStmts to signal that all the variables are used. Fixes #20206 - - - - - b784a51e by John Ericson at 2021-08-17T20:58:33+00:00 Test non-native switch C-- with twos compliment We don't want regressions like e8f7734d8a052f99b03e1123466dc9f47b48c311 to regress. Co-Authored-By: Sylvain Henry <hsyl20 at gmail.com> - - - - - 5798357d by Sylvain Henry at 2021-08-17T21:01:44+00:00 StgToCmm: use correct bounds for switches on sized values StgToCmm was only using literals signedness to determine whether using Int and Word range in Cmm switches. Now that we have sized literals (Int8#, Int16#, etc.), it needs to take their ranges into account. - - - - - 0ba21dbe by Matthew Pickering at 2021-08-18T05:43:57-04:00 Fix parsing of rpaths which include spaces in runInjectRPaths The logic didn't account for the fact that the paths could contain spaces before which led to errors such as the following from install_name_tool. Stderr ( T14304 ): Warning: -rtsopts and -with-rtsopts have no effect with -shared. Call hs_init_ghc() from your main() function to set these options. error: /nix/store/a6j5761iy238pbckxq2xrhqr2d5kra4m-cctools-binutils-darwin-949.0.1/bin/install_name_tool: for: dist/build/libHSp-0.1-ghc8.10.6.dylib (for architecture arm64) option "-add_rpath /Users/matt/ghc/bindisttest/install dir/lib/ghc-8.10.6/ghc-prim-0.6.1" would duplicate path, file already has LC_RPATH for: /Users/matt/ghc/bindisttest/install dir/lib/ghc-8.10.6/ghc-prim-0.6.1 `install_name_tool' failed in phase `Install Name Tool'. (Exit code: 1) Fixes #20212 This apparently also fixes #20026, which is a nice surprise. - - - - - 5f0d2dab by Matthew Pickering at 2021-08-18T17:57:42-04:00 Driver rework pt3: the upsweep This patch specifies and simplifies the module cycle compilation in upsweep. How things work are described in the Note [Upsweep] Note [Upsweep] ~~~~~~~~~~~~~~ Upsweep takes a 'ModuleGraph' as input, computes a build plan and then executes the plan in order to compile the project. The first step is computing the build plan from a 'ModuleGraph'. The output of this step is a `[BuildPlan]`, which is a topologically sorted plan for how to build all the modules. ``` data BuildPlan = SingleModule ModuleGraphNode -- A simple, single module all alone but *might* have an hs-boot file which isn't part of a cycle | ResolvedCycle [ModuleGraphNode] -- A resolved cycle, linearised by hs-boot files | UnresolvedCycle [ModuleGraphNode] -- An actual cycle, which wasn't resolved by hs-boot files ``` The plan is computed in two steps: Step 1: Topologically sort the module graph without hs-boot files. This returns a [SCC ModuleGraphNode] which contains cycles. Step 2: For each cycle, topologically sort the modules in the cycle *with* the relevant hs-boot files. This should result in an acyclic build plan if the hs-boot files are sufficient to resolve the cycle. The `[BuildPlan]` is then interpreted by the `interpretBuildPlan` function. * `SingleModule nodes` are compiled normally by either the upsweep_inst or upsweep_mod functions. * `ResolvedCycles` need to compiled "together" so that the information which ends up in the interface files at the end is accurate (and doesn't contain temporary information from the hs-boot files.) - During the initial compilation, a `KnotVars` is created which stores an IORef TypeEnv for each module of the loop. These IORefs are gradually updated as the loop completes and provide the required laziness to typecheck the module loop. - At the end of typechecking, all the interface files are typechecked again in the retypecheck loop. This time, the knot-tying is done by the normal laziness based tying, so the environment is run without the KnotVars. * UnresolvedCycles are indicative of a proper cycle, unresolved by hs-boot files and are reported as an error to the user. The main trickiness of `interpretBuildPlan` is deciding which version of a dependency is visible from each module. For modules which are not in a cycle, there is just one version of a module, so that is always used. For modules in a cycle, there are two versions of 'HomeModInfo'. 1. Internal to loop: The version created whilst compiling the loop by upsweep_mod. 2. External to loop: The knot-tied version created by typecheckLoop. Whilst compiling a module inside the loop, we need to use the (1). For a module which is outside of the loop which depends on something from in the loop, the (2) version is used. As the plan is interpreted, which version of a HomeModInfo is visible is updated by updating a map held in a state monad. So after a loop has finished being compiled, the visible module is the one created by typecheckLoop and the internal version is not used again. This plan also ensures the most important invariant to do with module loops: > If you depend on anything within a module loop, before you can use the dependency, the whole loop has to finish compiling. The end result of `interpretBuildPlan` is a `[MakeAction]`, which are pairs of `IO a` actions and a `MVar (Maybe a)`, somewhere to put the result of running the action. This list is topologically sorted, so can be run in order to compute the whole graph. As well as this `interpretBuildPlan` also outputs an `IO [Maybe (Maybe HomeModInfo)]` which can be queried at the end to get the result of all modules at the end, with their proper visibility. For example, if any module in a loop fails then all modules in that loop will report as failed because the visible node at the end will be the result of retypechecking those modules together. Along the way we also fix a number of other bugs in the driver: * Unify upsweep and parUpsweep. * Fix #19937 (static points, ghci and -j) * Adds lots of module loop tests due to Divam. Also related to #20030 Co-authored-by: Divam Narula <dfordivam at gmail.com> ------------------------- Metric Decrease: T10370 ------------------------- - - - - - d9cf2ec8 by Matthew Pickering at 2021-08-18T17:57:42-04:00 recomp: Check backend type rather than -fwrite-interface to decide whether we need any objects This was a small oversight in the original patch which leads to spurious recompilation when using `-fno-code` but not `-fwrite-interface`, which you plausibly might do when using ghci. Fixes #20216 - - - - - 4a10f0ff by sheaf at 2021-08-18T17:58:19-04:00 Don't look for TypeError in type family arguments Changes checkUserTypeError to no longer look for custom type errors inside type family arguments. This means that a program such as foo :: F xyz (TypeError (Text "blah")) -> bar does not throw a type error at definition site. This means that more programs can be accepted, as the custom type error might disappear upon reducing the above type family F. This applies only to user-written type signatures, which are checked within checkValidType. Custom type errors in type family arguments continue to be reported when they occur in unsolved Wanted constraints. Fixes #20241 - - - - - cad5a141 by Viktor Dukhovni at 2021-08-19T01:19:29-04:00 Fix missing can_fail annotation on two CAS primops Also note why has_side_effects is needed with reads of mutable data, using text provided by Simon Peyton-Jones. - - - - - 4ff4d434 by Simon Peyton Jones at 2021-08-19T01:20:03-04:00 Get the in-scope set right during RULE matching There was a subtle error in the in-scope set during RULE matching, which led to #20200 (not the original report, but the reports of failures following an initial bug-fix commit). This patch fixes the problem, and simplifies the code a bit. In pariticular there was a very mysterious and ad-hoc in-scope set extension in rnMatchBndr2, which is now moved to the right place, namely in the Let case of match, where we do the floating. I don't have a small repro case, alas. - - - - - d43442cb by John Ericson at 2021-08-19T18:02:13-04:00 Make Int64#/Word64# unconditionally available This prepares us to actually use them when the native size is 64 bits too. I more than saitisfied my curiosity finding they were gated since 47774449c9d66b768a70851fe82c5222c1f60689. - - - - - ad28ae41 by Matthew Pickering at 2021-08-19T18:02:48-04:00 Add -Wl,-U,___darwin_check_fd_set_overflow to rts/package.conf.in The make build system apparently uses this special package.conf rather than generating it from the cabal file. Ticket: #19950 (cherry picked from commit e316a0f3e7a733fac0c30633767487db086c4cd0) - - - - - 69fb6f6a by Ben Gamari at 2021-08-23T13:33:41-04:00 users guide: Document -hpcdir flag Previously this was undocumented. - - - - - 27c27f7d by Matthew Pickering at 2021-08-23T13:34:16-04:00 hadrian: Include runhaskell in bindist Fixes #19571 bin folder now containers/ ``` ghc ghc-iserv-dyn-9.3.20210813 hp2ps hsc2hs-0.68.8 unlit ghc-9.3.20210813 ghc-pkg hp2ps-0.1 runghc unlit-0.1 ghc-iserv ghc-pkg-9.3.20210813 hpc runghc-9.3.20210813 ghc-iserv-9.3.20210813 haddock hpc-0.68 runhaskell ghc-iserv-dyn haddock-2.24.0 hsc2hs runhaskell-9.3.20210813 ``` which installed via wrappers looks like ``` lrwxrwxrwx 1 matt users 16 Aug 13 17:32 ghc -> ghc-9.3.20210813 -rwxr-xr-x 1 matt users 446 Aug 13 17:32 ghc-9.3.20210813 lrwxrwxrwx 1 matt users 17 Aug 13 17:32 ghci -> ghci-9.3.20210813 -rwxr-xr-x 1 matt users 480 Aug 13 17:32 ghci-9.3.20210813 lrwxrwxrwx 1 matt users 20 Aug 13 17:32 ghc-pkg -> ghc-pkg-9.3.20210813 -rwxr-xr-x 1 matt users 506 Aug 13 17:32 ghc-pkg-9.3.20210813 lrwxrwxrwx 1 matt users 14 Aug 13 17:32 haddock -> haddock-2.24.0 -rwxr-xr-x 1 matt users 454 Aug 13 17:32 haddock-2.24.0 lrwxrwxrwx 1 matt users 9 Aug 13 17:32 hp2ps -> hp2ps-0.1 -rwxr-xr-x 1 matt users 420 Aug 13 17:32 hp2ps-0.1 lrwxrwxrwx 1 matt users 8 Aug 13 17:32 hpc -> hpc-0.68 -rwxr-xr-x 1 matt users 418 Aug 13 17:32 hpc-0.68 lrwxrwxrwx 1 matt users 13 Aug 13 17:32 hsc2hs -> hsc2hs-0.68.8 -rwxr-xr-x 1 matt users 1.2K Aug 13 17:32 hsc2hs-0.68.8 lrwxrwxrwx 1 matt users 19 Aug 13 17:32 runghc -> runghc-9.3.20210813 -rwxr-xr-x 1 matt users 457 Aug 13 17:32 runghc-9.3.20210813 lrwxrwxrwx 1 matt users 23 Aug 13 17:32 runhaskell -> runhaskell-9.3.20210813 -rwxr-xr-x 1 matt users 465 Aug 13 17:32 runhaskell-9.3.20210813 ``` - - - - - 7dde84ad by Matthew Pickering at 2021-08-23T13:34:16-04:00 hadrian: Write version wrappers in C rather than Haskell This reduces the resulting binary size on windows where the executables were statically linked. - - - - - 6af7d127 by Matthew Pickering at 2021-08-23T13:34:16-04:00 hadrian: Use ghc version as suffix for all executables ``` [matt at nixos:~/ghc-unique-spin]$ ls _build/bindist/ghc-9.3.20210813-x86_64-unknown-linux/bin/ ghc haddock runghc ghc-9.3.20210813 haddock-ghc-9.3.20210813 runghc-9.3.20210813 ghc-iserv hp2ps runhaskell ghc-iserv-dyn hp2ps-ghc-9.3.20210813 runhaskell-9.3.20210813 ghc-iserv-dyn-ghc-9.3.20210813 hpc unlit ghc-iserv-ghc-9.3.20210813 hpc-ghc-9.3.20210813 unlit-ghc-9.3.20210813 ghc-pkg hsc2hs ghc-pkg-9.3.20210813 hsc2hs-ghc-9.3.20210813 [matt at nixos:~/ghc-unique-spin]$ ls _build/bindist/ghc-9.3.20210813-x86_64-unknown-linux/wrappers/ ghc ghc-pkg-9.3.20210813 hpc runghc-9.3.20210813 ghc-9.3.20210813 haddock hpc-ghc-9.3.20210813 runhaskell ghci haddock-ghc-9.3.20210813 hsc2hs runhaskell-9.3.20210813 ghci-9.3.20210813 hp2ps hsc2hs-ghc-9.3.20210813 ghc-pkg hp2ps-ghc-9.3.20210813 runghc ``` See the discussion on #19571 where we decided that it was most sensible to use the same version number as a suffix for all executables. For those whose version number is different to normal (for example, haddock as it's own versioning scheme) the additional "ghc" suffix is used. Cabal already knows to look for this suffix so should work nicely with existing tooling. - - - - - 06aa8da5 by Sebastian Graf at 2021-08-23T13:34:51-04:00 Pmc: Better SCC annotations and trace output While investigating #20106, I made a few refactorings to the pattern-match checker that I don't want to lose. Here are the changes: * Some key functions of the checker now have SCC annotations * Better `-ddump-ec-trace` diagnostics for easier debugging. I added 'traceWhenFailPm' to see *why* a particular `MaybeT` computation fails and made use of it in `instCon`. I also increased the acceptance threshold of T11545, which seems to fail randomly lately due to ghc/max flukes. - - - - - c1acfd21 by Matthew Pickering at 2021-08-23T13:35:26-04:00 driver: Only check for unused package warning in after succesful downsweep Before we would check for the unused package warning even if the module graph was compromised due to an error in downsweep. This is easily fixed by pushing warmUnusedPackages into depanalE, and then returning the errors like the other downsweep errors. Fixes #20242 - - - - - f3892b5f by Krzysztof Gogolewski at 2021-08-23T13:36:00-04:00 Convert lookupIdSubst panic back to a warning (#20200) - - - - - c0407538 by Andreas Abel at 2021-08-23T13:36:38-04:00 Doc fix #20259: suggest bang patterns instead of case in hints.rst - - - - - d94e7ebd by Andreas Abel at 2021-08-23T13:37:15-04:00 Doc fix #20226: formatting issues in 9.2.1 release notes RST is brittle... - - - - - 8a939b40 by sheaf at 2021-08-23T23:39:15-04:00 TcPlugins: solve and report contras simultaneously This changes the TcPlugin datatype to allow type-checking plugins to report insoluble constraints while at the same time solve some other constraints. This allows better error messages, as the plugin can still simplify constraints, even when it wishes to report a contradiction. Pattern synonyms TcPluginContradiction and TcPluginOk are provided for backwards compatibility: existing type-checking plugins should continue to work without modification. - - - - - 03fc0393 by Matthew Pickering at 2021-08-23T23:39:49-04:00 driver: Correctly pass custom messenger to logging function This was an oversight from !6718 - - - - - 64696202 by Matthew Pickering at 2021-08-23T23:39:49-04:00 driver: Initialise common plugins once, before starting the pipeline This fixes an error message regression and is a slight performance improvement. See #20250 - - - - - 886ecd31 by Matthew Pickering at 2021-08-23T23:39:49-04:00 Add plugin-recomp-change-2 test This test tests that if there are two modules which use a plugin specified on the command line then both are recompiled when the plugin changes. - - - - - 31752b55 by Matthew Pickering at 2021-08-24T11:03:01-04:00 hadrian: Use cp -RP rather than -P in install to copy symlinks For some inexplicable reason `-P` only takes effect on the mac version of p when you also pass `-R`. > Symbolic links are always followed unless the -R flag is set, in which case symbolic > links are not followed, by default. > -P If the -R option is specified, no symbolic links are followed. This is the > default. Fixes #20254 - - - - - fdb2bfab by Fendor at 2021-08-24T11:03:38-04:00 Export PreloadUnitClosure as it is part of the public API - - - - - 71e8094d by Matthew Pickering at 2021-08-24T17:23:58+01:00 Fix colourised output in error messages This fixes a small mistake in 4dc681c7c0345ee8ae268749d98b419dabf6a3bc which forced the dump rather than user style for error messages. In particular, this change replaced `defaultUserStyle` with `log_default_dump_context` rather than `log_default_user_context` which meant the PprStyle was PprDump rather than PprUser for error messages. https://gitlab.haskell.org/ghc/ghc/-/commit/4dc681c7c0345ee8ae268749d98b419dabf6a3bc?expanded=1&page=4#b62120081f64009b94c12d04ded5c68870d8c647_285_405 Fixes #20276 - - - - - 0759c069 by Ryan Scott at 2021-08-25T19:35:12-04:00 Desugarer: Bring existentials in scope when substituting into record GADTs This fixes an outright bug in which the desugarer did not bring the existentially quantified type variables of a record GADT into `in_subst`'s in-scope set, leading to #20278. It also addresses a minor inefficiency in which `out_subst` was made into a substitution when a simpler `TvSubstEnv` would suffice. Fixes #20278. - - - - - b3653351 by Sebastian Graf at 2021-08-26T13:39:34-04:00 CallArity: Consider shadowing introduced by case and field binders In #20283, we saw a regression in `simple` due to CallArity for a very subtle reason: It simply didn't handle shadowing of case binders and constructor field binders! The test case T20283 has a very interesting binding `n_X1` that we want to eta-expand and that has a Unique (on GHC HEAD) that is reused by the Simplifier for a case binder: ``` let { n_X1 = ... } in ... let { lvl_s1Ul = ... case x_a1Rg of wild_X1 { __DEFAULT -> f_s1Tx rho_value_awA (GHC.Types.I# wild_X1); 0# -> lvl_s1TN } ... } in letrec { go3_X3 = \ (x_X4 :: GHC.Prim.Int#) (v_a1P9 [OS=OneShot] :: Double) -> let { karg_s1Wu = ... case lvl_s1Ul of { GHC.Types.D# y_a1Qf -> ... } } in case GHC.Prim.==# x_X4 y_a1R7 of { __DEFAULT -> go3_X3 (GHC.Prim.+# x_X4 1#) karg_s1Wu; 1# -> n_X1 karg_s1Wu -- Here we will assume that karg calls n_X1! }; } in go3_X3 0#; ``` Since the Case case of CallArity doesn't delete `X1` from the set of variables it is interested in knowing the usages of, we leak a very boring usage (of the case binder!) into the co-call graph that we mistakenly take for a usage of `n_X1`. We conclude that `lvl_s1Ul` and transitively `karg_s1Wu` call `n_X1` when really they don't. That culminates in the conclusion that `n_X1 karg_s1Wu` calls `n_X1` more than once. Wrong! Fortunately, this bug (which has been there right from CallArity's inception, I suppose) will never lead to a CallArity that is too optimistic. So by fixing this bug, we get strictly more opportunities for CallArity and all of them should be sound to exploit. Fixes #20283. - - - - - d551199c by Simon Peyton Jones at 2021-08-26T13:40:09-04:00 Fix GHC.Core.Subst.substDVarSet substDVarSet looked up coercion variables in the wrong environment! The fix is easy. It is still a pretty strange looking function, but the bug is gone. This fixes another manifestation of #20200. - - - - - 14c80432 by Aaron Allen at 2021-08-27T17:37:42-04:00 GHC.Tc.Gen Diagnostics Conversion (Part 1) Converts uses of `TcRnUnknownMessage` in these modules: - compiler/GHC/Tc/Gen/Annotation.hs - compiler/GHC/Tc/Gen/App.hs - compiler/GHC/Tc/Gen/Arrow.hs - compiler/GHC/Tc/Gen/Bind.hs - - - - - e28773fc by David Feuer at 2021-08-27T17:38:19-04:00 Export Solo from Data.Tuple * The `Solo` type is intended to be the canonical lifted unary tuple. Up until now, it has only been available from `GHC.Tuple` in `ghc-prim`. Export it from `Data.Tuple` in `base`. I proposed this on the libraries list in December, 2020. https://mail.haskell.org/pipermail/libraries/2020-December/031061.html Responses from chessai https://mail.haskell.org/pipermail/libraries/2020-December/031062.html and George Wilson https://mail.haskell.org/pipermail/libraries/2021-January/031077.html were positive. There were no other responses. * Add Haddock documentation for Solo. * Give `Solo` a single field, `getSolo`, a custom `Show` instance that does *not* use record syntax, and a `Read` instance that accepts either record syntax or non-record syntax. - - - - - 38748530 by Aaron Allen at 2021-08-27T22:19:23-05:00 Convert IFace Rename Errors (#19927) Converts uses of TcRnUnknownMessage in GHC.Iface.Rename. Closes #19927 - - - - - 8057a350 by ARATA Mizuki at 2021-08-28T14:25:14-04:00 AArch64 NCG: Emit FABS instructions for fabsFloat# and fabsDouble# Closes #20275 - - - - - 922c6bc8 by ARATA Mizuki at 2021-08-28T14:25:14-04:00 Add a test for #20275 - - - - - af41496f by hainq at 2021-09-01T15:09:08+07:00 Convert diagnostics in GHC.Tc.Validity to proper TcRnMessage. - Add 19 new messages. Update test outputs accordingly. - Pretty print suggest-extensions hints: remove space before interspersed commas. - Refactor Rank's MonoType constructors. Each MonoType constructor should represent a specific case. With the Doc suggestion belonging to the TcRnMessage diagnostics instead. - Move Rank from Validity to its own `GHC.Tc.Types.Rank` module. - Remove the outdated `check_irred_pred` check. - Remove the outdated duplication check in `check_valid_theta`, which was subsumed by `redundant-constraints`. - Add missing test cases for quantified-constraints/T16474 & th/T12387a. - - - - - 5b413533 by Peter Lebbing at 2021-09-06T12:14:35-04:00 fromEnum Natural: Throw error for non-representable values Starting with commit fe770c21, an error was thrown only for the values 2^63 to 2^64-1 inclusive (on a 64-bit machine), but not for higher values. Now, errors are thrown for all non-representable values again. Fixes #20291 - - - - - 407d3b3a by Alan Zimmerman at 2021-09-06T22:57:55-04:00 EPA: order of semicolons and comments for top-level decls is wrong A comment followed by a semicolon at the top level resulted in the preceding comments being attached to the following declaration. Capture the comments as belonging to the declaration preceding the semicolon instead. Closes #20258 - - - - - 89820293 by Oleg Grenrus at 2021-09-06T22:58:32-04:00 Define returnA = id - - - - - 3fb1afea by Sylvain Henry at 2021-09-06T22:59:10-04:00 GHCi: don't discard plugins on reload (#20335) Fix regression introduced in ecfd0278 - - - - - f72aa31d by Sylvain Henry at 2021-09-07T08:02:28-04:00 Bignum: refactor conversion rules * make "passthrough" rules non built-in: they don't need to * enhance note about efficient conversions between numeric types * make integerFromNatural a little more efficient * fix noinline pragma for naturalToWordClamp# (at least with non built-in rules, we get warnings in cases like this) - - - - - 81975ef3 by Ben Gamari at 2021-09-07T08:03:03-04:00 hadrian: Ensure that settings is regenerated during bindist installation Previously Hadrian would simply install the settings file generated in the build environment during the binary distribution installation. This is wrong since these environments may differ (e.g. different `cc` versions). We noticed on Darwin when installation of a binary distribution produced on a newer Darwin release resulted in a broken compiler due to the installed `settings` file incorrectly claiming that `cc` supported `-no-pie`. Fixing this sadly requires a bit of code duplication since `settings` is produced by Hadrian and not `configure`. For now I have simply duplicated the `settings` generation logic used by the Make build system into Hadrian's bindist Makefile. Ultimately the solution will probably involve shipping a freestanding utility to replace `configure`'s toolchain probing logic and generate a toolchain description file (similar to `settings`) as described in #19877. Fixes #20253. - - - - - 2735f5a6 by Ben Gamari at 2021-09-07T08:03:03-04:00 gitlab-ci: Fix bash version-dependence in ci.sh As described in https://stackoverflow.com/questions/7577052, safely expanding bash arrays is very-nearly impossible. The previous incantation failed under the bash version shipped with Centos 7. - - - - - 7fa8c32c by Alfredo Di Napoli at 2021-09-07T12:24:12-04:00 Add and use new constructors to TcRnMessage This commit adds the following constructors to the TcRnMessage type and uses them to replace sdoc-based diagnostics in some parts of GHC (e.g. TcRnUnknownMessage). It includes: * Add TcRnMonomorphicBindings diagnostic * Convert TcRnUnknownMessage in Tc.Solver.Interact * Add and use the TcRnOrphanInstance constructor to TcRnMessage * Add TcRnFunDepConflict and TcRnDupInstanceDecls constructors to TcRnMessage * Add and use TcRnConflictingFamInstDecls constructor to TcRnMessage * Get rid of TcRnUnknownMessage from GHC.Tc.Instance.Family - - - - - 6ea9b3ee by ARATA Mizuki at 2021-09-07T12:24:49-04:00 Fix code example in the documentation of subsumption - - - - - beef6135 by John Ericson at 2021-09-08T02:57:55-04:00 Let LLVM and C handle > native size arithmetic NCG needs to call slow FFI functions where we "borrow" the C compiler's implementation, but there is no reason why we need to do that for LLVM, or the unregisterized backend where everything is via C anyways! - - - - - 5b5c2452 by Jens Petersen at 2021-09-08T02:58:33-04:00 base Data.Fixed: fix documentation typo: succ (0.000 :: Milli) /= 1.001 ie `succ (0000) == 0001` -- (not 1001) - - - - - 7a4bde22 by Joshua Price at 2021-09-08T02:59:10-04:00 Fix broken haddock @since fields in base - - - - - ebbb1fa2 by Guillaume Bouchard at 2021-09-08T02:59:47-04:00 base: Numeric: remove 'Show' constraint on 'showIntAtBase' The constraint was there in order to show the 'Integral' value in case of error. Instead we can show the result of `toInteger`, which will be close (i.e. it will still show the same integer except if the 'Show' instance was funky). This changes a bit runtime semantic (i.e. exception string may be a bit different). - - - - - fb1e0a5d by Matthew Pickering at 2021-09-08T03:00:22-04:00 ffi: Don't allow wrapper stub with CApi convention Fixes #20272 - - - - - dcc1599f by Krzysztof Gogolewski at 2021-09-08T03:00:57-04:00 Minor doc fixes - Fix markup in 9.4 release notes - Document -ddump-cs-trace - Mention that ImpredicativeTypes is really supported only since 9.2 - Remove "There are some restrictions on the use of unboxed tuples". This used to be a list, but all those restrictions were removed. - Mark -fimplicit-import-qualified as documented - Remove "The :main and :run command" - duplicated verbatim in options - Avoid calling "main" a function (cf. #7816) - Update System.getArgs: the old location was before hierarchical modules - Note that multiplicity multiplication is not supported (#20319) - - - - - 330e6e9c by Krzysztof Gogolewski at 2021-09-08T03:00:57-04:00 Documentation: use https links - - - - - 9fc0fe00 by Ben Gamari at 2021-09-08T03:01:32-04:00 rts: Factor out TRACE_ cache update logic Just a small refactoring to perhaps enable code reuse later. - - - - - 86e5a6c3 by Alan Zimmerman at 2021-09-08T16:58:51-04:00 EPA: Capture '+' location for NPlusKPat The location of the plus symbol was being discarded, we now capture it. Closes #20243 - - - - - 87d93745 by Sylvain Henry at 2021-09-08T16:59:29-04:00 Only dump Core stats when requested to do so (#20342) - - - - - 74a87aa3 by Ben Gamari at 2021-09-11T08:53:50-04:00 distrib: Drop FP_GMP from configure script None of the configure options defined by `FP_GMP` are applicable to binary distributions. - - - - - 089de88e by Sylvain Henry at 2021-09-11T08:54:29-04:00 Canonicalize bignum literals Before this patch Integer and Natural literals were desugared into "real" Core in Core prep. Now we desugar them directly into their final ConApp form in HsToCore. We only keep the double representation for BigNat# (literals larger than a machine Word/Int) which are still desugared in Core prep. Using the final form directly allows case-of-known-constructor to fire for bignum literals, fixing #20245. Slight increase (+2.3) in T4801 which is a pathological case with Integer literals. Metric Increase: T4801 T11545 - - - - - f987ec1a by nineonine at 2021-09-11T08:55:06-04:00 Add test for #18181 - - - - - 5615737a by Oleg Grenrus at 2021-09-11T08:55:43-04:00 Remove dubious Eq1 and Ord1 Fixed instances. Fixes #20309 - - - - - 88f871ef by nineonine at 2021-09-11T08:56:20-04:00 Add performance test for #19695 - - - - - c3776542 by Ben Gamari at 2021-09-11T08:56:55-04:00 Ensure that zapFragileUnfolding preseves evaluatedness As noted in #20324, previously we would drop the fact that an unfolding was evaluated, despite what the documentation claims. - - - - - 070ae69c by Ben Gamari at 2021-09-11T08:57:29-04:00 ncg: Kill incorrect unreachable code As noted in #18183, these cases were previously incorrect and unused. Closes #18183. - - - - - 2d151752 by Sebastian Graf at 2021-09-11T08:58:04-04:00 Break recursion in GHC.Float.roundingMode# (#20352) Judging from the Assumption, we should never call `roundingMode#` on a negative number. Yet the strange "dummy" conversion from `IN` to `IP` and the following recursive call where making the function recursive. Replacing the call by a panic makes `roundingMode#` non-recursive, so that we may be able to inline it. Fixes #20352. It seems we trigger #19414 on some jobs, hence Metric Decrease: T12545 - - - - - 7bfa8955 by CarrieMY at 2021-09-13T09:35:07-04:00 Fix #20203 improve constant fold for `and`/`or` This patch follows the rules specified in note [Constant folding through nested expressions]. Modifications are summarized below. - Added andFoldingRules, orFoldingRules to primOpRules under those xxxxAndOp, xxxxOrOp - Refactored some helper functions - Modify data NumOps to include two fields: numAnd and numOr Resolves: #20203 See also: #19204 - - - - - dda61f79 by Ben Gamari at 2021-09-13T09:35:44-04:00 Don't depend unconditionally on xattr in darwin_install Previously the Darwin installation logic would attempt to call xattr unconditionally. This would break on older Darwin releases where this utility did not exist. - - - - - 3c885880 by Ben Gamari at 2021-09-13T09:36:20-04:00 testsuite: Mark hDuplicateTo001 as fragile in concurrent ways As noted in #17568. - - - - - a2a16e4c by Ben Gamari at 2021-09-13T09:36:54-04:00 hadrian: Recommend use of +werror over explicit flavour modification As noted in #20327, the previous guidance was out-of-date. - - - - - 64923cf2 by Joshua Price at 2021-09-13T09:37:31-04:00 Add test for #17865 - - - - - 885f17c8 by Christiaan Baaij at 2021-09-17T09:35:18-04:00 Improve error messages involving operators from Data.Type.Ord Fixes #20009 - - - - - 4564f00f by Krzysztof Gogolewski at 2021-09-17T09:35:53-04:00 Improve pretty-printer defaulting logic (#19361) When determining whether to default a RuntimeRep or Multiplicity variable, use isMetaTyVar to distinguish between metavariables (which can be hidden) and skolems (which cannot). - - - - - 6a7ae5ed by Tito Sacchi at 2021-09-17T09:36:31-04:00 Emit warning if bang is applied to unlifted types GHC will trigger a warning similar to the following when a strictness flag is applied to an unlifted type (primitive or defined with the Unlifted* extensions) in the definition of a data constructor. Test.hs:7:13: warning: [-Wredundant-strictness-flags] • Strictness flag has no effect on unlifted type ‘Int#’ • In the definition of data constructor ‘TestCon’ In the data type declaration for ‘Test’ | 7 | data Test = TestCon !Int# | ^^^^^^^^^^^^^ Fixes #20187 - - - - - 0d996d02 by Ben Gamari at 2021-09-17T09:37:06-04:00 testsuite: Add test for #18382 - - - - - 9300c736 by Alan Zimmerman at 2021-09-17T09:37:41-04:00 EPA: correctly capture comments between 'where' and binds In the following foo = x where -- do stuff doStuff = do stuff The "-- do stuff" comment is captured in the HsValBinds. Closes #20297 - - - - - bce230c2 by Artem Pelenitsyn at 2021-09-17T09:38:19-04:00 driver: -M allow omitting the -dep-suffix (means empty) (fix #15483) - - - - - 01e07ab1 by Ziyang Liu at 2021-09-17T09:38:56-04:00 Ensure .dyn_hi doesn't overwrite .hi This commit fixes the following bug: when `outputHi` is set, and both `.dyn_hi` and `.hi` are needed, both would be written to `outputHi`, causing `.dyn_hi` to overwrite `.hi`. This causes subsequent `readIface` to fail - "mismatched interface file profile tag (wanted "", got "dyn")" - triggering unnecessary rebuild. - - - - - e7c2ff88 by Sven Tennie at 2021-09-17T09:39:31-04:00 Add compile_flags.txt for clangd (C IDE) support This file configures clangd (C Language Server for IDEs) for the GHC project. Please note that this only works together with Haskell Language Server, otherwise .hie-bios/stage0/lib does not exist. - - - - - aa6caab0 by Thomas M. DuBuisson at 2021-09-17T09:40:09-04:00 Update error message to suggest the user consider OOM over RTS bug. Fix #17039 - - - - - bfddee13 by Matthew Pickering at 2021-09-17T09:40:44-04:00 Stop leaking <defunct> llc processes We needed to wait for the process to exit in the clean-up script as otherwise the `llc` process will not be killed until compilation finishes. This leads to running out of process spaces on some OSs. Thanks to Edsko de Vries for suggesting this fix. Fixes #20305 - - - - - a6529ffd by Matthew Pickering at 2021-09-17T09:41:20-04:00 driver: Clean up temporary files after a module has been compiled The refactoring accidently removed these calls to eagerly remove temporary files after a module has been compiled. This caused some issues with tmpdirs getting filled up on my system when the project had a large number of modules (for example, Agda) Fixes #20293 - - - - - 4a7f8d5f by Matthew Pickering at 2021-09-17T09:41:55-04:00 Remove Cabal dependency from check-exact and check-ppr executables Neither uses anything from Cabal, so the dependency can just be removed. - - - - - 987180d4 by Ben Gamari at 2021-09-17T09:42:30-04:00 testsuite: Add broken testcase for #19350 - - - - - ef8a3fbf by Ben Gamari at 2021-09-17T09:42:30-04:00 ghc-boot: Fix metadata handling of writeFileAtomic Previously the implementation of writeFileAtomic (which was stolen from Cabal) failed to preserve file mode, user and group, resulting in #14017. Fixes #14017. - - - - - 18283be3 by Ben Gamari at 2021-09-17T09:43:05-04:00 compiler: Ensure that all CoreTodos have SCCs In #20365 we noticed that a significant amount of time is spend in the Core2Core cost-center, suggesting that some passes are likely missing SCC pragmas. Try to fix this. - - - - - 15a5b7a5 by Matthew Pickering at 2021-09-17T09:43:40-04:00 Add "ipe" flavour transformer to add support for building with IPE debug info The "ipe" transformer compilers everything in stage2 with `-finfo-table-map` and `-fdistinct-constructor-tables` to produce a compiler which is usable with `-hi` profiling and ghc-debug. - - - - - 053a5c2c by Ziyang Liu at 2021-09-17T09:44:18-04:00 Add doc for -dyno, -dynosuf, -dynhisuf - - - - - 9eff805a by Matthew Pickering at 2021-09-17T09:44:53-04:00 Code Gen: Use strict map rather than lazy map in loop analysis We were ending up with a big 1GB thunk spike as the `fmap` operation did not force the key values promptly. This fixes the high maximum memory consumption when compiling the mmark package. Compilation is still slow and allocates a lot more than previous releases. Related to #19471 - - - - - 44e7120d by Matthew Pickering at 2021-09-17T09:44:53-04:00 Code Gen: Replace another lazy fmap with strict mapMap - - - - - b041ea77 by Matthew Pickering at 2021-09-17T09:44:53-04:00 Code Gen: Optimise successors calculation in loop calculation Before this change, the whole map would be traversed in order to delete a node from the graph before calculating successors. This is quite inefficient if the CFG is big, as was the case in the mmark package. A more efficient alternative is to leave the CFG untouched and then just delete the node once after the lookups have been performed. Ticket: #19471 - - - - - 53dc8e41 by Matthew Pickering at 2021-09-17T09:44:53-04:00 Code Gen: Use more efficient block merging algorithm The previous algorithm scaled poorly when there was a large number of blocks and edges. The algorithm links together block chains which have edges between them in the CFG. The new algorithm uses a union find data structure in order to efficiently merge together blocks and calculate which block chain each block id belonds to. I copied the UnionFind data structure which already existed in Cabal into the GHC library rathert than reimplement it myself. This change results in a very significant reduction in allocations when compiling the mmark package. Ticket: #19471 - - - - - c480f8f2 by Matthew Pickering at 2021-09-17T09:44:53-04:00 Code Gen: Rewrite shortcutWeightMap more efficiently This function was one of the main sources of allocation in a ticky profile due to how it repeatedly deleted nodes from a large map. Now firstly the cuts are normalised, so that chains of cuts are elimated before any rewrites are applied. Then the CFG is traversed and reconstructed once whilst applying the necessary rewrites to remove shortcutted edges (based on the normalised cuts). Ticket: #19471 - - - - - da60e627 by Sylvain Henry at 2021-09-17T09:45:36-04:00 Fix annoying warning about Data.List unqualified import - - - - - c662ac7e by Sylvain Henry at 2021-09-17T09:45:36-04:00 Refactor module dependencies code * moved deps related code into GHC.Unit.Module.Deps * refactored Deps module to not export Dependencies constructor to help maintaining invariants - - - - - f6a69fb8 by Sylvain Henry at 2021-09-17T09:45:36-04:00 Use an ADT for RecompReason - - - - - d41cfdd4 by Sylvain Henry at 2021-09-17T09:46:15-04:00 Constant folding for ctz/clz/popCnt (#20376) - - - - - 20e6fec8 by Matthew Pickering at 2021-09-17T09:46:51-04:00 Testsuite: Mark T12903 as fragile on i386 Closes #20377 - - - - - 7bc16521 by David Feuer at 2021-09-18T12:01:10-04:00 Add more instances for Solo Oleg Grenrus pointed out that `Solo` was missing `Eq`, `Ord`, `Bounded`, `Enum`, and `Ix` instances, which were all apparently available for the `OneTuple` type (in the `OneTuple` package). Though only the first three really seem useful, there's no reason not to take them all. For `Ix`, `Solo` naturally fills a gap between `()` and `(,)`. - - - - - 4d245e54 by Sebastian Graf at 2021-09-18T12:01:44-04:00 WorkWrap: Update Note [Wrapper activation] (#15056) The last point of the Conclusion was wrong; we inline functions without pragmas after the initial phase. It also appears that #15056 was fixed, as there already is a test T15056 which properly does foldr/build fusion for the reproducer. I made sure that T15056's `foo` is just large enough for WW to happen (which it wasn't), but for the worker to be small enough to inline into `blam`. Fixes #15056. - - - - - 2c28919f by Sebastian Graf at 2021-09-18T12:01:44-04:00 CoreUtils: Make exprIsHNF return True for unlifted variables (#20140) Clearly, evaluating an unlifted variable will never perform any work. Fixes #20140. - - - - - e17a37df by Joaquin "Florius" Azcarate at 2021-09-18T12:02:21-04:00 Fix formatting of link in base/Type.Reflection - - - - - 78d27dd8 by Matthew Pickering at 2021-09-18T12:02:56-04:00 docs: Fix examples for (un)escapeArgs The examples were just missing the surrounding brackets. ghci> escapeArgs ["hello \"world\""] "hello\\ \\\"world\\\"\n" Fixes #20340 - - - - - 1350c220 by Matthew Pickering at 2021-09-18T12:03:31-04:00 deriving: Always use module prefix in dataTypeName This fixes a long standard bug where the module prefix was omitted from the data type name supplied by Data.Typeable instances. Instead of reusing the Outputable instance for TyCon, we now take matters into our own hands and explicitly print the module followed by the type constructor name. Fixes #20371 - - - - - 446ca8b9 by Ben Gamari at 2021-09-18T12:04:06-04:00 users-guide: Improve documentation of ticky events - - - - - d99fc250 by Matthew Pickering at 2021-09-18T12:04:41-04:00 hadrian: Disable verbose timing information Before the output contain a lot of verbose information about timining various things to do with shake which wasn't so useful for developers. ``` shakeArgsWith 0.000s 0% Function shake 0.010s 0% Database read 0.323s 12% === With database 0.031s 1% Running rules 2.301s 86% ========================= Pool finished (1786 threads, 5 max) 0.003s 0% Cleanup 0.000s 0% Total 2.669s 100% Build completed in 2.67s ``` Now the output just contains the last line ``` Build completed in 2.67s ``` Ticket #20381 - - - - - 104bf6bf by Oleg Grenrus at 2021-09-22T08:23:08-04:00 Clarify that malloc, free etc. are the ones from stdlib.h - - - - - bb37026e by Aaron Allen at 2021-09-22T08:23:45-04:00 Convert Diagnostics in GHC.Tc.Gen.* (Part 2) Converts diagnostics in: (#20116) - GHC.Tc.Gen.Default - GHC.Tc.Gen.Export - - - - - 92257abd by Sylvain Henry at 2021-09-22T08:24:23-04:00 Link with libm dynamically (#19877) The compiler should be independent of the target. - - - - - b47fafd9 by alirezaghey at 2021-09-22T08:25:00-04:00 Fix minor inconsistency in documentation fixes #20388 - - - - - 3d328eb5 by Benjamin Maurer at 2021-09-22T08:25:37-04:00 Remove unused, undocumented debug/dump flag `-ddump-vt-trace`. See 20403. - - - - - 65c837a3 by Matthew Pickering at 2021-09-23T10:44:19+01:00 Typo [skip ci] - - - - - 69b35afd by Sven Tennie at 2021-09-23T15:59:38-04:00 deriveConstants: Add hie.yaml - - - - - 022d9717 by Sven Tennie at 2021-09-23T15:59:38-04:00 base: Generalize newStablePtrPrimMVar Make it polymorphic in the type of the MVar's value. This simple generalization makes it usable for `MVar a` instead of only `MVar ()` values. - - - - - 6f7f5990 by Sven Tennie at 2021-09-23T15:59:38-04:00 Introduce stack snapshotting / cloning (#18741) Add `StackSnapshot#` primitive type that represents a cloned stack (StgStack). The cloning interface consists of two functions, that clone either the treads own stack (cloneMyStack) or another threads stack (cloneThreadStack). The stack snapshot is offline/cold, i.e. it isn't evaluated any further. This is useful for analyses as it prevents concurrent modifications. For technical details, please see Note [Stack Cloning]. Co-authored-by: Ben Gamari <bgamari.foss at gmail.com> Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 29717ecb by Sven Tennie at 2021-09-23T15:59:38-04:00 Use Info Table Provenances to decode cloned stack (#18163) Emit an Info Table Provenance Entry (IPE) for every stack represeted info table if -finfo-table-map is turned on. To decode a cloned stack, lookupIPE() is used. It provides a mapping between info tables and their source location. Please see these notes for details: - [Stacktraces from Info Table Provenance Entries (IPE based stack unwinding)] - [Mapping Info Tables to Source Positions] Metric Increase: T12545 - - - - - aafda13d by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: Drop redundant `cabal update`s `cabal update` is already implied by `ci.sh setup`. - - - - - ca88d91c by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: Consolidate handling of cabal cache Previously the cache persistence was implemented as various ad-hoc `cp` commands at the end of the individual CI scripts. Here we move all of this logic into `ci.sh`. - - - - - cbfc0e93 by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: Isolate build from HOME - - - - - 55112fbf by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: Move phase timing logic into ci.sh - - - - - be11120f by Ben Gamari at 2021-09-23T16:00:17-04:00 ci: More surgical use of nix in Darwin builds - - - - - f48d747d by Ben Gamari at 2021-09-23T16:00:17-04:00 configure: Move nm search logic to new file - - - - - ee7bdc5c by Ben Gamari at 2021-09-23T16:00:18-04:00 configure: Add check for whether CC supports --target - - - - - 68509e1c by Ben Gamari at 2021-09-23T16:00:18-04:00 ci: Add version to cache key - - - - - dae4a068 by Ben Gamari at 2021-09-23T16:00:18-04:00 gitlab-ci: Ensure that CABAL_DIR is a Windows path Otherwise cabal-install falls over. - - - - - 1c91e721 by Ben Gamari at 2021-09-23T16:00:18-04:00 gitlab-ci: Use correct CABAL executable - - - - - 8a6598c7 by Ben Gamari at 2021-09-23T16:00:18-04:00 Ensure that cabal update is invoked before building - - - - - d7ee5295 by Ben Gamari at 2021-09-23T16:00:18-04:00 gitlab-ci: bash fixes - - - - - 98a30147 by GHC GitLab CI at 2021-09-23T16:00:18-04:00 hadrian: Pass CFLAGS to gmp configure - - - - - 02827066 by Ben Gamari at 2021-09-23T16:00:18-04:00 configure: Fix copy/paste error Previously both the --with-system-libffi path and the non--with-system-libffi path set CabalUseSystemLibFFI=True. This was wrong. - - - - - 316ac68f by Ben Gamari at 2021-09-23T16:00:18-04:00 configure: Clarify meaning of CabalHaveLibffi Previously the meaning of this flag was unclear and as a result I suspect that CabalHaveLibffi could be incorrectly False. - - - - - 552b32f1 by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Pass CFLAGS to hsc2hs tests - - - - - 7e19cb1c by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Fix ipeMap ipeMap.c failed to #include <string.h> - - - - - c9a87dca by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Make unsigned_reloc_macho_x64 and section_alignment makefile_tests - - - - - b30f90c4 by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Don't use cc directly in section_alignment test - - - - - a940ba7f by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Fix gnu sed-ism The BSD sed implementation doesn't allow `sed -i COMMAND FILE`; one must rather use `sed -i -e COMMAND FILE`. - - - - - e78752df by Ben Gamari at 2021-09-23T16:00:18-04:00 rts: Ensure that headers don't refer to undefined __STDC_VERSION__ Previously the C/C++ language version check in STG could throw an undefined macro warning due to __STDC_VERSION__ when compiled with a C++ compiler. Fix this by defining __STDC_VERSION__==0 when compiling with a C++ compiler. Fixes #20394. - - - - - 6716a4bd by Ben Gamari at 2021-09-23T16:00:18-04:00 gitlab-ci: Unset MACOSX_DEPLOYMENT_TARGET in stage0 build Otherwise we may get warnings from the toolchain if the bootstrap compiler was built with a different deployment target. - - - - - ac378d3e by Ben Gamari at 2021-09-23T16:00:18-04:00 testsuite: Ensure that C++11 is used in T20199 Otherwise we are dependent upon the C++ compiler's default language. - - - - - 33eb4a4e by Sylvain Henry at 2021-09-23T16:01:00-04:00 Constant-folding for timesInt2# (#20374) - - - - - 4b7ba3ae by Ben Gamari at 2021-09-24T23:14:31-04:00 gitlab-ci: Don't rely on $HOME when pushing test metrics As of cbfc0e933660626c9f4eaf5480076b6fcd31dceb we set $HOME to a non-existent directory to ensure hermeticity. - - - - - 8127520e by Ben Gamari at 2021-09-27T16:06:04+00:00 gitlab-ci: Ensure that temporary home exists - - - - - 0da019be by Artyom Kuznetsov at 2021-09-28T01:51:48-04:00 Remove NoGhcTc usage from HsMatchContext NoGhcTc is removed from HsMatchContext. As a result of this, HsMatchContext GhcTc is now a valid type that has Id in it, instead of Name and tcMatchesFun now takes Id instead of Name. - - - - - e38facf8 by Matthew Pickering at 2021-09-28T01:52:23-04:00 driver: Fix Ctrl-C handling with -j1 Even in -j1 we now fork all the work into it's own thread so that Ctrl-C exceptions are thrown on the main thread, which is blocked waiting for the work thread to finish. The default exception handler then picks up Ctrl-C exception and the dangling thread is killed. Fixes #20292 - - - - - 45a674aa by Sylvain Henry at 2021-09-28T01:53:01-04:00 Add `-dsuppress-core-sizes` flag (#20342) This flag is used to remove the output of core stats per binding in Core dumps. - - - - - 1935c42f by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Reduce default verbosity This change reduces the default verbosity of error messages to omit the stack trace information from the printed output. For example, before all errors would have a long call trace: ``` Error when running Shake build system: at action, called at src/Rules.hs:39:19 in main:Rules at need, called at src/Rules.hs:61:5 in main:Rules * Depends on: _build/stage1/lib/package.conf.d/ghc-9.3.conf * Depends on: _build/stage1/compiler/build/libHSghc-9.3.a * Depends on: _build/stage1/compiler/build/GHC/Tc/Solver/Rewrite.o * Depends on: _build/stage1/compiler/build/GHC/Tc/Solver/Rewrite.o _build/stage1/compiler/build/GHC/Tc/Solver/Rewrite.hi at cmd', called at src/Builder.hs:330:23 in main:Builder at cmd, called at src/Builder.hs:432:8 in main:Builder * Raised the exception: ``` Which can be useful but it confusing for GHC rather than hadrian developers. Ticket #20386 - - - - - 219f7f50 by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Remove deprecated tracing functions - - - - - 28963690 by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Rework the verbosity levels Before we really only had two verbosity levels, normal and verbose. There are now three levels: Normal: Commands show stderr (no stdout) and minimal build failure messages. Verbose (-V): Commands also show stdout, build failure message contains callstack and additional information Diagnostic (-VV): Very verbose output showing all command lines and passing -v3 to cabal commands. -V is similar to the default verbosity from before (but a little more verbose) - - - - - 66c85e2e by Matthew Pickering at 2021-09-28T01:53:36-04:00 ci: Increase default verbosity level to `-V` (Verbose) Given the previous commit, `-V` allows us to see some useful information in CI (such as the call stack on failure) which normally people don't want to see. As a result the $VERBOSE variable now tweaks the diagnostic level one level higher (to Diagnostic), which produces a lot of output. - - - - - 58fea28e by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Update documentation for new verbosity options - - - - - 26f24aec by Matthew Pickering at 2021-09-28T01:53:36-04:00 hadrian: Update comments on verbosity handling - - - - - 62b4a89b by taylorfausak at 2021-09-28T09:57:37-04:00 Remove outdated note about pragma layout - - - - - 028abd5b by Benjamin Maurer at 2021-09-28T09:58:13-04:00 Documented yet undocumented dump flags #18641 - - - - - b8d98827 by Richard Eisenberg at 2021-09-29T09:40:14-04:00 Compare FunTys as if they were TyConApps. See Note [Equality on FunTys] in TyCoRep. Close #17675. Close #17655, about documentation improvements included in this patch. Close #19677, about a further mistake around FunTy. test cases: typecheck/should_compile/T19677 - - - - - be77a9e0 by Fabian Thorand at 2021-09-29T09:40:51-04:00 Remove special case for large objects in allocateForCompact allocateForCompact() is called when the current allocation for the compact region does not fit in the nursery. It previously had a special case for objects exceeding the large object threshold. In that case, it would allocate a new compact region block just for that object. That led to a lot of small blocks being allocated in compact regions with a larger default block size (`autoBlockW`). This commit removes this special case because having a lot of small compact region blocks contributes significantly to memory fragmentation. The removal should be valid because - a more generic case for allocating a new compact region block follows at the end of allocateForCompact(), and that one takes `autoBlockW` into account - the reason for allocating separate blocks for large objects in the main heap seems to be to avoid copying during GCs, but once inside the compact region, the object will never be copied anyway. Fixes #18757. A regression test T18757 was added. - - - - - cd603062 by Kirill Zaborsky at 2021-09-29T09:41:27-04:00 Fix comment typos - - - - - 162492ea by Alexander Kjeldaas at 2021-09-29T09:41:27-04:00 Document interaction between unsafe FFI and GC In the multi-threaded RTS this can lead to hard to debug performance issues. - - - - - 361da88a by Kamil Dworakowski at 2021-09-29T09:42:04-04:00 Add a regression test for #17912 - - - - - 5cc4bd57 by Benjamin Maurer at 2021-09-29T09:42:41-04:00 Rectifying COMMENT and `mkComment` across platforms to work with SDoc and exhibit similar behaviors. Issue 20400 - - - - - a2be9f34 by Ziyang Liu at 2021-09-29T09:43:19-04:00 Document that `eqType`/`coreView` do not look through type families This isn't clear from the existing doc. - - - - - c668fd2c by Andrea Condoluci at 2021-09-29T09:44:04-04:00 TH stage restriction check for constructors, selectors, and class methods Closes ticket #17820. - - - - - d46e34d0 by Andrea Condoluci at 2021-09-29T09:44:04-04:00 Add tests for T17820 - - - - - 770fcac8 by Ben Gamari at 2021-09-29T09:44:40-04:00 GHC: Drop dead packageDbModules It was already commented out and contained a reference to the non-deterministic nameEnvElts so let's just drop it. - - - - - 42492b76 by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Reimplement seqEltsUFM in terms of fold Rather than nonDetEltsUFM; this should eliminate some unnecessary list allocations. - - - - - 97ffd6d9 by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Rewrite all eltsUFM occurrences to nonDetEltsUFM And remove the former. - - - - - df8c5961 by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Fix name of GHC.Core.TyCon.Env.nameEnvElts Rename to nonDetTyConEnvElts. - - - - - 1f2ba67a by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Make nubAvails deterministic Surprisingly this previously didn't appear to introduce any visible non-determinism but it seems worth avoiding non-determinism here. - - - - - 7c90a180 by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Rename nameEnvElts -> nonDetNameEnvElts - - - - - 2e68d4fa by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: Use seqEltsNameEnv rather that nameEnvElts - - - - - f66eaefd by Ben Gamari at 2021-09-29T09:44:40-04:00 compiler: occEnvElts -> nonDetOccEnvElts - - - - - 594ee2f4 by Matthew Pickering at 2021-09-30T00:56:30-04:00 testsuite: Make cabal01 more robust to large environments Sebastian unfortunately wrote a very long commit message in !5667 which caused `xargs` to fail on windows because the environment was too big. Fortunately `xargs` and `rm` don't need anything from the environment so just run those commands in an empty environment (which is what env -i achieves). - - - - - c261f220 by Sebastian Graf at 2021-09-30T00:56:30-04:00 Nested CPR light unleashed (#18174) This patch enables worker/wrapper for nested constructed products, as described in `Note [Nested CPR]`. The machinery for expressing Nested CPR was already there, since !5054. Worker/wrapper is equipped to exploit Nested CPR annotations since !5338. CPR analysis already handles applications in batches since !5753. This patch just needs to flip a few more switches: 1. In `cprTransformDataConWork`, we need to look at the field expressions and their `CprType`s to see whether the evaluation of the expressions terminates quickly (= is in HNF) or if they are put in strict fields. If that is the case, then we retain their CPR info and may unbox nestedly later on. More details in `Note [Nested CPR]`. 2. Enable nested `ConCPR` signatures in `GHC.Types.Cpr`. 3. In the `asConCpr` call in `GHC.Core.Opt.WorkWrap.Utils`, pass CPR info of fields to the `Unbox`. 4. Instead of giving CPR signatures to DataCon workers and wrappers, we now have `cprTransformDataConWork` for workers and treat wrappers by analysing their unfolding. As a result, the code from GHC.Types.Id.Make went away completely. 5. I deactivated worker/wrappering for recursive DataCons and wrote a function `isRecDataCon` to detect them. We really don't want to give `repeat` or `replicate` the Nested CPR property. See Note [CPR for recursive data structures] for which kind of recursive DataCons we target. 6. Fix a couple of tests and their outputs. I also documented that CPR can destroy sharing and lead to asymptotic increase in allocations (which is tracked by #13331/#19326) in `Note [CPR for data structures can destroy sharing]`. Nofib results: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- ben-raytrace -3.1% -0.4% binary-trees +0.8% -2.9% digits-of-e2 +5.8% +1.2% event +0.8% -2.1% fannkuch-redux +0.0% -1.4% fish 0.0% -1.5% gamteb -1.4% -0.3% mkhprog +1.4% +0.8% multiplier +0.0% -1.9% pic -0.6% -0.1% reptile -20.9% -17.8% wave4main +4.8% +0.4% x2n1 -100.0% -7.6% -------------------------------------------------------------------------------- Min -95.0% -17.8% Max +5.8% +1.2% Geometric Mean -2.9% -0.4% ``` The huge wins in x2n1 (loopy list) and reptile (see #19970) are due to refraining from unboxing (:). Other benchmarks like digits-of-e2 or wave4main regress because of that. Ultimately there are no great improvements due to Nested CPR alone, but at least it's a win. Binary sizes decrease by 0.6%. There are a significant number of metric decreases. The most notable ones (>1%): ``` ManyAlternatives(normal) ghc/alloc 771656002.7 762187472.0 -1.2% ManyConstructors(normal) ghc/alloc 4191073418.7 4114369216.0 -1.8% MultiLayerModules(normal) ghc/alloc 3095678333.3 3128720704.0 +1.1% PmSeriesG(normal) ghc/alloc 50096429.3 51495664.0 +2.8% PmSeriesS(normal) ghc/alloc 63512989.3 64681600.0 +1.8% PmSeriesV(normal) ghc/alloc 62575424.0 63767208.0 +1.9% T10547(normal) ghc/alloc 29347469.3 29944240.0 +2.0% T11303b(normal) ghc/alloc 46018752.0 47367576.0 +2.9% T12150(optasm) ghc/alloc 81660890.7 82547696.0 +1.1% T12234(optasm) ghc/alloc 59451253.3 60357952.0 +1.5% T12545(normal) ghc/alloc 1705216250.7 1751278952.0 +2.7% T12707(normal) ghc/alloc 981000472.0 968489800.0 -1.3% GOOD T13056(optasm) ghc/alloc 389322664.0 372495160.0 -4.3% GOOD T13253(normal) ghc/alloc 337174229.3 341954576.0 +1.4% T13701(normal) ghc/alloc 2381455173.3 2439790328.0 +2.4% BAD T14052(ghci) ghc/alloc 2162530642.7 2139108784.0 -1.1% T14683(normal) ghc/alloc 3049744728.0 2977535064.0 -2.4% GOOD T14697(normal) ghc/alloc 362980213.3 369304512.0 +1.7% T15164(normal) ghc/alloc 1323102752.0 1307480600.0 -1.2% T15304(normal) ghc/alloc 1304607429.3 1291024568.0 -1.0% T16190(normal) ghc/alloc 281450410.7 284878048.0 +1.2% T16577(normal) ghc/alloc 7984960789.3 7811668768.0 -2.2% GOOD T17516(normal) ghc/alloc 1171051192.0 1153649664.0 -1.5% T17836(normal) ghc/alloc 1115569746.7 1098197592.0 -1.6% T17836b(normal) ghc/alloc 54322597.3 55518216.0 +2.2% T17977(normal) ghc/alloc 47071754.7 48403408.0 +2.8% T17977b(normal) ghc/alloc 42579133.3 43977392.0 +3.3% T18923(normal) ghc/alloc 71764237.3 72566240.0 +1.1% T1969(normal) ghc/alloc 784821002.7 773971776.0 -1.4% GOOD T3294(normal) ghc/alloc 1634913973.3 1614323584.0 -1.3% GOOD T4801(normal) ghc/alloc 295619648.0 292776440.0 -1.0% T5321FD(normal) ghc/alloc 278827858.7 276067280.0 -1.0% T5631(normal) ghc/alloc 586618202.7 577579960.0 -1.5% T5642(normal) ghc/alloc 494923048.0 487927208.0 -1.4% T5837(normal) ghc/alloc 37758061.3 39261608.0 +4.0% T9020(optasm) ghc/alloc 257362077.3 254672416.0 -1.0% T9198(normal) ghc/alloc 49313365.3 50603936.0 +2.6% BAD T9233(normal) ghc/alloc 704944258.7 685692712.0 -2.7% GOOD T9630(normal) ghc/alloc 1476621560.0 1455192784.0 -1.5% T9675(optasm) ghc/alloc 443183173.3 433859696.0 -2.1% GOOD T9872a(normal) ghc/alloc 1720926653.3 1693190072.0 -1.6% GOOD T9872b(normal) ghc/alloc 2185618061.3 2162277568.0 -1.1% GOOD T9872c(normal) ghc/alloc 1765842405.3 1733618088.0 -1.8% GOOD TcPlugin_RewritePerf(normal) ghc/alloc 2388882730.7 2365504696.0 -1.0% WWRec(normal) ghc/alloc 607073186.7 597512216.0 -1.6% T9203(normal) run/alloc 107284064.0 102881832.0 -4.1% haddock.Cabal(normal) run/alloc 24025329589.3 23768382560.0 -1.1% haddock.base(normal) run/alloc 25660521653.3 25370321824.0 -1.1% haddock.compiler(normal) run/alloc 74064171706.7 73358712280.0 -1.0% ``` The biggest exception to the rule is T13701 which seems to fluctuate as usual (not unlike T12545). T14697 has a similar quality, being a generated multi-module test. T5837 is small enough that it similarly doesn't measure anything significant besides module loading overhead. T13253 simply does one additional round of Simplification due to Nested CPR. There are also some apparent regressions in T9198, T12234 and PmSeriesG that we (@mpickering and I) were simply unable to reproduce locally. @mpickering tried to run the CI script in a local Docker container and actually found that T9198 and PmSeriesG *improved*. In MRs that were rebased on top this one, like !4229, I did not experience such increases. Let's not get hung up on these regression tests, they were meant to test for asymptotic regressions. The build-cabal test improves by 1.2% in -O0. Metric Increase: T10421 T12234 T12545 T13035 T13056 T13701 T14697 T18923 T5837 T9198 Metric Decrease: ManyConstructors T12545 T12707 T13056 T14683 T16577 T18223 T1969 T3294 T9203 T9233 T9675 T9872a T9872b T9872c T9961 TcPlugin_RewritePerf - - - - - 205f0f92 by Andrea Condoluci at 2021-09-30T00:57:09-04:00 Trees That Grow refactor for HsTick and HsBinTick Move HsTick and HsBinTick to XExpr, the extension tree of HsExpr. Part of #16830 . - - - - - e0923b98 by Ben Gamari at 2021-09-30T00:57:44-04:00 ghc-boot: Eliminate unnecessary use of getEnvironment Previously we were using `System.Environment.getEnvironment`, which decodes all environment variables into Haskell `String`s, where a simple environment lookup would do. This made the compiler's allocations unnecessarily dependent on the environment. Fixes #20431. - - - - - 941d3792 by Sylvain Henry at 2021-09-30T19:41:09-04:00 Rules for sized conversion primops (#19769) Metric Decrease: T12545 - - - - - adc41a77 by Matthew Pickering at 2021-09-30T19:41:44-04:00 driver: Fix -E -XCPP, copy output from CPP ouput rather than .hs output Fixes #20416 I thought about adding a test for this case but I struggled to think of something robust. Grepping -v3 will include different paths on different systems and the structure of the result file depends on which preprocessor you are using. - - - - - 94f3ce7e by Matthew Pickering at 2021-09-30T19:42:19-04:00 Recompilation: Handle -plugin-package correctly If a plugins was specified using the -plugin-package-(id) flag then the module it applied to was always recompiled. The recompilation checker was previously using `findImportedModule`, which looked for packages in the HPT and then in the package database but only for modules specified using `-package`. The correct lookup function for plugins is `findPluginModule`, therefore we check normal imports with `findImportedModule` and plugins with `findPluginModule`. Fixes #20417 - - - - - ef92a009 by Andreas Klebinger at 2021-09-30T19:42:54-04:00 NCG: Linear-reg-alloc: A few small implemenation tweaks. Removed an intermediate list via a fold. realRegsAlias: Manually inlined the list functions to get better code. Linear.hs added a bang somewhere. - - - - - 9606774d by Aaron Allen at 2021-10-01T09:04:10-04:00 Convert Diagnostics GHC.Tc.Gen.* (Part 3) Converts all diagnostics in the `GHC.Tc.Gen.Expr` module. (#20116) - - - - - 9600a5fb by Matthew Pickering at 2021-10-01T09:04:46-04:00 code gen: Improve efficiency of findPrefRealReg Old strategy: For each variable linearly scan through all the blocks and check to see if the variable is any of the block register mappings. This is very slow when you have a lot of blocks. New strategy: Maintain a map from virtual registers to the first real register the virtual register was assigned to. Consult this map in findPrefRealReg. The map is updated when the register mapping is updated and is hidden behind the BlockAssigment abstraction. On the mmark package this reduces compilation time from about 44s to 32s. Ticket: #19471 - - - - - e3701815 by Matthew Pickering at 2021-10-01T09:05:20-04:00 ci: Unset CI_* variables before run_hadrian and test_make The goal here is to somewhat sanitize the environment so that performance tests don't fluctuate as much as they have been doing. In particular the length of the commit message was causing benchmarks to increase because gitlab stored the whole commit message twice in environment variables. Therefore when we used `getEnvironment` it would cause more allocation because more string would be created. See #20431 ------------------------- Metric Decrease: T10421 T13035 T18140 T18923 T9198 T12234 T12425 ------------------------- - - - - - e401274a by Ben Gamari at 2021-10-02T05:18:03-04:00 gitlab-ci: Bump docker images To install libncurses-dev on Debian targets. - - - - - 42f49c4e by Ben Gamari at 2021-10-02T05:18:03-04:00 Bump terminfo submodule to 0.4.1.5 Closes #20307. - - - - - cb862ecf by Andreas Schwab at 2021-10-02T05:18:40-04:00 CmmToLlvm: Sign/Zero extend parameters for foreign calls on RISC-V Like S390 and PPC64, RISC-V requires parameters for foreign calls to be extended to full words. - - - - - 0d455a18 by Richard Eisenberg at 2021-10-02T05:19:16-04:00 Use eqType, not tcEqType, in metavar kind check Close #20356. See addendum to Note [coreView vs tcView] in GHC.Core.Type for the details. Also killed old Note about metaTyVarUpdateOK, which has been gone for some time. test case: typecheck/should_fail/T20356 - - - - - 4264e74d by Ben Gamari at 2021-10-02T05:19:51-04:00 rts: Add missing write barriers in MVar wake-up paths Previously PerformPut failed to respect the non-moving collector's snapshot invariant, hiding references to an MVar and its new value by overwriting a stack frame without dirtying the stack. Fix this. PerformTake exhibited a similar bug, failing to dirty (and therefore mark) the blocked stack before mutating it. Closes #20399. - - - - - 040c347e by Ben Gamari at 2021-10-02T05:19:51-04:00 rts: Unify stack dirtiness check This fixes an inconsistency where one dirtiness check would not mask out the STACK_DIRTY flag, meaning it may also be affected by the STACK_SANE flag. - - - - - 4bdafb48 by Sylvain Henry at 2021-10-02T05:20:29-04:00 Add (++)/literal rule When we derive the Show instance of the big record in #16577, I get the following compilation times (with -O): Before: 0.91s After: 0.77s Metric Decrease: T19695 - - - - - 8b3d98ff by Sylvain Henry at 2021-10-02T05:21:07-04:00 Don't use FastString for UTF-8 encoding only - - - - - f4554f1d by Ben Gamari at 2021-10-03T14:23:36-04:00 ci: Use https:// transport and access token to push perf notes Previously we would push perf notes using a standard user and SSH key-based authentication. However, configuring SSH is unnecessarily fiddling. We now rather use HTTPS and a project access token. - - - - - 91cd1248 by Ben Gamari at 2021-10-03T14:23:45-04:00 ci/test-metrics: Clean up various bash quoting issues - - - - - ed0e29f1 by Ben Gamari at 2021-10-03T23:24:37-04:00 base: Update Unicode database to 14.0 Closes #20404. - - - - - e8693713 by Ben Gamari at 2021-10-03T23:25:11-04:00 configure: Fix redundant-argument warning from -no-pie check Modern clang versions are quite picky when it comes to reporting redundant arguments. In particular, they will warn when -no-pie is passed when no linking is necessary. Previously the configure script used a `$CC -Werror -no-pie -E` invocation to test whether `-no-pie` is necessary. Unfortunately, this meant that clang would throw a redundant argument warning, causing configure to conclude that `-no-pie` was not supported. We now rather use `$CC -Werror -no-pie`, ensuring that linking is necessary and avoiding this failure mode. Fixes #20463. - - - - - b3267fad by Sylvain Henry at 2021-10-04T08:28:23+00:00 Constant folding for negate (#20347) Only for small integral types for now. - - - - - 2308a130 by Vladislav Zavialov at 2021-10-04T18:44:07-04:00 Clean up HiePass constraints - - - - - 40c81dd2 by Matthew Pickering at 2021-10-04T23:45:11-04:00 ci: Run hadrian builds verbosely, but not tests This reduces the output from the testsuite to a more manageable level. Fixes #20432 - - - - - 347537a5 by Ben Gamari at 2021-10-04T23:45:46-04:00 compiler: Improve Haddocks of atomic MachOps - - - - - a0f44ceb by Ben Gamari at 2021-10-04T23:45:46-04:00 compiler: Fix racy ticker counter registration Previously registration of ticky entry counters was racy, performing a read-modify-write to add the new counter to the ticky_entry_ctrs list. This could result in the list becoming cyclic if multiple threads entered the same closure simultaneously. Fixes #20451. - - - - - a7629334 by Vladislav Zavialov at 2021-10-04T23:46:21-04:00 Bespoke TokenLocation data type The EpaAnnCO we were using contained an Anchor instead of EpaLocation, making it harder to work with. At the same time, using EpaLocation by itself isn't possible either, as we may have tokens without location information. Hence the new data type: data TokenLocation = NoTokenLoc | TokenLoc !EpaLocation - - - - - a14d0e63 by sheaf at 2021-10-04T23:46:58-04:00 Bump TcLevel of failing kind equality implication Not bumping the TcLevel meant that we could end up trying to add evidence terms for the implication constraint created to wrap failing kind equalities (to avoid their deferral). fixes #20043 - - - - - 48b0f17a by sheaf at 2021-10-04T23:47:35-04:00 Add a regression test for #17723 The underlying bug was fixed by b8d98827, see MR !2477 - - - - - 5601b9e2 by Matthías Páll Gissurarson at 2021-10-05T03:18:39-04:00 Speed up valid hole-fits by adding early abort and checks. By adding an early abort flag in `TcSEnv`, we can fail fast in the presence of insoluble constraints. This helps us avoid a lot of work in valid hole-fits, and we geta massive speed-up by avoiding a lot of useless work solving constraints that never come into play. Additionally, we add a simple check for degenerate hole types, such as when the type of the hole is an immutable type variable (as is the case when the hole is completely unconstrained). Then the only valid fits are the locals, so we can ignore the global candidates. This fixes #16875 - - - - - 298df16d by Krzysztof Gogolewski at 2021-10-05T03:19:14-04:00 Reject type family equation with wrong name (#20260) We should reject "type family Foo where Bar = ()". This check was done in kcTyFamInstEqn but not in tcTyFamInstEqn. I factored out arity checking, which was duplicated. - - - - - 643b6f01 by Sebastian Graf at 2021-10-05T14:32:51-04:00 WorkWrap: Nuke CPR signatures of join points (#18824) In #18824 we saw that the Simplifier didn't nuke a CPR signature of a join point when it pushed a continuation into it when it better should have. But join points are local, mostly non-exported bindings. We don't use their CPR signature anyway and would discard it at the end of the Core pipeline. Their main purpose is to propagate CPR info during CPR analysis and by the time worker/wrapper runs the signature will have served its purpose. So we zap it! Fixes #18824. - - - - - b4c0cc36 by Sebastian Graf at 2021-10-05T14:32:51-04:00 Simplifier: Get rid of demand zapping based on Note [Arity decrease] The examples in the Note were inaccurate (`$s$dm` has arity 1 and that seems OK) and the code didn't actually nuke the demand *signature* anyway. Specialise has to nuke it, but it starts from a clean IdInfo anyway (in `newSpecIdM`). So I just deleted the code. Fixes #20450. - - - - - cd1b016f by Sebastian Graf at 2021-10-05T14:32:51-04:00 CprAnal: Activate Sum CPR for local bindings We've had Sum CPR (#5075) for top-level bindings for a couple of years now. That begs the question why we didn't also activate it for local bindings, and the reasons for that are described in `Note [CPR for sum types]`. Only that it didn't make sense! The Note said that Sum CPR would destroy let-no-escapes, but that should be a non-issue since we have syntactic join points in Core now and we don't WW for them (`Note [Don't w/w join points for CPR]`). So I simply activated CPR for all bindings of sum type, thus fixing #5075 and \#16570. NoFib approves: ``` -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- comp_lab_zift -0.0% +0.7% fluid +1.7% +0.7% reptile +0.1% +0.1% -------------------------------------------------------------------------------- Min -0.0% -0.2% Max +1.7% +0.7% Geometric Mean +0.0% +0.0% ``` There were quite a few metric decreases on the order of 1-4%, but T6048 seems to regress significantly, by 26.1%. WW'ing for a `Just` constructor and the nested data type meant additional Simplifier iterations and a 30% increase in term sizes as well as a 200-300% in type sizes due to unboxed 9-tuples. There's not much we can do about it, I'm afraid: We're just doing much more work there. Metric Decrease: T12425 T18698a T18698b T20049 T9020 WWRec Metric Increase: T6048 - - - - - 000f2a30 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Address some Foldable documentation nits - Add link to laws from the class head - Simplify wording of left/right associativity intro paragraph - Avoid needless mention of "endomorphisms" - - - - - 7059a729 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Add laws link and tweak Traversable class text - - - - - 43358ab9 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Note linear `elem` cost This is a writeup of the state of play for better than linear `elem` via a helper type class. - - - - - 56899c8d by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Note elem ticket 20421 - - - - - fb6b772f by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Minor wording tweaks/fixes - - - - - f49c7012 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Adopt David Feuer's explantion of foldl' via foldr - - - - - 5282eaa1 by Viktor Dukhovni at 2021-10-05T14:33:29-04:00 Explain Endo, Dual, ... in laws - - - - - f52df067 by Alfredo Di Napoli at 2021-10-05T14:34:04-04:00 Make GHC.Utils.Error.Validity type polymorphic This commit makes the `Validity` type polymorphic: ``` data Validity' a = IsValid -- ^ Everything is fine | NotValid a -- ^ A problem, and some indication of why -- | Monomorphic version of @Validity'@ specialised for 'SDoc's. type Validity = Validity' SDoc ``` The type has been (provisionally) renamed to Validity' to not break existing code, as the monomorphic `Validity` type is quite pervasive in a lot of signatures in GHC. Why having a polymorphic Validity? Because it carries the evidence of "what went wrong", but the old type carried an `SDoc`, which clashed with the new GHC diagnostic infrastructure (#18516). Having it polymorphic it means we can carry an arbitrary, richer diagnostic type, and this is very important for things like the `checkOriginativeSideConditions` function, which needs to report the actual diagnostic error back to `GHC.Tc.Deriv`. It also generalises Validity-related functions to be polymorphic in @a at . - - - - - ac275f42 by Alfredo Di Napoli at 2021-10-05T14:34:04-04:00 Eradicate TcRnUnknownMessage from GHC.Tc.Deriv This (big) commit finishes porting the GHC.Tc.Deriv module to support the new diagnostic infrastructure (#18516) by getting rid of the legacy calls to `TcRnUnknownMessage`. This work ended up being quite pervasive and touched not only the Tc.Deriv module but also the Tc.Deriv.Utils and Tc.Deriv.Generics module, which needed to be adapted to use the new infrastructure. This also required generalising `Validity`. More specifically, this is a breakdown of the work done: * Add and use the TcRnUselessTypeable data constructor * Add and use TcRnDerivingDefaults data constructor * Add and use the TcRnNonUnaryTypeclassConstraint data constructor * Add and use TcRnPartialTypeSignatures * Add T13324_compile2 test to test another part of the TcRnPartialTypeSignatures diagnostic * Add and use TcRnCannotDeriveInstance data constructor, which introduces a new data constructor to TcRnMessage called TcRnCannotDeriveInstance, which is further sub-divided to carry a `DeriveInstanceErrReason` which explains the reason why we couldn't derive a typeclass instance. * Add DerivErrSafeHaskellGenericInst data constructor to DeriveInstanceErrReason * Add DerivErrDerivingViaWrongKind and DerivErrNoEtaReduce * Introduce the SuggestExtensionInOrderTo Hint, which adds (and use) a new constructor to the hint type `LanguageExtensionHint` called `SuggestExtensionInOrderTo`, which can be used to give a bit more "firm" recommendations when it's obvious what the required extension is, like in the case for the `DerivingStrategies`, which automatically follows from having enabled both `DeriveAnyClass` and `GeneralizedNewtypeDeriving`. * Wildcard-free pattern matching in mk_eqn_stock, which removes `_` in favour of pattern matching explicitly on `CanDeriveAnyClass` and `NonDerivableClass`, because that determine whether or not we can suggest to the user `DeriveAnyClass` or not. - - - - - 52400ebb by Simon Peyton Jones at 2021-10-05T14:34:39-04:00 Ensure top-level binders in scope in SetLevels Ticket #20200 (the Agda failure) showed another case in which lookupIdSubst would fail to find a local Id in the InScopeSet. This time it was because SetLevels was given a program in which the top-level bindings were not in dependency order. The Simplifier (see Note [Glomming] in GHC.Core.Opt.Occuranal) and the specialiser (see Note [Top level scope] in GHC.Core.Opt.Specialise) may both produce top-level bindings where an early binding refers to a later one. One solution would be to run the occurrence analyser again to put them all in the right order. But a simpler one is to make SetLevels OK with this input by bringing all top-level binders into scope at the start. That's what this patch does. - - - - - 11240b74 by Sylvain Henry at 2021-10-05T14:35:17-04:00 Constant folding for (.&.) maxBound (#20448) - - - - - 29ee04f3 by Zubin Duggal at 2021-10-05T14:35:52-04:00 docs: Clarify documentation of `getFileSystemEncoding` (#20344) It may not always be a Unicode encoding - - - - - 435ff398 by Mann mit Hut at 2021-10-06T00:11:07-04:00 Corrected types of thread ids obtained from the RTS While the thread ids had been changed to 64 bit words in e57b7cc6d8b1222e0939d19c265b51d2c3c2b4c0 the return type of the foreign import function used to retrieve these ids - namely 'GHC.Conc.Sync.getThreadId' - was never updated accordingly. In order to fix that this function returns now a 'CUULong'. In addition to that the types used in the thread labeling subsystem were adjusted as well and several format strings were modified throughout the whole RTS to display thread ids in a consistent and correct way. Fixes #16761 - - - - - 89e98bdf by Alan Zimmerman at 2021-10-06T00:11:42-04:00 EPA: Remove duplicate AnnOpenP/AnnCloseP in DataDecl The parens EPAs were added in the tyvars where they belong, but also at the top level of the declaration. Closes #20452 - - - - - fc4c7ffb by Ryan Scott at 2021-10-06T00:12:17-04:00 Remove the Maybe in primRepName's type There's no need for this `Maybe`, as it will always be instantiated to `Just` in practice. Fixes #20482. - - - - - 4e91839a by sheaf at 2021-10-06T00:12:54-04:00 Add a regression test for #13233 This test fails on GHC 8.0.1, only when profiling is enabled, with the error: ghc: panic! (the 'impossible' happened) kindPrimRep.go a_12 This was fixed by commit b460d6c9. - - - - - 7fc986e1 by Sebastian Graf at 2021-10-06T00:13:29-04:00 CprAnal: Two regression tests For #16040 and #2387. - - - - - 9af29e7f by Matthew Pickering at 2021-10-06T10:57:24-04:00 Disable -dynamic-too if -dynamic is also passed Before if you passed both options then you would generate two identical hi/dyn_hi and o/dyn_o files, both in the dynamic way. It's better to warn this is happening rather than duplicating the work and causing potential confusion. -dynamic-too should only be used with -static. Fixes #20436 - - - - - a466b024 by sheaf at 2021-10-06T10:58:03-04:00 Improve overlap error for polykinded constraints There were two problems around `mkDictErr`: 1. An outdated call to `flattenTys` meant that we missed out on some instances. As we no longer flatten type-family applications, the logic is obsolete and can be removed. 2. We reported "out of scope" errors in a poly-kinded situation because `BoxedRep` and `Lifted` were considered out of scope. We fix this by using `pretendNameIsInScope`. fixes #20465 - - - - - b041fc6e by Ben Gamari at 2021-10-07T03:40:49-04:00 hadrian: Generate ghcii.sh in binary distributions Technically we should probably generate this in the in-place build tree as well, but I am not bothering to do so here as ghcii.sh will be removed in 9.4 when WinIO becomes the default anyways (see #12720). Fixes #19339. - - - - - 75a766a3 by Ben Gamari at 2021-10-07T03:40:49-04:00 hadrian: Fix incorrect ticket reference This was supposed to refer to #20253. - - - - - 62157287 by Teo Camarasu at 2021-10-07T03:41:27-04:00 fix non-moving gc heap space requirements estimate The space requirements of the non-moving gc are comparable to the compacting gc, not the copying gc. The copying gc requires a much larger overhead. Fixes #20475 - - - - - e82c8dd2 by Joachim Breitner at 2021-10-07T03:42:01-04:00 Fix rst syntax mistakes in release notes - - - - - 358f6222 by Benjamin Maurer at 2021-10-07T03:42:36-04:00 Removed left-over comment from `nonDetEltsUFM`-removal in `seqEltsUFM`. - - - - - 0cf23263 by Alan Zimmerman at 2021-10-07T03:43:11-04:00 EPA: Add comments to EpaDelta The EpaDelta variant of EpaLocation cannot be sorted by location. So we capture any comments that need to be printed between the prior output and this location, when creating an EpaDelta offset in ghc-exactprint. And make the EpaLocation fields strict. - - - - - e1d02fb0 by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: allow naturalEq#/Ne# to inline (#20361) We now perform constant folding on bigNatEq# instead. - - - - - 44886aab by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: allow inlining of naturalEq/Ne/Gt/Lt/Ge/Le/Compare (#20361) Perform constant folding on bigNatCompare instead. Some functions of the Enum class for Natural now need to be inlined explicitly to be specialized at call sites (because `x > lim` for Natural is inlined and the resulting function is a little too big to inline). If we don't do this, T17499 runtime allocations regresses by 16%. - - - - - 3a5a5c85 by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: allow naturalToWordClamp/Negate/Signum to inline (#20361) We don't need built-in rules now that bignum literals (e.g. 123 :: Natural) match with their constructors (e.g. NS 123##). - - - - - 714568bb by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: remove outdated comment - - - - - 4d44058d by Sylvain Henry at 2021-10-07T20:20:01-04:00 Bignum: transfer NOINLINE from Natural to BigNat - - - - - 01f5324f by Joachim Breitner at 2021-10-07T20:20:36-04:00 Recover test case for T11547 commit 98c7749 has reverted commit 59d7ee53, including the test that that file added. That test case is still valuable, so I am re-adding it. I add it with it’s current (broken) behavior so that whoever fixes it intentionally or accidentially will notice and then commit the actual desired behavior (which is kinda unspecified, see https://gitlab.haskell.org/ghc/ghc/-/issues/20455#note_382030) - - - - - 3d31f11e by Sylvain Henry at 2021-10-08T13:08:16-04:00 Don't link plugins' units with target code (#20218) Before this patch, plugin units were linked with the target code even when the unit was passed via `-plugin-package`. This is an issue to support plugins in cross-compilers (plugins are definitely not ABI compatible with target code). We now clearly separate unit dependencies for plugins and unit dependencies for target code and only link the latter ones. We've also added a test to ensure that plugin units passed via `-package` are linked with target code so that `thNameToGhcName` can still be used in plugins that need it (see T20218b). - - - - - 75aea732 by Joachim Breitner at 2021-10-08T13:08:51-04:00 New test case: Variant of T14052 with data type definitions previous attempts at fixing #11547 and #20455 were reverted because they showed some quadratic behaviour, and the test case T15052 was added to catch that. I believe that similar quadratic behavor can be triggered with current master, by using type definitions rather than value definitions, so this adds a test case similar to T14052. I have hopes that my attempts at fixing #11547 will lead to code that avoid the quadratic increase here. Or not, we will see. In any case, having this in `master` and included in future comparisons will be useful. - - - - - 374a718e by Teo Camarasu at 2021-10-08T18:09:56-04:00 Fix nonmoving gen label in gc stats report The current code assumes the non-moving generation is always generation 1, but this isn't the case if the amount of generations is greater than 2 Fixes #20461 - - - - - a37275a3 by Matthew Pickering at 2021-10-08T18:10:31-04:00 ci: Remove BROKEN_TESTS for x86 darwin builds The tests Capi_Ctype_001 Capi_Ctype_002 T12010 pass regularly on CI so let's mark them unbroken and hopefully then we can fix #20013. - - - - - e6838872 by Matthew Pickering at 2021-10-08T18:10:31-04:00 ci: Expect x86-darwin to pass Closes #20013 - - - - - 1f160cd9 by Matthew Pickering at 2021-10-08T18:10:31-04:00 Normalise output of T20199 test - - - - - 816d2561 by CarrieMY at 2021-10-08T18:11:08-04:00 Fix -E -fno-code undesirable interactions #20439 - - - - - 55a6377a by Matthew Pickering at 2021-10-08T18:11:43-04:00 code gen: Disable dead code elimination when -finfo-table-map is enabled It's important that when -finfo-table-map is enabled that we generate IPE entries just for those info tables which are actually used. To this end, the info tables which are used are collected just before code generation starts and entries only created for those tables. Not accounted for in this scheme was the dead code elimination in the native code generator. When compiling GHC this optimisation removed an info table which had an IPE entry which resulting in the following kind of linker error: ``` /home/matt/ghc-with-debug/_build/stage1/lib/../lib/x86_64-linux-ghc-9.3.20210928/libHSCabal-3.5.0.0-ghc9.3.20210928.so: error: undefined reference to '.Lc5sS_info' /home/matt/ghc-with-debug/_build/stage1/lib/../lib/x86_64-linux-ghc-9.3.20210928/libHSCabal-3.5.0.0-ghc9.3.20210928.so: error: undefined reference to '.Lc5sH_info' /home/matt/ghc-with-debug/_build/stage1/lib/../lib/x86_64-linux-ghc-9.3.20210928/libHSCabal-3.5.0.0-ghc9.3.20210928.so: error: undefined reference to '.Lc5sm_info' collect2: error: ld returned 1 exit status `cc' failed in phase `Linker'. (Exit code: 1) Development.Shake.cmd, system command failed ``` Unfortunately, by the time this optimisation happens the structure of the CmmInfoTable has been lost, we only have the generated code for the info table to play with so we can no longer just collect all the used info tables and generate the IPE map. This leaves us with two options: 1. Return a list of the names of the discarded info tables and then remove them from the map. This is awkward because we need to do code generation for the map as well. 2. Just disable this small code size optimisation when -finfo-table-map is enabled. The option produces very big object files anyway. Option 2 is much easier to implement and means we don't have to thread information around awkwardly. It's at the cost of slightly larger object files (as dead code is not eliminated). Disabling this optimisation allows an IPE build of GHC to complete successfully. Fixes #20428 - - - - - a76409c7 by Andrei Barbu at 2021-10-08T19:45:29-04:00 Add defaulting plugins. Like the built-in type defaulting rules these plugins can propose candidates to resolve ambiguous type variables. Machine learning and other large APIs like those for game engines introduce new numeric types and other complex typed APIs. The built-in defaulting mechanism isn't powerful enough to resolve ambiguous types in these cases forcing users to specify minutia that they might not even know how to do. There is an example defaulting plugin linked in the documentation. Applications include defaulting the device a computation executes on, if a gradient should be computed for a tensor, or the size of a tensor. See https://github.com/ghc-proposals/ghc-proposals/pull/396 for details. - - - - - 31983ab4 by sheaf at 2021-10-09T04:46:05-04:00 Reject GADT pattern matches in arrow notation Tickets #20469 and #20470 showed that the current implementation of arrows is not at all up to the task of supporting GADTs: GHC produces ill-scoped Core programs because it doesn't propagate the evidence introduced by a GADT pattern match. For the time being, we reject GADT pattern matches in arrow notation. Hopefully we are able to add proper support for GADTs in arrows in the future. - - - - - a356bd56 by Matthew Pickering at 2021-10-10T15:07:52+02:00 driver: Fix assertion failure on self-import Fixes #20459 - - - - - 245ab166 by Ben Gamari at 2021-10-10T17:55:10-04:00 hadrian: Include Cabal flags in verbose configure output - - - - - 9f9d6280 by Zejun Wu at 2021-10-12T01:39:53-04:00 Derive Eq instance for the HieTypeFix type We have `instance Eq a => Eq (HieType a)` already. This instance can be handy when we want to impement a function to find all `fromIntegral :: a -> a` using `case ty of { Roll (HFunTy _ a b) -> a == b; _ -> False }`. - - - - - 8d6de541 by Ben Gamari at 2021-10-12T01:40:29-04:00 nonmoving: Fix and factor out mark_trec_chunk We need to ensure that the TRecChunk itself is marked, in addition to the TRecs it contains. - - - - - aa520ba1 by Ben Gamari at 2021-10-12T01:40:29-04:00 rts/nonmoving: Rename mark_* to trace_* These functions really do no marking; they merely trace pointers. - - - - - 2c02ea8d by Ben Gamari at 2021-10-12T01:40:29-04:00 rts/primops: Fix write barrier in stg_atomicModifyMutVarzuzh Previously the call to dirty_MUT_VAR in stg_atomicModifyMutVarzuzh was missing its final argument. Fixes #20414. - - - - - 2e0c13ab by Ben Gamari at 2021-10-12T01:40:29-04:00 rts/nonmoving: Enable selector optimisation by default - - - - - 2c06720e by GHC GitLab CI at 2021-10-12T01:41:04-04:00 rts/Linker: Fix __dso_handle handling Previously the linker's handling of __dso_handle was quite wrong. Not only did we claim that __dso_handle could be NULL when statically linking (which it can not), we didn't even implement this mislead theory faithfully and instead resolved the symbol to a random pointer. This lead to the failing relocations on AArch64 noted in #20493. Here we try to implement __dso_handle as a dynamic linker would do, choosing an address within the loaded object (specifically its start address) to serve as the object's handle. - - - - - 58223dfa by Carrie Xu at 2021-10-12T01:41:41-04:00 Add Hint to "Empty 'do' block" Error Message#20147 - - - - - 8e88ef36 by Carrie Xu at 2021-10-12T01:41:41-04:00 Change affected tests stderr - - - - - 44384696 by Zubin Duggal at 2021-10-12T01:42:15-04:00 driver: Share the graph of dependencies We want to share the graph instead of recomputing it for each key. - - - - - e40feab0 by Matthew Pickering at 2021-10-12T01:42:50-04:00 Make ms_ghc_prim_import field strict If you don't promptly force this field then it ends up retaining a lot of data structures related to parsing. For example, the following retaining chain can be observed when using GHCi. ``` PState 0x4289365ca0 0x4289385d68 0x4289385db0 0x7f81b37a7838 0x7f81b3832fd8 0x4289365cc8 0x4289365cd8 0x4289365cf0 0x4289365cd8 0x4289365d08 0x4289385e48 0x7f81b4e4c290 0x7f818f63f440 0x7f818f63f440 0x7f81925ccd18 0x7f81b4e41230 0x7f818f63f440 0x7f81925ccd18 0x7f818f63f4a8 0x7f81b3832fd8 0x7f81b3832fd8 0x4289365d20 0x7f81b38233b8 0 19 <PState:GHC.Parser.Lexer:_build-ipe/stage1/compiler/build/GHC/Parser/Lexer.hs:3779:46> _thunk( ) 0x4289384230 0x4289384160 <([LEpaComment], [LEpaComment]):GHC.Parser.Lexer:> _thunk( ) 0x4289383250 <EpAnnComments:GHC.Parser.Lexer:compiler/GHC/Parser/Lexer.x:2306:19-40> _thunk( ) 0x4289399850 0x7f818f63f440 0x4289399868 <SrcSpanAnnA:GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12527:13-30> L 0x4289397600 0x42893975a8 <GenLocated:GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12527:32> 0x4289c4e8c8 : 0x4289c4e8b0 <[]:GHC.Parser.Header:compiler/GHC/Parser/Header.hs:104:36-54> (0x4289c4da70,0x7f818f63f440) <(,):GHC.Parser.Header:compiler/GHC/Parser/Header.hs:104:36-54> _thunk( ) 0x4289c4d030 <Bool:GHC.Parser.Header:compiler/GHC/Parser/Header.hs:(112,22)-(115,27)> ExtendedModSummary 0x422e9c8998 0x7f81b617be78 0x422e9c89b0 0x4289c4c0c0 0x7f81925ccd18 0x7f81925ccd18 0x7f81925ccd18 0x7f81925ccd18 0x7f818f63f440 0x4289c4c0d8 0x4289c4c0f0 0x7f81925ccd18 0x422e9c8a20 0x4289c4c108 0x4289c4c730 0x7f818f63f440 <ExtendedModSummary:GHC.Driver.Make:compiler/GHC/Driver/Make.hs:2041:30-38> ModuleNode 0x4289c4b850 <ModuleGraphNode:GHC.Unit.Module.Graph:compiler/GHC/Unit/Module/Graph.hs:139:14-36> 0x4289c4b590 : 0x4289c4b578 <[]:GHC.Unit.Module.Graph:compiler/GHC/Unit/Module/Graph.hs:139:31-36> ModuleGraph 0x4289c4b2f8 0x4289c4b310 0x4289c4b340 0x7f818f63f4a0 <ModuleGraph:GHC.Driver.Make:compiler/GHC/Driver/Make.hs:(242,19)-(244,40)> HscEnv 0x4289d9a4a8 0x4289d9aad0 0x4289d9aae8 0x4217062a88 0x4217060b38 0x4217060b58 0x4217060b68 0x7f81b38a7ce0 0x4217060b78 0x7f818f63f440 0x7f818f63f440 0x4217062af8 0x4289d9ab10 0x7f81b3907b60 0x4217060c00 114 <HscEnv:GHC.Runtime.Eval:compiler/GHC/Runtime/Eval.hs:790:31-44> ``` - - - - - 5c266b59 by Ben Gamari at 2021-10-12T19:16:40-04:00 hadrian: Introduce `static` flavour - - - - - 683011c7 by Ben Gamari at 2021-10-12T19:16:40-04:00 gitlab-ci: Introduce static Alpine job - - - - - 9257abeb by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Drop :set from ghci scripts The ghci scripts for T9293 and ghci057 used `:set` to print the currently-set options. However, in neither case was this necessary to the correctness of the test and moreover it would introduce spurious platform-dependence (e.g. since `-fexternal-dynamic-refs` is set by default only on platforms that support dynamic linking). - - - - - 82a89df7 by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/linker: Define _DYNAMIC when necessary Usually the dynamic linker would define _DYNAMIC. However, when dynamic linking is not supported (e.g. on musl) it is safe to define it to be NULL. - - - - - fcd970b5 by GHC GitLab CI at 2021-10-12T19:16:40-04:00 rts/linker: Resolve __fini_array_* symbols to NULL If the __fini_array_{start,end} symbols are not defined (e.g. as is often the case when linking against musl) then resolve them to NULL. - - - - - 852ec4f5 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Mark T13702 as requiring share libraries It fails on statically-built Alpine with ``` T13702.hs:1:1: error: Could not find module ‘Prelude’ Perhaps you haven't installed the "dyn" libraries for package ‘base-4.15.0.0’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 1 | {-# LANGUAGE ForeignFunctionInterface #-} | ^ ``` - - - - - b604bfd9 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Mark ghcilink00[25] as requiring dynamic linking - - - - - d709a133 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Mark all ghci/linking/dyn tests as requiring dynamic linking - - - - - 99b8177a by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Mark T14931 as requiring dynamic linking - - - - - 2687f65e by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Compile safeInfered tests with -v0 This eliminates some spurious platform-dependence due to static linking (namely in UnsafeInfered02 due to dynamic-too). - - - - - 587d7e66 by Brian Jaress at 2021-10-12T19:16:40-04:00 documentation: flavours.md static details - - - - - 91cfe121 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Make recomp021 less environment-sensitive Suppress output from diff to eliminate unnecessary environmental-dependence. - - - - - dc094597 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Make T12600 more robust Previously we would depend upon `grep ... | head -n1`. In principle this should work, but on Alpine Linux `grep` complains when its stdout stream has been closed. - - - - - cdd45a61 by Ben Gamari at 2021-10-12T19:16:40-04:00 gitlab-ci: Mark more broken tests on Alpine - - - - - 9ebda74e by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/RtsSymbols: Add environ - - - - - 08aa7a1d by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/linker: Introduce a notion of strong symbols - - - - - 005b1848 by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/RtsSymbols: Declare atexit as a strong symbol - - - - - 5987357b by Ben Gamari at 2021-10-12T19:16:40-04:00 rts/RtsSymbols: fini array - - - - - 9074b748 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Move big-obj test from ghci/linking/dyn to ghci/linking There was nothing dynamic about this test. - - - - - 3b1c12d3 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Fix overzealous command-line mangling Previously this attempt at suppressing make's -s flag would mangle otherwise valid arguments. - - - - - 05303f68 by Ben Gamari at 2021-10-12T19:16:40-04:00 testsuite: Clean up dynlib support predicates Previously it was unclear whether req_shared_libs should require: * that the platform supports dynamic library loading, * that GHC supports dynamic linking of Haskell code, or * that the dyn way libraries were built Clarify by splitting the predicate into two: * `req_dynamic_lib_support` demands that the platform support dynamic linking * `req_dynamic_hs` demands that the GHC support dynamic linking of Haskell code on the target platform Naturally `req_dynamic_hs` cannot be true unless `req_dynamic_lib_support` is also true. - - - - - 9859eede by Ben Gamari at 2021-10-12T19:16:40-04:00 gitlab-ci: Bump docker images Bumps bootstrap compiler to GHC 9.0.1. - - - - - af5ed156 by Matthew Pickering at 2021-10-12T19:17:15-04:00 Make the OccName field of NotOrphan strict In GHCi, by default the ModIface is not written to disk, this can leave a thunk which retains a TyCon which ends up retaining a great deal more on the heap. For example, here is the retainer trace from ghc-debug. ``` ... many other closures ... <TyCon:GHC.Core.TyCon:compiler/GHC/Core/TyCon.hs:1755:34-97> Just 0x423162aaa8 <Maybe:GHC.Core.TyCon:compiler/GHC/Core/TyCon.hs:(1936,11)-(1949,13)> FamilyTyCon 0x4231628318 0x4210e06260 0x4231628328 0x4231628340 0x421730a398 0x4231628358 0x4231628380 0x4231628390 0x7f0f5a171d18 0x7f0f7b1d7850 0x42316283a8 0x7f0f7b1d7830 <TyCon:GHC.Core.TyCon:compiler/GHC/Cor e/TyCon.hs:1948:30-32> _thunk( ) 0x4231624000 <OccName:GHC.Iface.Make:compiler/GHC/Iface/Make.hs:724:22-43> NotOrphan 0x42357d8ed8 <IsOrphan:GHC.Iface.Make:compiler/GHC/Iface/Make.hs:724:12-43> IfaceFamInst 0x4210e06260 0x42359aed10 0x4210e0c6b8 0x42359aed28 <IfaceFamInst:GHC.Iface.Make:> ``` Making the field strict squashes this retainer leak when using GHCi. - - - - - 0c5d9ca8 by Matthew Pickering at 2021-10-12T19:17:15-04:00 Be more careful about retaining KnotVars It is quite easy to end up accidently retaining a KnotVars, which contains pointers to a stale TypeEnv because they are placed in the HscEnv. One place in particular we have to be careful is when loading a module into the EPS in `--make` mode, we have to remove the reference to KnotVars as otherwise the interface loading thunks will forever retain reference to the KnotVars which are live at the time the interface was loaded. These changes do not go as far as to enforce the invariant described in Note [KnotVar invariants] * At the end of upsweep, there should be no live KnotVars but at least improve the situation. This is left for future work (#20491) - - - - - 105e2711 by Matthew Pickering at 2021-10-12T19:17:15-04:00 driver: Pass hsc_env with empty HPT into upsweep Otherwise you end up retaining the whole old HPT when reloading in GHCi. - - - - - 7215f6de by Matthew Pickering at 2021-10-12T19:17:15-04:00 Make fields of Linkable strict The Module field can end up retaining part of a large structure and is always calculated by projection. - - - - - 053d9deb by Matthew Pickering at 2021-10-12T19:17:15-04:00 Make the fields of MakeEnv strict There's no reason for them to be lazy, and in particular we would like to make sure the old_hpt field is evaluated. - - - - - 0d711791 by Matthew Pickering at 2021-10-12T19:17:15-04:00 More strictness around HomePackageTable This patch makes some operations to do with HomePackageTable stricter * Adding a new entry into the HPT would not allow the old HomeModInfo to be collected because the function used by insertWith wouldn't be forced. * We're careful to force the new MVar value before it's inserted into the global MVar as otherwise we retain references to old entries. - - - - - ff0409d0 by Matthew Pickering at 2021-10-12T19:17:15-04:00 driver: Filter out HPT modules **before** typecheck loop It's better to remove the modules first before performing the typecheckLoop as otherwise you can end up with thunks which reference stale HomeModInfo which are difficult to force due to the knot-tie. - - - - - c2ce1b17 by Matthew Pickering at 2021-10-12T19:17:15-04:00 Add GHCi recompilation performance test - - - - - 82938981 by Matthew Pickering at 2021-10-12T19:17:15-04:00 Force name_exe field to avoid retaining entire UnitEnv (including whole HPT) Not forcing this one place will result in GHCi using 2x memory on a reload. - - - - - 90f06a0e by Haochen Tong at 2021-10-12T19:17:53-04:00 Check for libatomic dependency for atomic operations Some platforms (e.g. RISC-V) require linking against libatomic for some (e.g. sub-word-sized) atomic operations. Fixes #19119. - - - - - 234bf368 by Haochen Tong at 2021-10-12T19:17:53-04:00 Move libatomic check into m4/fp_gcc_supports_atomics.m4 - - - - - 4cf43b2a by Haochen Tong at 2021-10-12T19:17:53-04:00 Rename fp_gcc_supports__atomics to fp_cc_supports__atomics - - - - - 0aae1b4e by Joachim Breitner at 2021-10-13T01:07:45+00:00 shadowNames: Accept an OccName, not a GreName previously, the `shadowNames` function would take `[GreName]`. This has confused me for two reasons: * Why `GreName` and not `Name`? Does the difference between a normal name and a field name matter? The code of `shadowNames` shows that it does not, but really its better if the type signatures says so. * Why `Name` and not `OccName`? The point of `shadowNames` is to shadow _unqualified names_, at least in the two use cases I am aware of (names defined on the GHCI prompt or in TH splices). The code of `shadowNames` used to have cases that peek at the module of the given name and do something if that module appears in the `GlobalRdrElt`, but I think these cases are dead code, I don’t see how they could occur in the above use cases. Also, I replaced them with `errors` and GHC would still validate. Hence removing this code (yay!) This change also allows `shadowNames` to accept an `OccSet` instead, which allows for a faster implemenation; I’ll try that separately. This in stead might help with !6703. - - - - - 19cd403b by Norman Ramsey at 2021-10-13T03:32:21-04:00 Define and export Outputable instance for StgOp - - - - - 58bd0cc1 by Zubin Duggal at 2021-10-13T13:50:10+05:30 ci: build validate-x86_64-linux-deb9-debug with hyperlinked source (#20067) - - - - - 4536e8ca by Zubin Duggal at 2021-10-13T13:51:00+05:30 hadrian, testsuite: Teach Hadrian to query the testsuite driver for dependencies Issues #19072, #17728, #20176 - - - - - 60d3e33d by Zubin Duggal at 2021-10-13T13:51:03+05:30 hadrian: Fix location for haddocks in installed pkgconfs - - - - - 337a31db by Zubin Duggal at 2021-10-13T13:51:03+05:30 testsuite: Run haddock tests on out of tree compiler - - - - - 8c224b6d by Zubin Duggal at 2021-10-13T13:51:03+05:30 ci: test in-tree compiler in hadrian - - - - - 8d5a5ecf by Zubin Duggal at 2021-10-13T13:51:03+05:30 hadrian: avoid building check-{exact,ppr} and count-deps when the tests don't need them hadrian: build optional dependencies with test compiler - - - - - d0e87d0c by Zubin Duggal at 2021-10-13T13:51:03+05:30 testsuite: remove 'req_smp' from testwsdeque - - - - - 3c0e60b8 by Zubin Duggal at 2021-10-13T13:51:03+05:30 testsuite: strip windows line endings for haddock haddock: deterministic SCC Updates haddock submodule Metric Increase: haddock.Cabal haddock.base haddock.compiler - - - - - 64460b20 by Ben Gamari at 2021-10-13T18:44:12-04:00 distrib/configure: Add AC_CONFIG_MACRO_DIRS Sadly, autoconf cannot warn when it encounters an undefined macro and therefore this bug went unnoticed for altogether far too long. - - - - - e46edfcf by sheaf at 2021-10-13T18:44:49-04:00 Set logger flags in --backpack mode Backpack used to initialise the logger before obtaining the DynFlags. This meant that logging options (such as dump flags) were not set. Initialising the logger after the session flags have been set fixes the issue. fixes #20396 - - - - - df016e4e by Matthew Pickering at 2021-10-14T08:41:17-04:00 Make sure paths are quoted in install Makefile Previously it would fail with this error: ``` if [ -L wrappers/ghc ]; then echo "ghc is a symlink"; fi ghc is a symlink cp: target 'dir/bin/ghc' is not a directory make: *** [Makefile:197: install_wrappers] Error 1 ``` which is because the install path contains a space. Fixes #20506 - - - - - 7f2ce0d6 by Joachim Breitner at 2021-10-14T08:41:52-04:00 Move BreakInfo into own module while working on GHCi stuff, e.g. `GHC.Runtime.Eval.Types`, I observed a fair amount of modules being recompiled that I didn’t expect to depend on this, from byte code interpreters to linkers. Turns out that the rather simple `BreakInfo` type is all these modules need from the `GHC.Runtime.Eval.*` hierarchy, so by moving that into its own file we make the dependency tree wider and shallower, which is probably worth it. - - - - - 557d26fa by Ziyang Liu at 2021-10-14T14:32:57-04:00 Suggest -dynamic-too in failNonStd when applicable I encountered an error that says ``` Cannot load -dynamic objects when GHC is built the normal way To fix this, either: (1) Use -fexternal-interpreter, or (2) Build the program twice: once the normal way, and then with -dynamic using -osuf to set a different object file suffix. ``` Or it could say ``` (2) Use -dynamic-too ``` - - - - - f450e948 by Joachim Breitner at 2021-10-14T14:33:32-04:00 fuzzyLookup: More deterministic order else the output may depend on the input order, which seems it may depend on the concrete Uniques, which is causing headaches when including test cases about that. - - - - - 8b7f5424 by Alan Zimmerman at 2021-10-14T14:34:07-04:00 EPA: Preserve semicolon order in annotations Ensure the AddSemiAnn items appear in increasing order, so that if they are converted to delta format they are still in the correct order. Prior to this the exact printer sorted by Span, which is meaningless for EpaDelta locations. - - - - - 481e6b54 by Matthew Pickering at 2021-10-14T14:34:42-04:00 Some extra strictness in annotation fields Locations can be quite long-lived so it's important that things which live in locations, such as annotations are forced promptly. Otherwise they end up retaining the entire PState, as evidenced by this retainer trace: ``` PState 0x4277ce6cd8 0x4277ce6d00 0x7f61f12d37d8 0x7f61f12d37d8 0x7f61f135ef78 0x4277ce6d48 0x4277ce6d58 0x4277ce6d70 0x4277ce6d58 0x4277ce6d88 0x4277ce6da0 0x7f61f29782f0 0x7f61cd16b440 0x7f61cd16b440 0x7f61d00f8d18 0x7f61f296d290 0x7f61cd16b440 0x7f61d00f8d18 0x7f61cd16b4a8 0x7f61f135ef78 0x4277ce6db8 0x4277ce6dd0 0x7f61f134f358 0 3 <PState:GHC.Parser.Lexer:_build-ipe/stage1/compiler/build/GHC/Parser/Lexer.hs:3779:46> _thunk( ) 0x4277ce6280 0x4277ce68a0 <([LEpaComment], [LEpaComment]):GHC.Parser.Lexer:> _thunk( ) 0x4277ce6568 <EpAnnComments:GHC.Parser.Lexer:compiler/GHC/Parser/Lexer.x:2306:19-40> _thunk( ) 0x4277ce62b0 0x4277ce62c0 0x4277ce6280 0x7f61f287fc58 <EpAnn AnnList:GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12664:13-32> SrcSpanAnn 0x4277ce6060 0x4277ce6048 <SrcSpanAnn':GHC.Parser:_build-ipe/stage1/compiler/build/GHC/Parser.hs:12664:3-35> L 0x4277ce4e70 0x428f8c9158 <GenLocated:GHC.Data.BooleanFormula:compiler/GHC/Data/BooleanFormula.hs:40:23-29> 0x428f8c8318 : 0x428f8c8300 <[]:GHC.Base:libraries/base/GHC/Base.hs:1316:16-29> Or 0x428f8c7890 <BooleanFormula:GHC.Data.BooleanFormula:compiler/GHC/Data/BooleanFormula.hs:40:23-29> IfConcreteClass 0x7f61cd16b440 0x7f61cd16b440 0x428f8c7018 0x428f8c7030 <IfaceClassBody:GHC.Iface.Make:compiler/GHC/Iface/Make.hs:(640,12)-(645,13)> ``` Making these few places strict is sufficient for now but there are perhaps more places which will need strictifying in future. ------------------------- Metric Increase: parsing001 ------------------------- - - - - - 7a8171bc by Tom Sydney Kerckhove at 2021-10-15T06:51:18+00:00 Insert warnings in the documentation of dangerous functions - - - - - 1cda768c by Joachim Breitner at 2021-10-15T18:15:36-04:00 GHC.Builtin.Uniques: Remove unused code a number of functions exported by this module are (no longer) used, so let’s remove them. In particular, it no longer seems to be the case that type variables have tag `'t'`, so removed the special handling when showing them. * the use of `initTyVarUnique` was removed in 7babb1 (with the notable commit message of "Before merging to HEAD we need to tidy up and write a proper commit message.") * `mkPseudoUniqueD`and `mkPseudoUniqueH` were added in 423d477, but never ever used? * `mkCoVarUnique` was added in 674654, but never ever used? - - - - - 88e913d4 by Oleg Grenrus at 2021-10-15T18:16:14-04:00 Null eventlog writer - - - - - bbb1f6da by Sylvain Henry at 2021-10-15T18:16:51-04:00 Hadrian: display command line above errors (#20490) - - - - - b6954f0c by Joachim Breitner at 2021-10-15T18:17:26-04:00 shadowNames: Use OccEnv a, not [OccName] this allows us to use a smarter implementation based on `Data.IntSet.differenceWith`, which should do less work. Also, it will unblock improvements to !6703. The `OccEnv a` really denotes a set of `OccName`s. We are not using `OccSet`, though, because that is an `OccEnv OccName`, and we in !6703 we want to use this with differently-valued `OccEnv`s. But `OccSet`s are readily and safely coerced into `OccEnv`s. There is no other use of `delLocalRdrEnvList` remaining, so removing that. - - - - - c9922a8e by Matthew Pickering at 2021-10-15T18:18:00-04:00 hadrian: Document lint targets Fixes #20508 - - - - - 65bf3992 by Matthew Pickering at 2021-10-17T14:06:08-04:00 ghci: Explicitly store and restore interface file cache In the old days the old HPT was used as an interface file cache when using ghci. The HPT is a `ModuleEnv HomeModInfo` and so if you were using hs-boot files then the interface file from compiling the .hs file would be present in the cache but not the hi-boot file. This used to be ok, because the .hi file used to just be a better version of the .hi-boot file, with more information so it was fine to reuse it. Now the source hash of a module is kept track of in the interface file and the source hash for the .hs and .hs-boot file are correspondingly different so it's no longer safe to reuse an interface file. I took the decision to move the cache management of interface files to GHCi itself, and provide an API where `load` can be provided with a list of interface files which can be used as a cache. An alternative would be to manage this cache somewhere in the HscEnv but it seemed that an API user should be responsible for populating and suppling the cache rather than having it managed implicitly. Fixes #20217 - - - - - 81740ce8 by sheaf at 2021-10-17T14:06:46-04:00 Introduce Concrete# for representation polymorphism checks PHASE 1: we never rewrite Concrete# evidence. This patch migrates all the representation polymorphism checks to the typechecker, using a new constraint form Concrete# :: forall k. k -> TupleRep '[] Whenever a type `ty` must be representation-polymorphic (e.g. it is the type of an argument to a function), we emit a new `Concrete# ty` Wanted constraint. If this constraint goes unsolved, we report a representation-polymorphism error to the user. The 'FRROrigin' datatype keeps track of the context of the representation-polymorphism check, for more informative error messages. This paves the way for further improvements, such as allowing type families in RuntimeReps and improving the soundness of typed Template Haskell. This is left as future work (PHASE 2). fixes #17907 #20277 #20330 #20423 #20426 updates haddock submodule ------------------------- Metric Decrease: T5642 ------------------------- - - - - - 19d1237e by Koz Ross at 2021-10-19T03:29:40-04:00 Fix infelicities in docs for lines, unlines, words, unwords - - - - - 3035d1a2 by Matthew Pickering at 2021-10-19T03:30:16-04:00 tests: Remove $(CABAL_MINIMAL_CONFIGURATION) from T16219 There is a latent issue in T16219 where -dynamic-too is enabled when compiling a signature file which causes us to enter the DT_Failed state because library-a-impl doesn't generate dyn_o files. Somehow this used to work in 8.10 (that also entered the DT_Failed state) We don't need dynamic object files when compiling a signature file but the code loads interfaces, and if dynamic-too is enabled then it will also try to load the dyn_hi file and check the two are consistent. There is another hack to do with this in `GHC.Iface.Recomp`. The fix for this test is to remove CABAL_MINIMAL_CONFIGURATION, which stops cabal building shared libraries by default. I'm of the opinion that the DT_Failed state indicates an error somewhere so we should hard fail rather than this confusing (broken) rerun logic. Whether this captures the original intent of #16219 is debateable, but it's not clear how it was supposed to work in the first place if the libraries didn't build dynamic object files. Module C imports module A, which is from a library where shared objects are not built so the test would never have worked anyway (if anything from A was used in a TH splice). - - - - - d25868b6 by Matthew Pickering at 2021-10-19T03:30:16-04:00 dynamic-too: Expand GHC.Iface.Recomp comment about the backpack hack - - - - - 837ce6cf by Matthew Pickering at 2021-10-19T03:30:16-04:00 driver: Check the correct flag to see if dynamic-too is enabled. We just need to check the flag here rather than read the variable which indicates whether dynamic-too compilation has failed. - - - - - 981f2c74 by Matthew Pickering at 2021-10-19T03:30:16-04:00 driver: Update cached DynFlags in ModSummary if we are enabling -dynamic-too - - - - - 1bc77a85 by Matthew Pickering at 2021-10-19T03:30:16-04:00 dynamic-too: Check the dynamic-too status in hscPipeline This "fixes" DT_Failed in --make mode, but only "fixes" because I still believe DT_Failed is pretty broken. - - - - - 51281e81 by Matthew Pickering at 2021-10-19T03:30:16-04:00 Add test for implicit dynamic too This test checks that we check for missing dynamic objects if dynamic-too is enabled implicitly by the driver. - - - - - 8144a92f by Matthew Pickering at 2021-10-19T03:30:16-04:00 WW: Use module name rather than filename for absent error messages WwOpts in WorkWrap.Utils initialised the wo_output_file field with the result of outputFile dflags. This is misguided because outputFile is only set when -o is specified, which is barely ever (and never in --make mode). It seems this is just used to add more context to an error message, a more appropriate thing to use I think would be a module name. Fixes #20438 - - - - - df419c1a by Matthew Pickering at 2021-10-19T03:30:16-04:00 driver: Cleanups related to ModLocation ModLocation is the data type which tells you the locations of all the build products which can affect recompilation. It is now computed in one place and not modified through the pipeline. Important locations will now just consult ModLocation rather than construct the dynamic object path incorrectly. * Add paths for dynamic object and dynamic interface files to ModLocation. * Always use the paths from mod location when looking for where to find any interface or object file. * Always use the paths in a ModLocation when deciding where to write an interface and object file. * Remove `dynamicOutputFile` and `dynamicOutputHi` functions which *calculated* (incorrectly) the location of `dyn_o` and `dyn_hi` files. * Don't set `outputFile_` and so-on in `enableCodeGenWhen`, `-o` and hence `outputFile_` should not affect the location of object files in `--make` mode. It is now sufficient to just update the ModLocation with the temporary paths. * In `hscGenBackendPipeline` don't recompute the `ModLocation` to account for `-dynamic-too`, the paths are now accurate from the start of the run. * Rename `getLocation` to `mkOneShotModLocation`, as that's the only place it's used. Increase the locality of the definition by moving it close to the use-site. * Load the dynamic interface from ml_dyn_hi_file rather than attempting to reconstruct it in load_dynamic_too. * Add a variety of tests to check how -o -dyno etc interact with each other. Some other clean-ups * DeIOify mkHomeModLocation and friends, they are all pure functions. * Move FinderOpts into GHC.Driver.Config.Finder, next to initFinderOpts. * Be more precise about whether we mean outputFile or outputFile_: there were many places where outputFile was used but the result shouldn't have been affected by `-dyno` (for example the filename of the resulting executable). In these places dynamicNow would never be set but it's still more precise to not allow for this possibility. * Typo fixes suffices -> suffixes in the appropiate places. - - - - - 3d6eb85e by Matthew Pickering at 2021-10-19T03:30:16-04:00 driver: Correct output of -fno-code and -dynamic-too Before we would print [1 of 3] Compiling T[boot] ( T.hs-boot, nothing, T.dyn_o ) Which was clearly wrong for two reasons. 1. No dynamic object file was produced for T[boot] 2. The file would be called T.dyn_o-boot if it was produced. Fixes #20300 - - - - - 753b921d by Matthew Pickering at 2021-10-19T03:30:16-04:00 Remove DT_Failed state At the moment if `-dynamic-too` fails then we rerun the whole pipeline as if we were just in `-dynamic` mode. I argue this is a misfeature and we should remove the so-called `DT_Failed` mode. In what situations do we fall back to `DT_Failed`? 1. If the `dyn_hi` file corresponding to a `hi` file is missing completely. 2. If the interface hash of `dyn_hi` doesn't match the interface hash of `hi`. What happens in `DT_Failed` mode? * The whole compiler pipeline is rerun as if the user had just passed `-dynamic`. * Therefore `dyn_hi/dyn_o` files are used which don't agree with the `hi/o` files. (As evidenced by `dynamicToo001` test). * This is very confusing as now a single compiler invocation has produced further `hi`/`dyn_hi` files which are different to each other. Why should we remove it? * In `--make` mode, which is predominately used `DT_Failed` does not work (#19782), there can't be users relying on this functionality. * In `-c` mode, the recovery doesn't fix the root issue, which is the `dyn_hi` and `hi` files are mismatched. We should instead produce an error and pass responsibility to the build system using `-c` to ensure that the prerequisites for `-dynamic-too` (dyn_hi/hi) files are there before we start compiling. * It is a misfeature to support use cases like `dynamicToo001` which allow you to mix different versions of dynamic/non-dynamic interface files. It's more likely to lead to subtle bugs in your resulting programs where out-dated build products are used rather than a deliberate choice. * In practice, people are usually compiling with `-dynamic-too` rather than separately with `-dynamic` and `-static`, so the build products always match and `DT_Failed` is only entered due to compiler bugs (see !6583) What should we do instead? * In `--make` mode, for home packages check during recompilation checking that `dyn_hi` and `hi` are both present and agree, recompile the modules if they do not. * For package modules, when loading the interface check that `dyn_hi` and `hi` are there and that they agree but fail with an error message if they are not. * In `--oneshot` mode, fail with an error message if the right files aren't already there. Closes #19782 #20446 #9176 #13616 - - - - - 7271bf78 by Joachim Breitner at 2021-10-19T03:30:52-04:00 InteractiveContext: Smarter caching when rebuilding the ic_rn_gbl_env The GlobalRdrEnv of a GHCI session changes in odd ways: New bindings are not just added "to the end", but also "in the middle", namely when changing the set of imports: These are treated as if they happened before all bindings from the prompt, even those that happened earlier. Previously, this meant that the `ic_rn_gbl_env` is recalculated from the `ic_tythings`. But this wasteful if `ic_tythings` has many entries that define the same unqualified name. By separately keeping track of a `GlobalRdrEnv` of all the locally defined things we can speed this operation up significantly. This change improves `T14052Type` by 60% (It used to be 70%, but it looks that !6723 already reaped some of the rewards). But more importantly, it hopefully unblocks #20455, becaues with this smarter caching, the change needed to fix that issue will no longer make `T14052` explode. I hope. It does regress `T14052` by 30%; caching isn’t free. Oh well. Metric Decrease: T14052Type Metric Increase: T14052 - - - - - 53c0e771 by Matthew Pickering at 2021-10-19T03:31:27-04:00 Add test for T20509 This test checks to see whether a signature can depend on another home module. Whether it should or not is up for debate, see #20509 for more details. - - - - - fdfb3b03 by Matthew Pickering at 2021-10-19T03:31:27-04:00 Make the fields of Target and TargetId strict Targets are long-lived through GHC sessions so we don't want to end up retaining In particular in 'guessTarget', the call to `unitIdOrHomeUnit` was retaining reference to an entire stale HscEnv, which in turn retained reference to a stale HomePackageTable. Making the fields strict forces that place promptly and helps ensure that mistakes like this don't happen again. - - - - - 877e6685 by Matthew Pickering at 2021-10-19T03:31:27-04:00 Temporary fix for leak with -fno-code (#20509) This hack inserted for backpack caused a very bad leak when using -fno-code where EPS entries would end up retaining stale HomePackageTables. For any interactive user, such as HLS, this is really bad as once the entry makes it's way into the EPS then it's there for the rest of the session. This is a temporary fix which "solves" the issue by filtering the HPT to only the part which is needed for the hack to work, but in future we want to separate out hole modules from the HPT entirely to avoid needing to do this kind of special casing. ------------------------- Metric Decrease: MultiLayerModulesDefsGhci ------------------------- - - - - - cfacac68 by Matthew Pickering at 2021-10-19T03:31:27-04:00 Add performance test for ghci, -fno-code and reloading (#20509) This test triggers the bad code path identified by #20509 where an entry into the EPS caused by importing Control.Applicative will retain a stale HomePackageTable. - - - - - 12d74ef7 by Richard Eisenberg at 2021-10-19T13:36:36-04:00 Care about specificity in pattern type args Close #20443. - - - - - 79c9c816 by Zubin Duggal at 2021-10-19T13:37:12-04:00 Don't print Shake Diagnostic messages (#20484) - - - - - f8ce38e6 by Emily Martins at 2021-10-19T22:21:26-04:00 Fix #19884: add warning to tags command, drop T10989 - - - - - d73131b9 by Ben Gamari at 2021-10-19T22:22:02-04:00 hadrian: Fix quoting in binary distribution installation Makefile Previously we failed to quote various paths in Hadrian's installation Makefile, resulting in #20506. - - - - - 949d7398 by Matthew Pickering at 2021-10-20T14:05:23-04:00 Add note about heap invariants [skip ci] At the moment the note just covers three important invariants but now there is a place to add more to if we think of them. - - - - - 2f75ffac by Ben Gamari at 2021-10-20T14:06:00-04:00 hadrian/doc: Add margin to staged-compilation figure - - - - - 5f274fbf by Ben Gamari at 2021-10-20T14:06:00-04:00 hadrian: Fix binary-dist support for cross-compilers Previously the logic which called ghc-pkg failed to account for the fact that the executable name may be prefixed with a triple. Moreover, the call must occur before we delete the settings file as ghc-pkg needs the latter. Fixes #20267. - - - - - 3e4b51ff by Matthew Pickering at 2021-10-20T14:06:36-04:00 Fix perf-nofib CI job The main change is to install the necessary build dependencies into an environment file using `caball install --lib`. Also updates the nofib submodule with a few fixes needed for the job to work. - - - - - ef92d889 by Matthew Pickering at 2021-10-20T14:07:12-04:00 Distribute HomeModInfo cache before starting upsweep This change means the HomeModInfo cache isn't retained until the end of upsweep and each cached interface can be collected immediately after its module is compiled. The result is lower peak memory usage when using GHCi. For Agda it reduced peak memory usage from about 1600M to 1200M. - - - - - 05b8a218 by Matthew Pickering at 2021-10-20T14:07:49-04:00 Make fields of GlobalRdrElt strict In order to do this I thought it was prudent to change the list type to a bag type to avoid doing a lot of premature work in plusGRE because of ++. Fixes #19201 - - - - - 0b575899 by Sylvain Henry at 2021-10-20T17:49:07-04:00 Bignum: constant folding for bigNatCompareWord# (#20361) - - - - - 758e0d7b by Sylvain Henry at 2021-10-20T17:49:07-04:00 Bignum: allow Integer predicates to inline (#20361) T17516 allocations increase by 48% because Integer's predicates are inlined in some Ord instance methods. These methods become too big to be inlined while they probably should: this is tracked in #20516. Metric Increase: T17516 - - - - - a901a1ae by Sylvain Henry at 2021-10-20T17:49:07-04:00 Bignum: allow Integer's signum to inline (#20361) Allow T12545 to increase because it only happens on CI with dwarf enabled and probably not related to this patch. Metric Increase: T12545 - - - - - 9ded1b17 by Matthew Pickering at 2021-10-20T17:49:42-04:00 Make sure ModIface values are still forced even if not written When we are not writing a ModIface to disk then the result can retain a lot of stuff. For example, in the case I was debugging the DocDeclsMap field was holding onto the entire HomePackageTable due to a single unforced thunk. Therefore, now if we're not going to write the interface then we still force deeply it in order to remove these thunks. The fields in the data structure are not made strict because when we read the field from the interface we don't want to load it immediately as there are parts of an interface which are unused a lot of the time. Also added a note to explain why not all the fields in a ModIface field are strict. The result of this is being able to load Agda in ghci and not leaking information across subsequent reloads. - - - - - 268857af by Matthew Pickering at 2021-10-20T17:50:19-04:00 ci: Move hlint jobs from quick-built into full-build This somewhat fixes the annoyance of not getting any "useful" feedback from a CI pipeline if you have a hlint failure. Now the hlint job runs in parallel with the other CI jobs so the feedback is recieved at the same time as other testsuite results. Fixes #20507 - - - - - f6f24515 by Joachim Breitner at 2021-10-20T17:50:54-04:00 instance Ord Name: Do not repeat default methods it is confusing to see what looks like it could be clever code, only to see that it does precisely the same thing as the default methods. Cleaning this up, to spare future readers the confusion. - - - - - 56b2b04f by Ziyang Liu at 2021-10-22T10:57:28-04:00 Document that `InScopeSet` is a superset of currently in-scope variables - - - - - 7f4e0e91 by Moritz Angermann at 2021-10-22T10:58:04-04:00 Do not sign extend CmmInt's unless negative. Might fix #20526. - - - - - 77c6f3e6 by sheaf at 2021-10-22T10:58:44-04:00 Use tcEqType in GHC.Core.Unify.uVar Because uVar used eqType instead of tcEqType, it was possible to accumulate a substitution that unified Type and Constraint. For example, a call to `tc_unify_tys` with arguments tys1 = [ k, k ] tys2 = [ Type, Constraint ] would first add `k = Type` to the substitution. That's fine, but then the second call to `uVar` would claim that the substitution also unifies `k` with `Constraint`. This could then be used to cause trouble, as per #20521. Fixes #20521 - - - - - fa5870d3 by Sylvain Henry at 2021-10-22T19:20:05-04:00 Add test for #19641 Now that Bignum predicates are inlined (!6696), we only need to add a test. Fix #19641 - - - - - 6fd7da74 by Sylvain Henry at 2021-10-22T19:20:44-04:00 Remove Indefinite We no longer need it after previous IndefUnitId refactoring. - - - - - 806e49ae by Sylvain Henry at 2021-10-22T19:20:44-04:00 Refactor package imports Use an (Raw)PkgQual datatype instead of `Maybe FastString` to represent package imports. Factorize the code that renames RawPkgQual into PkgQual in function `rnPkgQual`. Renaming consists in checking if the FastString is the magic "this" keyword, the home-unit unit-id or something else. Bump haddock submodule - - - - - 47ba842b by Haochen Tong at 2021-10-22T19:21:21-04:00 Fix compilerConfig stages Fix the call to compilerConfig because it accepts 1-indexed stage numbers. Also fixes `make stage=3`. - - - - - 621608c9 by Matthew Pickering at 2021-10-22T19:21:56-04:00 driver: Don't use the log queue abstraction when j = 1 This simplifies the code path for -j1 by not using the log queue queue abstraction. The result is that trace output isn't interleaved with other dump output like it can be with -j<N>. - - - - - dd2dba80 by Sebastian Graf at 2021-10-22T19:22:31-04:00 WorkWrap: `isRecDataCon` should not eta-reduce NewTyCon field tys (#20539) In #20539 we had a type ```hs newtype Measured a = Measured { unmeasure :: () -> a } ``` and `isRecDataCon Measured` recursed into `go_arg_ty` for `(->) ()`, because `unwrapNewTyConEtad_maybe` eta-reduced it. That triggered an assertion error a bit later. Eta reducing the field type is completely wrong to do here! Just call `unwrapNewTyCon_maybe` instead. Fixes #20539 and adds a regression test T20539. - - - - - 8300ca2e by Ben Gamari at 2021-10-24T01:26:11-04:00 driver: Export wWarningFlagMap A new feature requires Ghcide to be able to convert warnings to CLI flags (WarningFlag -> String). This is most easily implemented in terms of the internal function flagSpecOf, which uses an inefficient implementation based on linear search through a linked list. This PR derives Ord for WarningFlag, and replaces that list with a Map. Closes #19087. - - - - - 3bab222c by Sebastian Graf at 2021-10-24T01:26:46-04:00 DmdAnal: Implement Boxity Analysis (#19871) This patch fixes some abundant reboxing of `DynFlags` in `GHC.HsToCore.Match.Literal.warnAboutOverflowedLit` (which was the topic of #19407) by introducing a Boxity analysis to GHC, done as part of demand analysis. This allows to accurately capture ad-hoc unboxing decisions previously made in worker/wrapper in demand analysis now, where the boxity info can propagate through demand signatures. See the new `Note [Boxity analysis]`. The actual fix for #19407 is described in `Note [No lazy, Unboxed demand in demand signature]`, but `Note [Finalising boxity for demand signature]` is probably a better entry-point. To support the fix for #19407, I had to change (what was) `Note [Add demands for strict constructors]` a bit (now `Note [Unboxing evaluated arguments]`). In particular, we now take care of it in `finaliseBoxity` (which is only called from demand analaysis) instead of `wantToUnboxArg`. I also had to resurrect `Note [Product demands for function body]` and rename it to `Note [Unboxed demand on function bodies returning small products]` to avoid huge regressions in `join004` and `join007`, thereby fixing #4267 again. See the updated Note for details. A nice side-effect is that the worker/wrapper transformation no longer needs to look at strictness info and other bits such as `InsideInlineableFun` flags (needed for `Note [Do not unbox class dictionaries]`) at all. It simply collects boxity info from argument demands and interprets them with a severely simplified `wantToUnboxArg`. All the smartness is in `finaliseBoxity`, which could be moved to DmdAnal completely, if it wasn't for the call to `dubiousDataConInstArgTys` which would be awkward to export. I spent some time figuring out the reason for why `T16197` failed prior to my amendments to `Note [Unboxing evaluated arguments]`. After having it figured out, I minimised it a bit and added `T16197b`, which simply compares computed strictness signatures and thus should be far simpler to eyeball. The 12% ghc/alloc regression in T11545 is because of the additional `Boxity` field in `Poly` and `Prod` that results in more allocation during `lubSubDmd` and `plusSubDmd`. I made sure in the ticky profiles that the number of calls to those functions stayed the same. We can bear such an increase here, as we recently improved it by -68% (in b760c1f). T18698* regress slightly because there is more unboxing of dictionaries happening and that causes Lint (mostly) to allocate more. Fixes #19871, #19407, #4267, #16859, #18907 and #13331. Metric Increase: T11545 T18698a T18698b Metric Decrease: T12425 T16577 T18223 T18282 T4267 T9961 - - - - - 691c450f by Alan Zimmerman at 2021-10-24T01:27:21-04:00 EPA: Use LocatedA for ModuleName This allows us to use an Anchor with a DeltaPos in it when exact printing. - - - - - 3417a81a by Joachim Breitner at 2021-10-24T01:27:57-04:00 undefined: Neater CallStack in error message Users of `undefined` don’t want to see ``` files.hs: Prelude.undefined: CallStack (from HasCallStack): error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err undefined, called at file.hs:151:19 in main:Main ``` but want to see ``` files.hs: Prelude.undefined: CallStack (from HasCallStack): undefined, called at file.hs:151:19 in main:Main ``` so let’s make that so. The function for that is `withFrozenCallStack`, but that is not usable here (module dependencies, and also not representation-polymorphic). And even if it were, it could confuse GHC’s strictness analyzer, leading to big regressions in some perf tests (T10421 in particular). So after shuffling modules and definitions around, I eventually noticed that the easiest way is to just not call `error` here. Fixes #19886 - - - - - 98aa29d3 by John Ericson at 2021-10-24T01:28:33-04:00 Fix dangling reference to RtsConfig.h It hasn't existed since a2a67cd520b9841114d69a87a423dabcb3b4368e -- in 2009! - - - - - 9cde38a0 by John Ericson at 2021-10-25T17:45:15-04:00 Remove stray reference to `dist-ghcconstants` I think this hasn't been a thing since 86054b4ab5125a8b71887b06786d0a428539fb9c, almost 10 years ago! - - - - - 0f7541dc by Viktor Dukhovni at 2021-10-25T17:45:51-04:00 Tweak descriptions of lines and unlines It seems more clear to think of lines as LF-terminated rather than LF-separated. - - - - - 0255ef38 by Zubin Duggal at 2021-10-26T12:36:24-04:00 Warn if unicode bidirectional formatting characters are found in the source (#20263) - - - - - 9cc6c193 by sheaf at 2021-10-26T12:37:02-04:00 Don't default type variables in type families This patch removes the following defaulting of type variables in type and data families: - type variables of kind RuntimeRep defaulting to LiftedRep - type variables of kind Levity defaulting to Lifted - type variables of kind Multiplicity defaulting to Many It does this by passing "defaulting options" to the `defaultTyVars` function; when calling from `tcTyFamInstEqnGuts` or `tcDataFamInstHeader` we pass options that avoid defaulting. This avoids wildcards being defaulted, which caused type families to unexpectedly fail to reduce. Note that kind defaulting, applicable only with -XNoPolyKinds, is not changed by this patch. Fixes #17536 ------------------------- Metric Increase: T12227 ------------------------- - - - - - cc113616 by Artyom Kuznetsov at 2021-10-26T20:27:33+00:00 Change CaseAlt and LambdaExpr to FunRhs in deriving Foldable and Traversable (#20496) - - - - - 9bd6daa4 by John Ericson at 2021-10-27T13:29:39-04:00 Make build system: Generalize and/or document distdirs `manual-package-config` should not hard-code the distdir, and no longer does Elsewhere, we must continue to hard-code due to inconsitent distdir names across stages, so we document this referring to the existing note "inconsistent distdirs". - - - - - 9d577ea1 by John Ericson at 2021-10-27T13:30:15-04:00 Compiler dosen't need to know about certain settings from file - RTS and libdw - SMP - RTS ways I am leaving them in the settings file because `--info` currently prints all the fields in there, but in the future I do believe we should separate the info GHC actually needs from "extra metadata". The latter could go in `+RTS --info` and/or a separate file that ships with the RTS for compile-time inspection instead. - - - - - ed9ec655 by Ben Gamari at 2021-10-27T13:30:55-04:00 base: Note export of Data.Tuple.Solo in changelog - - - - - 638f6548 by Ben Gamari at 2021-10-27T13:30:55-04:00 hadrian: Turn the `static` flavour into a transformer This turns the `static` flavour into the `+fully_static` flavour transformer. - - - - - 522eab3f by Ziyang Liu at 2021-10-29T05:01:50-04:00 Show family TyCons in mk_dict_error in the case of a single match - - - - - 71700526 by Sebastian Graf at 2021-10-29T05:02:25-04:00 Add more INLINABLE and INLINE pragmas to `Enum Int*` instances Otherwise the instances aren't good list producers. See Note [Stable Unfolding for list producers]. - - - - - 925c47b4 by Sebastian Graf at 2021-10-29T05:02:25-04:00 WorkWrap: Update Unfolding with WW'd body prior to `tryWW` (#20510) We have a function in #20510 that is small enough to get a stable unfolding in WW: ```hs small :: Int -> Int small x = go 0 x where go z 0 = z * x go z y = go (z+y) (y-1) ``` But it appears we failed to use the WW'd RHS as the stable unfolding. As a result, inlining `small` would expose the non-WW'd version of `go`. That appears to regress badly in #19727 which is a bit too large to extract a reproducer from that is guaranteed to reproduce across GHC versions. The solution is to simply update the unfolding in `certainlyWillInline` with the WW'd RHS. Fixes #20510. - - - - - 7b67724b by John Ericson at 2021-10-29T16:57:48-04:00 make build system: RTS should use dist-install not dist This is the following find and replace: - `rts/dist` -> `rts/dist-install` # for paths - `rts_dist` -> `rts_dist-install` # for make rules and vars - `,dist` -> `,dist-install` # for make, just in rts/ghc.mk` Why do this? Does it matter when the RTS is just built once? The answer is, yes, I think it does, because I want the distdir--stage correspondence to be consistent. In particular, for #17191 and continuing from d5de970dafd5876ef30601697576167f56b9c132 I am going to make the headers (`rts/includes`) increasingly the responsibility of the RTS (hence their new location). However, those headers are current made for multiple stages. This will probably become unnecessary as work on #17191 progresses and the compiler proper becomes more of a freestanding cabal package (e.g. a library that can be downloaded from Hackage and built without any autoconf). However, until that is finished, we have will transitional period where the RTS and headers need to agree on dirs for multiple stages. I know the make build system is going away, but it's not going yet, so I need to change it to unblock things :). - - - - - b0a1ed55 by Sylvain Henry at 2021-10-29T16:58:35-04:00 Add test for T15547 (#15547) Fix #15547 - - - - - c8d89f62 by Sylvain Henry at 2021-10-29T16:58:35-04:00 Bignum: add missing rule Add missing "Natural -> Integer -> Word#" rule. - - - - - 2a4581ff by sheaf at 2021-10-29T16:59:13-04:00 User's guide: data family kind-inference changes Explain that the kind of a data family instance must now be fully determined by the header of the instance, and how one might migrate code to account for this change. Fixes #20527 - - - - - ea862ef5 by Ben Gamari at 2021-10-30T15:43:28-04:00 ghci: Make getModBreaks robust against DotO Unlinked Previously getModBreaks assumed that an interpreted linkable will have only a single `BCOs` `Unlinked` entry. However, in general an object may also contain `DotO`s; ignore these. Fixes #20570. - - - - - e4095c0c by John Ericson at 2021-10-31T09:04:41-04:00 Make build system: Put make generated include's in RTS distdirs These are best thought of as being part of the RTS. - After !6791, `ghcautoconf.h` won't be used by the compiler inappropriately. - `ghcversion.h` is only used once outside the RTS, which is `compiler/cbits/genSym.c`. Except we *do* mean the RTS GHC is built against there, so it's better if we always get get the installed version. - `ghcplatform.h` alone is used extensively outside the RTS, but since we no longer have a target platform it is perfectly safe/correct to get the info from the previous RTS. All 3 are exported from the RTS currently and in the bootstrap window. This commit just swaps directories around, such that the new headers may continue to be used in stage 0 despite the reasoning above, but the idea is that we can subsequently make more interesting changes doubling down on the reasoning above. In particular, in !6803 we'll start "morally" moving `ghcautonconf.h` over, introducing an RTS configure script and temporary header of its `AC_DEFINE`s until the top-level configure script doesn't define any more. Progress towards #17191 - - - - - f5471c0b by John Ericson at 2021-10-31T09:05:16-04:00 Modularize autoconf platform detection This will allow better reuse of it, such as in the upcoming RTS configure script. Progress towards #17191 - - - - - 6b38c8a6 by Ben Gamari at 2021-10-31T09:05:52-04:00 ghc: Bump Cabal-Version to 1.22 This is necessary to use reexported-modules - - - - - 6544446d by Ben Gamari at 2021-10-31T09:05:52-04:00 configure: Hide error output from --target check - - - - - 7445bd71 by Andreas Klebinger at 2021-11-01T12:13:45+00:00 Update comment in Lint.hs mkWwArgs has been renamed to mkWorkerArgs. - - - - - f1a782dd by Vladislav Zavialov at 2021-11-02T01:36:32-04:00 HsToken for let/in (#19623) One more step towards the new design of EPA. - - - - - 37a37139 by John Ericson at 2021-11-02T01:37:08-04:00 Separate some AC_SUBST / AC_DEFINE Eventually, the RTS configure alone will need the vast majority of AC_DEFINE, and the top-level configure will need the most AC_SUBST. By removing the "side effects" of the macros like this we make them more reusable so they can be shared between the two configures without doing too much. - - - - - 2f69d102 by John Ericson at 2021-11-02T01:37:43-04:00 Remove `includes_GHCCONSTANTS` from make build system It is dead code. - - - - - da1a8e29 by John Ericson at 2021-11-02T01:37:43-04:00 Treat generated RTS headers in a more consistent manner We can depend on all of them at once the same way. - - - - - a7e1be3d by Ryan Scott at 2021-11-02T01:38:53-04:00 Fix #20590 with another application of mkHsContextMaybe We were always converting empty GADT contexts to `Just []` in `GHC.ThToHs`, which caused the pretty-printer to always print them as `() => ...`. This is easily fixed by using the `mkHsContextMaybe` function when converting GADT contexts so that empty contexts are turned to `Nothing`. This is in the same tradition established in commit 4c87a3d1d14f9e28c8aa0f6062e9c4201f469ad7. In the process of fixing this, I discovered that the `Cxt` argument to `mkHsContextMaybe` is completely unnecessary, as we can just as well check if the `LHsContext GhcPs` argument is empty. Fixes #20590. - - - - - 39eed84c by Alan Zimmerman at 2021-11-02T21:39:32+00:00 EPA: Get rid of bare SrcSpan's in the ParsedSource The ghc-exactPrint library has had to re-introduce the relatavise phase. This is needed if you change the length of an identifier and want the layout to be preserved afterwards. It is not possible to relatavise a bare SrcSpan, so introduce `SrcAnn NoEpAnns` for them instead. Updates haddock submodule. - - - - - 9f42a6dc by ARATA Mizuki at 2021-11-03T09:19:17-04:00 hadrian: Use $bindir instead of `dirname $0` in ghci wrapper `dirname $0` doesn't work when the wrapper is called via a symbolic link. Fix #20589 - - - - - bf6f96a6 by Vladislav Zavialov at 2021-11-03T16:35:50+03:00 Generalize the type of wrapLocSndMA - - - - - 1419fb16 by Matthew Pickering at 2021-11-04T00:36:09-04:00 ci: Don't run alpine job in fast-ci - - - - - 6020905a by Takenobu Tani at 2021-11-04T09:40:42+00:00 Correct load_load_barrier for risc-v This patch corrects the instruction for load_load_barrier(). Current load_load_barrier() incorrectly uses `fence w,r`. It means a store-load barrier. See also linux-kernel's smp_rmb() implementation: https://github.com/torvalds/linux/blob/v5.14/arch/riscv/include/asm/barrier.h#L27 - - - - - 086e288c by Richard Eisenberg at 2021-11-04T13:04:44-04:00 Tiny renamings and doc updates Close #20433 - - - - - f0b920d1 by CarrieMY at 2021-11-05T05:30:13-04:00 Fix deferOutOfScopeVariables for qualified #20472 - - - - - 59dfb005 by Simon Peyton Jones at 2021-11-05T05:30:48-04:00 Remove record field from Solo Ticket #20562 revealed that Solo, which is a wired-in TyCon, had a record field that wasn't being added to the type env. Why not? Because wired-in TyCons don't have record fields. It's not hard to change that, but it's tiresome for this one use-case, and it seems easier simply to make `getSolo` into a standalone function. On the way I refactored the handling of Solo slightly, to put it into wiredInTyCons (where it belongs) rather than only in knownKeyNames - - - - - be3750a5 by Matthew Pickering at 2021-11-05T10:12:16-04:00 Allow CApi FFI calls in GHCi At some point in the past this started working. I noticed this when working on multiple home units and couldn't load GHC's dependencies into the interpreter. Fixes #7388 - - - - - d96ce59d by John Ericson at 2021-11-05T10:12:52-04:00 make: Futher systematize handling of generated headers This will make it easier to add and remove generated headers, as we will do when we add a configure script for the RTS. - - - - - 3645abac by John Ericson at 2021-11-05T20:25:32-04:00 Avoid GHC_STAGE and other include bits We should strive to make our includes in terms of the RTS as much as possible. One place there that is not possible, the llvm version, we make a new tiny header Stage numbers are somewhat arbitrary, if we simple need a newer RTS, we should say so. - - - - - 4896a6a6 by Matthew Pickering at 2021-11-05T20:26:07-04:00 Fix boolean confusion with Opt_NoLlvmMangler flag I accidently got the two branches of the if expression the wrong way around when refactoring. Fixes #20567 - - - - - d74cc01e by Ziyang Liu at 2021-11-06T07:53:06-04:00 Export `withTcPlugins` and `withHoleFitPlugins` - - - - - ecd6d142 by Sylvain Henry at 2021-11-06T07:53:42-04:00 i386: fix codegen of 64-bit comparisons - - - - - e279ea64 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Add missing Int64/Word64 constant-folding rules - - - - - 4c86df25 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Fix Int64ToInt/Word64ToWord rules on 32-bit architectures When the input literal was larger than 32-bit it would crash in a compiler with assertion enabled because it was creating an out-of-bound word-sized literal (32-bit). - - - - - 646c3e21 by Sylvain Henry at 2021-11-06T07:53:42-04:00 CI: allow perf-nofib to fail - - - - - 20956e57 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Remove target dependent CPP for Word64/Int64 (#11470) Primops types were dependent on the target word-size at *compiler* compilation time. It's an issue for multi-target as GHC may not have the correct primops types for the target. This patch fixes some primops types: if they take or return fixed 64-bit values they now always use `Int64#/Word64#`, even on 64-bit architectures (where they used `Int#/Word#` before). Users of these primops may now need to convert from Int64#/Word64# to Int#/Word# (a no-op at runtime). This is a stripped down version of !3658 which goes the all way of changing the underlying primitive types of Word64/Int64. This is left for future work. T12545 allocations increase ~4% on some CI platforms and decrease ~3% on AArch64. Metric Increase: T12545 Metric Decrease: T12545 - - - - - 2800eee2 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Make Word64 use Word64# on every architecture - - - - - be9d7862 by Sylvain Henry at 2021-11-06T07:53:42-04:00 Fix Int64/Word64's Enum instance fusion Performance improvement: T15185(normal) run/alloc 51112.0 41032.0 -19.7% GOOD Metric Decrease: T15185 - - - - - 6f2d6a5d by Nikolay Yakimov at 2021-11-06T11:24:50-04:00 Add regression test for #20568 GHC produced broken executables with rebindable if and -fhpc if `ifThenElse` expected non-Bool condition until GHC 9.0. This adds a simple regression test. - - - - - 7045b783 by Vladislav Zavialov at 2021-11-06T11:25:25-04:00 Refactor HdkM using deriving via * No more need for InlineHdkM, mkHdkM * unHdkM is now just a record selector * Update comments - - - - - 0d8a883e by Andreas Klebinger at 2021-11-07T12:54:30-05:00 Don't undersaturate join points through eta-reduction. In #20599 I ran into an issue where the unfolding for a join point was eta-reduced removing the required lambdas. This patch adds guards that should prevent this from happening going forward. - - - - - 3d7e3d91 by Vladislav Zavialov at 2021-11-07T12:55:05-05:00 Print the Type kind qualified when ambiguous (#20627) The Type kind is printed unqualified: ghci> :set -XNoStarIsType ghci> :k (->) (->) :: Type -> Type -> Type This is the desired behavior unless the user has defined their own Type: ghci> data Type Then we want to resolve the ambiguity by qualification: ghci> :k (->) (->) :: GHC.Types.Type -> GHC.Types.Type -> GHC.Types.Type - - - - - 184f6bc6 by John Ericson at 2021-11-07T16:26:10-05:00 Factor out unregisterised and tables next to code m4 macros These will be useful for upcoming RTS configure script. - - - - - 56705da8 by Sebastian Graf at 2021-11-07T16:26:46-05:00 Pmc: Do inhabitation test for unlifted vars (#20631) Although I thought we were already set to handle unlifted datatypes correctly, it appears we weren't. #20631 showed that it's wrong to assume `vi_bot=IsNotBot` for `VarInfo`s of unlifted types from their inception if we don't follow up with an inhabitation test to see if there are any habitable constructors left. We can't trigger the test from `emptyVarInfo`, so now we instead fail early in `addBotCt` for variables of unlifted types. Fixed #20631. - - - - - 28334b47 by sheaf at 2021-11-08T13:40:05+01:00 Default kind vars in tyfams with -XNoPolyKinds We should still default kind variables in type families in the presence of -XNoPolyKinds, to avoid suggesting enabling -XPolyKinds just because the function arrow introduced kind variables, e.g. type family F (t :: Type) :: Type where F (a -> b) = b With -XNoPolyKinds, we should still default `r :: RuntimeRep` in `a :: TYPE r`. Fixes #20584 - - - - - 3f103b1a by John Ericson at 2021-11-08T19:35:12-05:00 Factor out GHC_ADJUSTORS_METHOD m4 macro - - - - - ba9fdc51 by John Ericson at 2021-11-08T19:35:12-05:00 Factor out FP_FIND_LIBFFI and use in RTS configure too - - - - - 2929850f by Sylvain Henry at 2021-11-09T10:02:06-05:00 RTS: open timerfd synchronously (#20618) - - - - - bc498fdf by Sylvain Henry at 2021-11-09T10:02:46-05:00 Bignum: expose backendName (#20495) - - - - - 79a26df1 by Sylvain Henry at 2021-11-09T10:02:46-05:00 Don't expose bignum backend in ghc --info (#20495) GHC is bignum backend agnostic and shouldn't report this information as in the future ghc-bignum will be reinstallable potentially with a different backend that GHC is unaware of. Moreover as #20495 shows the returned information may be wrong currently. - - - - - e485f4f2 by Andreas Klebinger at 2021-11-09T19:54:31-05:00 SpecConstr - Attach evaldUnfolding to known evaluated arguments. - - - - - 983a99f0 by Ryan Scott at 2021-11-09T19:55:07-05:00 deriving: infer DatatypeContexts from data constructors, not type constructor Previously, derived instances that use `deriving` clauses would infer `DatatypeContexts` by using `tyConStupidTheta`. But this sometimes causes redundant constraints to be included in the derived instance contexts, as the constraints that appear in the `tyConStupidTheta` may not actually appear in the types of the data constructors (i.e., the `dataConStupidTheta`s). For instance, in `data Show a => T a = MkT deriving Eq`, the type of `MkT` does not require `Show`, so the derived `Eq` instance should not require `Show` either. This patch makes it so with some small tweaks to `inferConstraintsStock`. Fixes #20501. - - - - - bdd7b2be by Ryan Scott at 2021-11-09T19:55:07-05:00 Flesh out Note [The stupid context] and reference it `Note [The stupid context]` in `GHC.Core.DataCon` talks about stupid contexts from `DatatypeContexts`, but prior to this commit, it was rather outdated. This commit spruces it up and references it from places where it is relevant. - - - - - 95563259 by Li-yao Xia at 2021-11-10T09:16:21-05:00 Fix rendering of Applicative law - - - - - 0f852244 by Viktor Dukhovni at 2021-11-10T09:16:58-05:00 Improve ZipList section of Traversable overview - Fix cut/paste error by adding missing `c` pattern in `Vec3` traversable instance. - Add a bit of contextual prose above the Vec2/Vec3 instance sample code. - - - - - c4cd13b8 by Richard Eisenberg at 2021-11-10T18:18:19-05:00 Fix Note [Function types] Close #19938. - - - - - dfb9913c by sheaf at 2021-11-10T18:18:59-05:00 Improvements to rank_polymorphism.rst - rename the function f4 to h1 for consistency with the naming convention - be more explicit about the difference between `Int -> (forall a. a -> a)` and `forall a. Int -> (a -> a)` - reorder the section to make it flow better Fixes #20585 - - - - - 1540f556 by sheaf at 2021-11-10T18:19:37-05:00 Clarify hs-boot file default method restrictions The user guide wrongly stated that default methods should not be included in hs-boot files. In fact, if the class is not left abstract (no methods, no superclass constraints, ...) then the defaults must be provided and match with those given in the .hs file. We add some tests for this, as there were no tests in the testsuite that gave rise to the "missing default methods" error. Fixes #20588 - - - - - 8c0aec38 by Sylvain Henry at 2021-11-10T18:20:17-05:00 Hadrian: fix building/registering of .dll libraries - - - - - 11c9a469 by Matthew Pickering at 2021-11-11T07:21:28-05:00 testsuite: Convert hole fit performance tests into proper perf tests Fixes #20621 - - - - - c2ed85cb by Matthew Pickering at 2021-11-11T07:22:03-05:00 driver: Cache the transitive dependency calculation in ModuleGraph Two reasons for this change: 1. Avoid computing the transitive dependencies when compiling each module, this can save a lot of repeated work. 2. More robust to forthcoming changes to support multiple home units. - - - - - 4230e4fb by Matthew Pickering at 2021-11-11T07:22:03-05:00 driver: Use shared transitive dependency calculation in hptModulesBelow This saves a lot of repeated work on big dependency graphs. ------------------------- Metric Decrease: MultiLayerModules T13719 ------------------------- - - - - - af653b5f by Matthew Bauer at 2021-11-11T07:22:39-05:00 Only pass -pie, -no-pie when linking Previously, these flags were passed when both compiling and linking code. However, `-pie` and `-no-pie` are link-time-only options. Usually, this does not cause issues, but when using Clang with `-Werror` set results in errors: clang: error: argument unused during compilation: '-nopie' [-Werror,-Wunused-command-line-argument] This is unused by Clang because this flag has no effect at compile time (it’s called `-nopie` internally by Clang but called `-no-pie` in GHC for compatibility with GCC). Just passing these flags at linking time resolves this. Additionally, update #15319 hack to look for `-pgml` instead. Because of the main change, the value of `-pgmc` does not matter when checking for the workaround of #15319. However, `-pgml` *does* still matter as not all `-pgml` values support `-no-pie`. To cover all potential values, we assume that no custom `-pgml` values support `-no-pie`. This means that we run the risk of not using `-no-pie` when it is otherwise necessary for in auto-hardened toolchains! This could be a problem at some point, but this workaround was already introduced in 8d008b71 and we might as well continue supporting it. Likewise, mark `-pgmc-supports-no-pie` as deprecated and create a new `-pgml-supports-no-pie`. - - - - - 7cc6ebdf by Sebastian Graf at 2021-11-11T07:23:14-05:00 Add regression test for #20598 Fixes #20598, which is mostly a duplicate of #18824 but for GHC 9.2. - - - - - 7b44c816 by Simon Jakobi at 2021-11-12T21:20:17-05:00 Turn GHC.Data.Graph.Base.Graph into a newtype - - - - - a57cc754 by John Ericson at 2021-11-12T21:20:52-05:00 Make: Do not generate ghc.* headers in stage0 GHC should get everything it needs from the RTS, which for stage0 is the "old" RTS that comes from the bootstrap compiler. - - - - - 265ead8a by Richard Eisenberg at 2021-11-12T21:21:27-05:00 Improve redundant-constraints warning Previously, we reported things wrong with f :: (Eq a, Ord a) => a -> Bool f x = x == x saying that Eq a was redundant. This is fixed now, along with some simplification in Note [Replacement vs keeping]. There's a tiny bit of extra complexity in setImplicationStatus, but it's explained in Note [Tracking redundant constraints]. Close #20602 - - - - - ca90ffa3 by Richard Eisenberg at 2021-11-12T21:21:27-05:00 Use local instances with least superclass depth See new Note [Use only the best local instance] in GHC.Tc.Solver.Interact. This commit also refactors the InstSC/OtherSC mechanism slightly. Close #20582. - - - - - dfc4093c by Vladislav Zavialov at 2021-11-12T21:22:03-05:00 Implement -Wforall-identifier (#20609) In accordance with GHC Proposal #281 "Visible forall in types of terms": For three releases before this change takes place, include a new warning -Wforall-identifier in -Wdefault. This warning will be triggered at definition sites (but not use sites) of forall as an identifier. Updates the haddock submodule. - - - - - 4143bd21 by Cheng Shao at 2021-11-12T21:22:39-05:00 hadrian: use /bin/sh in timeout wrapper /usr/bin/env doesn't work within a nix build. - - - - - 43cab5f7 by Simon Peyton Jones at 2021-11-12T21:23:15-05:00 Get the in-scope set right in simplArg This was a simple (but long standing) error in simplArg, revealed by #20639 - - - - - 578b8b48 by Ben Gamari at 2021-11-12T21:23:51-05:00 gitlab-ci: Allow draft MRs to fail linting jobs Addresses #20623 by allowing draft MRs to fail linting jobs. - - - - - 908e49fa by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - 05166660 by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - e41cffb0 by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - cce3a025 by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - 4499db7d by Ben Gamari at 2021-11-12T21:23:51-05:00 Fix it - - - - - dd1be88b by Travis Whitaker at 2021-11-12T21:24:29-05:00 mmapForLinkerMarkExecutable: do nothing when len = 0 - - - - - 4c6ace75 by John Ericson at 2021-11-12T21:25:04-05:00 Delete compiler/MachDeps.h This was accidentally added back in 28334b475a109bdeb8d53d58c48adb1690e2c9b4 after it is was no longer needed by the compiler proper in 20956e5784fe43781d156dd7ab02f0bff4ab41fb. - - - - - 490e8c75 by John Ericson at 2021-11-12T21:25:40-05:00 Generate ghcversion.h with the top-level configure This is, rather unintuitively, part of the goal of making the packages that make of the GHC distribution more freestanding. `ghcversion.h` is very simple, so we easily can move it out of the main build systems (make and Hadrian). By doing so, the RTS becomes less of a special case to those build systems as the header, already existing in the source tree, appears like any other. We could do this with the upcomming RTS configure, but it hardly matters because there is nothing platform-specific here, it is just versioning information like the other files the top-level configure can be responsible for. - - - - - bba156f3 by John Ericson at 2021-11-12T21:26:15-05:00 Remove bit about size_t in ghc-llvm-version.h This shouldn't be here. It wasn't causing a problem because this header was only used from Haskell, but still. - - - - - 0b1da2f1 by John Ericson at 2021-11-12T21:26:50-05:00 Make: Install RTS headers in `$libdir/rts/include` not `$libdir/include` Before we were violating the convention of every other package. This fixes that. It matches the changes made in d5de970dafd5876ef30601697576167f56b9c132 to the location of the files in the repo. - - - - - b040d0d4 by Sebastian Graf at 2021-11-12T21:27:26-05:00 Add regression test for #20663 - - - - - c6065292 by John Ericson at 2021-11-12T21:28:02-05:00 Make: Move remaining built RTS headers to ...build/include This allows us to clean up the rts include dirs in the package conf. - - - - - aa372972 by Ryan Scott at 2021-11-15T10:17:57-05:00 Refactoring: Consolidate some arguments with DerivInstTys Various functions in GHC.Tc.Deriv.* were passing around `TyCon`s and `[Type]`s that ultimately come from the same `DerivInstTys`. This patch moves the definition of `DerivInstTys` to `GHC.Tc.Deriv.Generate` so that all of these `TyCon` and `[Type]` arguments can be consolidated into a single `DerivInstTys`. Not only does this make the code easier to read (in my opinion), this will also be important in a subsequent commit where we need to add another field to `DerivInstTys` that will also be used from `GHC.Tc.Deriv.Generate` and friends. - - - - - 564a19af by Ryan Scott at 2021-11-15T10:17:57-05:00 Refactoring: Move DataConEnv to GHC.Core.DataCon `DataConEnv` will prove to be useful in another place besides `GHC.Core.Opt.SpecConstr` in a follow-up commit. - - - - - 3e5f0595 by Ryan Scott at 2021-11-15T10:17:57-05:00 Instantiate field types properly in stock-derived instances Previously, the `deriving` machinery was very loosey-goosey about how it used the types of data constructor fields when generating code. It would usually just consult `dataConOrigArgTys`, which returns the _uninstantiated_ field types of each data constructor. Usually, you can get away with this, but issues #20375 and #20387 revealed circumstances where this approach fails. Instead, when generated code for a stock-derived instance `C (T arg_1 ... arg_n)`, one must take care to instantiate the field types of each data constructor with `arg_1 ... arg_n`. The particulars of how this is accomplished is described in the new `Note [Instantiating field types in stock deriving]` in `GHC.Tc.Deriv.Generate`. Some highlights: * `DerivInstTys` now has a new `dit_dc_inst_arg_env :: DataConEnv [Type]` field that caches the instantiated field types of each data constructor. Whenever we need to consult the field types somewhere in `GHC.Tc.Deriv.*` we avoid using `dataConOrigArgTys` and instead look it up in `dit_dc_inst_arg_env`. * Because `DerivInstTys` now stores the instantiated field types of each constructor, some of the details of the `GHC.Tc.Deriv.Generics.mkBindsRep` function were able to be simplified. In particular, we no longer need to apply a substitution to instantiate the field types in a `Rep(1)` instance, as that is already done for us by `DerivInstTys`. We still need a substitution to implement the "wrinkle" section of `Note [Generating a correctly typed Rep instance]`, but the code is nevertheless much simpler than before. * The `tyConInstArgTys` function has been removed in favor of the new `GHC.Core.DataCon.dataConInstUnivs` function, which is really the proper tool for the job. `dataConInstUnivs` is much like `tyConInstArgTys` except that it takes a data constructor, not a type constructor, as an argument, and it adds extra universal type variables from that data constructor at the end of the returned list if need be. `dataConInstUnivs` takes care to instantiate the kinds of the universal type variables at the end, thereby avoiding a bug in `tyConInstArgTys` discovered in https://gitlab.haskell.org/ghc/ghc/-/issues/20387#note_377037. Fixes #20375. Fixes #20387. - - - - - 25d36c31 by John Ericson at 2021-11-15T10:18:32-05:00 Make: Get rid of GHC_INCLUDE_DIRS These dirs should not be included in all stages. Instead make the per-stage `BUILD_*_INCLUDE_DIR` "plural" to insert `rts/include` in the right place. - - - - - b679721a by John Ericson at 2021-11-15T10:18:32-05:00 Delete dead code knobs for building GHC itself As GHC has become target agnostic, we've left behind some now-useless logic in both build systems. - - - - - 3302f42a by Sylvain Henry at 2021-11-15T13:19:42-05:00 Fix windres invocation I've already fixed this 7 months ago in the comments of #16780 but it never got merged. Now we need this for #20657 too. - - - - - d9f54905 by Sylvain Henry at 2021-11-15T13:19:42-05:00 Hadrian: fix windows cross-build (#20657) Many small things to fix: * Hadrian: platform triple is "x86_64-w64-mingw32" and this wasn't recognized by Hadrian (note "w64" instead of "unknown") * Hadrian was using the build platform ("isWindowsHost") to detect the use of the Windows toolchain, which was wrong. We now use the "targetOs" setting. * Hadrian was doing the same thing for Darwin so we fixed both at once, even if cross-compilation to Darwin is unlikely to happen afaik (cf "osxHost" vs "osxTarget" changes) * Hadrian: libffi name was computed in two different places and one of them wasn't taking the different naming on Windows into account. * Hadrian was passing "-Irts/include" when building the stage1 compiler leading to the same error as in #18143 (which is using make). stage1's RTS is stage0's one so mustn't do this. * Hadrian: Windows linker doesn't seem to support "-zorigin" so we don't pass it (similarly to Darwin) * Hadrian: hsc2hs in cross-compilation mode uses a trick (taken from autoconf): it defines "static int test_array[SOME_EXPR]" where SOME_EXPR is a constant expression. However GCC reports an error because SOME_EXPR is supposedly not constant. This is fixed by using another method enabled with the `--via-asm` flag of hsc2hs. It has been fixed in `make` build system (5f6fcf7808b16d066ad0fb2068225b3f2e8363f7) but not in Hadrian. * Hadrian: some packages are specifically built only on Windows but they shouldn't be when building a cross-compiler (`touchy` and `ghci-wrapper`). We now correctly detect this case and disable these packages. * Base: we use `iNVALID_HANDLE_VALUE` in a few places. It fixed some hsc2hs issues before we switched to `--via-asm` (see above). I've kept these changes are they make the code nicer. * Base: `base`'s configure tries to detect if it is building for Windows but for some reason the `$host_alias` value is `x86_64-windows` in my case and it wasn't properly detected. * Base: libraries/base/include/winio_structs.h imported "Windows.h" with a leading uppercase. It doesn't work on case-sensitive systems when cross-compiling so we have to use "windows.h". * RTS: rts/win32/ThrIOManager.c was importin "rts\OSThreads.h" but this path isn't valid when cross-compiling. We replaced "\" with "/". * DeriveConstants: this tool derives the constants from the target RTS header files. However these header files define `StgAsyncIOResult` only when `mingw32_HOST_OS` is set hence it seems we have to set it explicitly. Note that deriveConstants is called more than once (why? there is only one target for now so it shouldn't) and in the second case this value is correctly defined (probably coming indirectly from the import of "rts/PosixSource.h"). A better fix would probably be to disable the unneeded first run of deriveconstants. - - - - - cc635da1 by Richard Eisenberg at 2021-11-15T13:20:18-05:00 Link to ghc-proposals repo from README A potential contributor said that they weren't aware of ghc-proposals. This might increase visibility. - - - - - a8e1a756 by Ben Gamari at 2021-11-16T03:12:34-05:00 gitlab-ci: Refactor toolchain provision This makes it easier to invoke ci.sh on Darwin by teaching it to manage the nix business. - - - - - 1f0014a8 by Ben Gamari at 2021-11-16T03:12:34-05:00 gitlab-ci: Fail if dynamic references are found in a static bindist Previously we called error, which just prints an error, rather than fail, which actually fails. - - - - - 85f2c0ba by Ben Gamari at 2021-11-16T03:12:34-05:00 gitlab-ci/darwin: Move SDK path discovery into toolchain.nix Reduce a bit of duplication and a manual step when running builds manually. - - - - - 3e94b5a7 by John Ericson at 2021-11-16T03:13:10-05:00 Make: Get rid of `BUILD_.*_INCLUDE_DIRS` First, we improve some of the rules around -I include dirs, and CPP opts. Then, we just specify the RTS's include dirs normally (locally per the package and in the package conf), and then everything should work normally. The primops.txt.pp rule needs no extra include dirs at all, as it no longer bakes in a target platfom. Reverts some of the extra stage arguments I added in 05419e55cab272ed39790695f448b311f22669f7, as they are no longer needed. - - - - - 083a7583 by Ben Gamari at 2021-11-17T05:10:27-05:00 Increase type sharing Fixes #20541 by making mkTyConApp do more sharing of types. In particular, replace * BoxedRep Lifted ==> LiftedRep * BoxedRep Unlifted ==> UnliftedRep * TupleRep '[] ==> ZeroBitRep * TYPE ZeroBitRep ==> ZeroBitType In each case, the thing on the right is a type synonym for the thing on the left, declared in ghc-prim:GHC.Types. See Note [Using synonyms to compress types] in GHC.Core.Type. The synonyms for ZeroBitRep and ZeroBitType are new, but absolutely in the same spirit as the other ones. (These synonyms are mainly for internal use, though the programmer can use them too.) I also renamed GHC.Core.Ty.Rep.isVoidTy to isZeroBitTy, to be compatible with the "zero-bit" nomenclature above. See discussion on !6806. There is a tricky wrinkle: see GHC.Core.Types Note [Care using synonyms to compress types] Compiler allocation decreases by up to 0.8%. - - - - - 20a4f251 by Ben Gamari at 2021-11-17T05:11:03-05:00 hadrian: Factor out --extra-*-dirs=... pattern We repeated this idiom quite a few times. Give it a name. - - - - - 4cec6cf2 by Ben Gamari at 2021-11-17T05:11:03-05:00 hadrian: Ensure that term.h is in include search path terminfo now requires term.h but previously neither build system offered any way to add the containing directory to the include search path. Fix this in Hadrian. Also adds libnuma includes to global include search path as it was inexplicably missing earlier. - - - - - 29086749 by Sebastian Graf at 2021-11-17T05:11:38-05:00 Pmc: Don't case split on wildcard matches (#20642) Since 8.10, when formatting a pattern match warning, we'd case split on a wildcard match such as ```hs foo :: [a] -> [a] foo [] = [] foo xs = ys where (_, ys@(_:_)) = splitAt 0 xs -- Pattern match(es) are non-exhaustive -- In a pattern binding: -- Patterns not matched: -- ([], []) -- ((_:_), []) ``` But that's quite verbose and distracts from which part of the pattern was actually the inexhaustive one. We'd prefer a wildcard for the first pair component here, like it used to be in GHC 8.8. On the other hand, case splitting is pretty handy for `-XEmptyCase` to know the different constructors we could've matched on: ```hs f :: Bool -> () f x = case x of {} -- Pattern match(es) are non-exhaustive -- In a pattern binding: -- Patterns not matched: -- False -- True ``` The solution is to communicate that we want a top-level case split to `generateInhabitingPatterns` for `-XEmptyCase`, which is exactly what this patch arranges. Details in `Note [Case split inhabiting patterns]`. Fixes #20642. - - - - - c591ab1f by Sebastian Graf at 2021-11-17T05:11:38-05:00 testsuite: Refactor pmcheck all.T - - - - - 33c0c83d by Andrew Pritchard at 2021-11-17T05:12:17-05:00 Fix Haddock markup on Data.Type.Ord.OrdCond. - - - - - 7bcd91f4 by Andrew Pritchard at 2021-11-17T05:12:17-05:00 Provide in-line kind signatures for Data.Type.Ord.Compare. Haddock doesn't know how to render SAKS, so the only current way to make the documentation show the kind is to write what it should say into the type family declaration. - - - - - 16d86b97 by ARATA Mizuki at 2021-11-17T05:12:56-05:00 bitReverse functions in GHC.Word are since base-4.14.0.0, not 4.12.0.0 They were added in 33173a51c77d9960d5009576ad9b67b646dfda3c, which constitutes GHC 8.10.1 / base-4.14.0.0 - - - - - 7850142c by Morrow at 2021-11-17T11:14:37+00:00 Improve handling of import statements in GHCi (#20473) Currently in GHCi, when given a line of user input we: 1. Attempt to parse and handle it as a statement 2. Otherwise, attempt to parse and handle a single import 3. Otherwise, check if there are imports present (and if so display an error message) 4. Otherwise, attempt to parse a module and only handle the declarations This patch simplifies the process to: Attempt to parse and handle it as a statement Otherwise, attempt to parse a module and handle the imports and declarations This means that multiple imports in a multiline are now accepted, and a multiline containing both imports and declarations is now accepted (as well as when separated by semicolons). - - - - - 09d44b4c by Zubin Duggal at 2021-11-18T01:37:36-05:00 hadrian: add threadedDebug RTS way to devel compilers - - - - - 5fa45db7 by Zubin Duggal at 2021-11-18T01:37:36-05:00 testsuite: disable some tests when we don't have dynamic libraries - - - - - f8c1c549 by Matthew Pickering at 2021-11-18T01:38:11-05:00 Revert "base: Use one-shot kqueue on macOS" This reverts commit 41117d71bb58e001f6a2b6a11c9314d5b70b9182 - - - - - f55ae180 by Simon Peyton Jones at 2021-11-18T14:44:45-05:00 Add one line of comments (c.f. !5706) Ticket #19815 suggested changing coToMCo to use isReflexiveCo rather than isReflCo. But perf results weren't encouraging. This patch just adds a comment to point to the data, such as it is. - - - - - 12d023d1 by Vladislav Zavialov at 2021-11-18T14:45:20-05:00 testsuite: check for FlexibleContexts in T17563 The purpose of testsuite/tests/typecheck/should_fail/T17563.hs is to make sure we do validity checking on quantified constraints. In particular, see the following functions in GHC.Tc.Validity: * check_quant_pred * check_pred_help * check_class_pred The original bug report used a~b constraints as an example of a constraint that requires validity checking. But with GHC Proposal #371, equality constraints no longer require GADTs or TypeFamilies; instead, they require TypeOperators, which are checked earlier in the pipeline, in the renamer. Rather than simply remove this test, we change the example to use another extension: FlexibleContexts. Since we decide whether a constraint requires this extension in check_class_pred, the regression test continues to exercise the relevant code path. - - - - - 78d4bca0 by Ben Gamari at 2021-11-18T22:27:20-05:00 ghc-cabal, make: Add support for building C++ object code Co-Authored By: Matthew Pickering <matthew at well-typed.com> - - - - - a8b4961b by Ben Gamari at 2021-11-18T22:27:20-05:00 Bump Cabal submodule - - - - - 59e8a900 by Ben Gamari at 2021-11-18T22:27:20-05:00 Bump text and parsec submodules Accommodates text-2.0. Metric Decrease: T15578 - - - - - 7f7d7888 by Ben Gamari at 2021-11-18T22:27:20-05:00 ghc-cabal: Use bootstrap compiler's text package This avoids the need to build `text` without Cabal, in turn avoiding the need to reproduce the workaround for #20010 contained therein. - - - - - 048f8d96 by Ben Gamari at 2021-11-18T22:27:20-05:00 gitlab-ci: Bump MACOSX_DEPLOYMENT_TARGET It appears that Darwin's toolchain includes system headers in the dependency makefiles it generates with `-M` with older `MACOSX_DEPLOYMENT_TARGETS`. To avoid this we have bumped the deployment target for x86-64/Darwin to 10.10. - - - - - 0acbbd20 by Ben Gamari at 2021-11-18T22:27:20-05:00 testsuite: Use libc++ rather than libstdc++ in objcpp-hi It appears that libstdc++ is no longer available in recent XCode distributions. Closes #16083. - - - - - aed98dda by John Ericson at 2021-11-18T22:27:55-05:00 Hadrian: bring up to date with latest make improvements Headers should be associated with the RTS, and subject to less hacks. The most subtle issue was that the package-grained dependencies on generated files were being `need`ed before calculating Haskell deps, but not before calculating C/C++ deps. - - - - - aabff109 by Ben Gamari at 2021-11-20T05:34:27-05:00 Bump deepseq submodule to 1.4.7.0-pre Addresses #20653. - - - - - 3d6b78db by Matthew Pickering at 2021-11-20T05:35:02-05:00 Remove unused module import syntax from .bkp mode .bkp mode had this unused feature where you could write module A and it would go looking for A.hs on the file system and use that rather than provide the definition inline. This isn't use anywhere in the testsuite and the code to find the module A looks dubious. Therefore to reduce .bkp complexity I propose to remove it. Fixes #20701 - - - - - bdeea37e by Sylvain Henry at 2021-11-20T05:35:42-05:00 More support for optional home-unit This is a preliminary refactoring for #14335 (supporting plugins in cross-compilers). In many places the home-unit must be optional because there won't be one available in the plugin environment (we won't be compiling anything in this environment). Hence we replace "HomeUnit" with "Maybe HomeUnit" in a few places and we avoid the use of "hsc_home_unit" (which is partial) in some few others. - - - - - 29e03071 by Ben Gamari at 2021-11-20T05:36:18-05:00 rts: Ensure that markCAFs marks object code Previously `markCAFs` would only evacuate CAFs' indirectees. This would allow reachable object code to be unloaded by the linker as `evacuate` may never be called on the CAF itself, despite it being reachable via the `{dyn,revertible}_caf_list`s. To fix this we teach `markCAFs` to explicit call `markObjectCode`, ensuring that the linker is aware of objects reachable via the CAF lists. Fixes #20649. - - - - - b2933ea9 by Ben Gamari at 2021-11-20T05:36:54-05:00 gitlab-ci: Set HOME to plausible but still non-existent location We have been seeing numerous CI failures on aarch64/Darwin of the form: CI_COMMIT_BRANCH: CI_PROJECT_PATH: ghc/ghc error: creating directory '/nonexistent': Read-only file system Clearly *something* is attempting to create `$HOME`. A bit of sleuthing by @int-e found that the culprit is likely `nix`, although it's not clear why. For now we avoid the issue by setting `HOME` to a fresh directory in the working tree. - - - - - bc7e9f03 by Zubin Duggal at 2021-11-20T17:39:25+00:00 Use 'NonEmpty' for the fields in an 'HsProjection' (#20389) T12545 is very inconsistently affected by this change for some reason. There is a decrease in allocations on most configurations, but an increase on validate-x86_64-linux-deb9-unreg-hadrian. Accepting it as it seems unrelated to this patch. Metric Decrease: T12545 Metric Increase: T12545 - - - - - 742d8b60 by sheaf at 2021-11-20T18:13:23-05:00 Include "not more specific" info in overlap msg When instances overlap, we now include additional information about why we weren't able to select an instance: perhaps one instance overlapped another but was not strictly more specific, so we aren't able to directly choose it. Fixes #20542 - - - - - f748988b by Simon Peyton Jones at 2021-11-22T11:53:02-05:00 Better wrapper activation calculation As #20709 showed, GHC could prioritise a wrapper over a SPEC rule, which is potentially very bad. This patch fixes that problem. The fix is is described in Note [Wrapper activation], especially item 4, 4a, and Conclusion. For now, it has a temporary hack (replicating what was there before to make sure that wrappers inline no earlier than phase 2. But it should be temporary; see #19001. - - - - - f0bac29b by Simon Peyton Jones at 2021-11-22T11:53:02-05:00 Make INLINE/NOINLINE pragmas a bgi less constraining We can inline a bit earlier than the previous pragmas said. I think they dated from an era in which the InitialPhase did no inlining. I don't think this patch will have much effect, but it's a bit cleaner. - - - - - 68a3665a by Sylvain Henry at 2021-11-22T11:53:47-05:00 Hadrian: bump stackage LTS to 18.18 (GHC 8.10.7) - - - - - 680ef2c8 by Andreas Klebinger at 2021-11-23T01:07:29-05:00 CmmSink: Be more aggressive in removing no-op assignments. No-op assignments like R1 = R1 are not only wasteful. They can also inhibit other optimizations like inlining assignments that read from R1. We now check for assignments being a no-op before and after we simplify the RHS in Cmm sink which should eliminate most of these no-ops. - - - - - 1ed2aa90 by Andreas Klebinger at 2021-11-23T01:07:29-05:00 Don't include types in test output - - - - - 3ab3631f by Krzysztof Gogolewski at 2021-11-23T01:08:05-05:00 Add a warning for GADT match + NoMonoLocalBinds (#20485) Previously, it was an error to pattern match on a GADT without GADTs or TypeFamilies. This is now allowed. Instead, we check the flag MonoLocalBinds; if it is not enabled, we issue a warning, controlled by -Wgadt-mono-local-binds. Also fixes #20485: pattern synonyms are now checked too. - - - - - 9dcb2ad1 by Ben Gamari at 2021-11-23T16:09:39+00:00 gitlab-ci: Bump DOCKER_REV - - - - - 16690374 by nineonine at 2021-11-23T22:32:51-08:00 Combine STG free variable traversals (#17978) Previously we would traverse the STG AST twice looking for free variables. * Once in `annTopBindingsDeps` which considers top level and imported ids free. Its output is used to put bindings in dependency order. The pass happens in STG pipeline. * Once in `annTopBindingsFreeVars` which only considers non-top level ids free. Its output is used by the code generator to compute offsets into closures. This happens in Cmm (CodeGen) pipeline. Now these two traversal operations are merged into one - `FVs.depSortWithAnnotStgPgm`. The pass happens right at the end of STG pipeline. Some type signatures had to be updated due to slight shifts of StgPass boundaries (for example, top-level CodeGen handler now directly works with CodeGen flavoured Stg AST instead of Vanilla). Due to changed order of bindings, a few debugger type reconstruction bugs have resurfaced again (see tests break018, break021) - work item #18004 tracks this investigation. authors: simonpj, nineonine - - - - - 91c0a657 by Matthew Pickering at 2021-11-25T01:03:17-05:00 Correct retypechecking in --make mode Note [Hydrating Modules] ~~~~~~~~~~~~~~~~~~~~~~~~ What is hydrating a module? * There are two versions of a module, the ModIface is the on-disk version and the ModDetails is a fleshed-out in-memory version. * We can **hydrate** a ModIface in order to obtain a ModDetails. Hydration happens in three different places * When an interface file is initially loaded from disk, it has to be hydrated. * When a module is finished compiling, we hydrate the ModIface in order to generate the version of ModDetails which exists in memory (see Note) * When dealing with boot files and module loops (see Note [Rehydrating Modules]) Note [Rehydrating Modules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ If a module has a boot file then it is critical to rehydrate the modules on the path between the two. Suppose we have ("R" for "recursive"): ``` R.hs-boot: module R where data T g :: T -> T A.hs: module A( f, T, g ) where import {-# SOURCE #-} R data S = MkS T f :: T -> S = ...g... R.hs: module R where data T = T1 | T2 S g = ...f... ``` After compiling A.hs we'll have a TypeEnv in which the Id for `f` has a type type uses the AbstractTyCon T; and a TyCon for `S` that also mentions that same AbstractTyCon. (Abstract because it came from R.hs-boot; we know nothing about it.) When compiling R.hs, we build a TyCon for `T`. But that TyCon mentions `S`, and it currently has an AbstractTyCon for `T` inside it. But we want to build a fully cyclic structure, in which `S` refers to `T` and `T` refers to `S`. Solution: **rehydration**. *Before compiling `R.hs`*, rehydrate all the ModIfaces below it that depend on R.hs-boot. To rehydrate a ModIface, call `typecheckIface` to convert it to a ModDetails. It's just a de-serialisation step, no type inference, just lookups. Now `S` will be bound to a thunk that, when forced, will "see" the final binding for `T`; see [Tying the knot](https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/tying-the-knot). But note that this must be done *before* compiling R.hs. When compiling R.hs, the knot-tying stuff above will ensure that `f`'s unfolding mentions the `LocalId` for `g`. But when we finish R, we carefully ensure that all those `LocalIds` are turned into completed `GlobalIds`, replete with unfoldings etc. Alas, that will not apply to the occurrences of `g` in `f`'s unfolding. And if we leave matters like that, they will stay that way, and *all* subsequent modules that import A will see a crippled unfolding for `f`. Solution: rehydrate both R and A's ModIface together, right after completing R.hs. We only need rehydrate modules that are * Below R.hs * Above R.hs-boot There might be many unrelated modules (in the home package) that don't need to be rehydrated. This dark corner is the subject of #14092. Suppose we add to our example ``` X.hs module X where import A data XT = MkX T fx = ...g... ``` If in `--make` we compile R.hs-boot, then A.hs, then X.hs, we'll get a `ModDetails` for `X` that has an AbstractTyCon for `T` in the the argument type of `MkX`. So: * Either we should delay compiling X until after R has beeen compiled. * Or we should rehydrate X after compiling R -- because it transitively depends on R.hs-boot. Ticket #20200 has exposed some issues to do with the knot-tying logic in GHC.Make, in `--make` mode. this particular issue starts [here](https://gitlab.haskell.org/ghc/ghc/-/issues/20200#note_385758). The wiki page [Tying the knot](https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/tying-the-knot) is helpful. Also closely related are * #14092 * #14103 Fixes tickets #20200 #20561 - - - - - f0c5d8d3 by Matthew Pickering at 2021-11-25T01:03:17-05:00 Make T14075 more robust - - - - - 6907e9fa by Matthew Pickering at 2021-11-25T01:03:17-05:00 Revert "Convert lookupIdSubst panic back to a warning (#20200)" This reverts commit df1d808f26544cbb77d85773d672137c65fd3cc7. - - - - - baa8ffee by Greg Steuck at 2021-11-25T01:03:54-05:00 Use getExecutablePath in getBaseDir on OpenBSD While OpenBSD doesn't have a general mechanism for determining the path of the executing program image, it is reasonable to rely on argv[0] which happens as a fallback in getExecutablePath. With this change on top of T18173 we can get a bit close to fixing #18173. - - - - - e3c59191 by Christiaan Baaij at 2021-11-25T01:04:32-05:00 Ensure new Ct/evidence invariant The `ctev_pred` field of a `CtEvidence` is a just a cache for the type of the evidence. More precisely: * For Givens, `ctev_pred` = `varType ctev_evar` * For Wanteds, `ctev_pred` = `evDestType ctev_dest` This new invariant is needed because evidence can become part of a type, via `Castty ty kco`. - - - - - 3639ad8f by Christiaan Baaij at 2021-11-25T01:04:32-05:00 Compare types of recursive let-bindings in alpha-equivalence This commit fixes #20641 by checking the types of recursive let-bindings when performing alpha-equality. The `Eq (DeBruijn CoreExpr)` instance now also compares `BreakPoint`s similarly to `GHC.Core.Utils.eqTickish`, taking bound variables into account. In addition, the `Eq (DeBruijn Type)` instance now correctly compares the kinds of the types when one of them contains a Cast: the instance is modeled after `nonDetCmpTypeX`. - - - - - 7c65687e by CarrieMY at 2021-11-25T01:05:11-05:00 Enable UnboxedTuples in `genInst`, Fixes #20524 - - - - - e33412d0 by Krzysztof Gogolewski at 2021-11-25T01:05:46-05:00 Misc cleanup * Remove `getTag_RDR` (unused), `tidyKind` and `tidyOpenKind` (already available as `tidyType` and `tidyOpenType`) * Remove Note [Explicit Case Statement for Specificity]. Since 0a709dd9876e40 we require GHC 8.10 for bootstrapping. * Change the warning to `cmpAltCon` to a panic. This shouldn't happen. If it ever does, the code was wrong anyway: it shouldn't always return `LT`, but rather `LT` in one case and `GT` in the other case. * Rename `verifyLinearConstructors` to `verifyLinearFields` * Fix `Note [Local record selectors]` which was not referenced * Remove vestiges of `type +v` * Minor fixes to StaticPointers documentation, part of #15603 - - - - - bb71f7f1 by Greg Steuck at 2021-11-25T01:06:25-05:00 Reorder `sed` arguments to work with BSD sed The order was swapped in 490e8c750ea23ce8e2b7309e0d514b7d27f231bb causing the build on OpenBSD to fail with: `sed: 1: "mk/config.h": invalid command code m` - - - - - c18a51f0 by John Ericson at 2021-11-25T01:06:25-05:00 Apply 1 suggestion(s) to 1 file(s) - - - - - d530c46c by sheaf at 2021-11-25T01:07:04-05:00 Add Data.Bits changes to base 4.16 changelog Several additions since 4.15 had not been recorded in the changelog: - newtypes And, Ior, Xor and Iff, - oneBits - symbolic synonyms `.^.`, `.>>.`, `!>>.`, `.<<.` and `!<<.`. Fixes #20608. - - - - - 4d34bf15 by Matthew Pickering at 2021-11-25T01:07:40-05:00 Don't use implicit lifting when deriving Lift It isn't much more complicated to be more precise when deriving Lift so we now generate ``` data Foo = Foo Int Bool instance Lift Foo where lift (Foo a b) = [| Foo $(lift a) $(lift b) |] liftTyped (Foo a b) = [|| Foo $$(lift a) $$(lift b) |] ``` This fixes #20688 which complained about using implicit lifting in the derived code. - - - - - 8961d632 by Greg Steuck at 2021-11-25T01:08:18-05:00 Disable warnings for unused goto labels Clang on OpenBSD aborts compilation with this diagnostics: ``` % "inplace/bin/ghc-stage1" -optc-Wno-error=unused-label -optc-Wall -optc-Werror -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist-install/build/./autogen -optc-Irts/include/../dist-install/build/include -optc-Irts/include/. -optc-Irts/. -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DRtsWay=\"rts_v\" -static -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/linker/Elf.c -o rts/dist-install/build/linker/Elf.o rts/linker/Elf.c:2169:1: error: error: unused label 'dl_iterate_phdr_fail' [-Werror,-Wunused-label] | 2169 | dl_iterate_phdr_fail: | ^ dl_iterate_phdr_fail: ^~~~~~~~~~~~~~~~~~~~~ rts/linker/Elf.c:2172:1: error: error: unused label 'dlinfo_fail' [-Werror,-Wunused-label] | 2172 | dlinfo_fail: | ^ dlinfo_fail: ^~~~~~~~~~~~ 2 errors generated. ``` - - - - - 5428b8c6 by Zubin Duggal at 2021-11-25T01:08:54-05:00 testsuite: debounce title updates - - - - - 96b3899e by Ben Gamari at 2021-11-25T01:09:29-05:00 gitlab-ci: Add release jobs for Darwin targets As noted in #20707, the validate jobs which we previously used lacked profiling support. Also clean up some variable definitions. Fixes #20707. - - - - - 52cdc2fe by Pepe Iborra at 2021-11-25T05:00:43-05:00 Monoid instance for InstalledModuleEnv - - - - - 47f36440 by Pepe Iborra at 2021-11-25T05:00:43-05:00 Drop instance Semigroup ModuleEnv There is more than one possible Semigroup and it is not needed since plusModuleEnv can be used directly - - - - - b742475a by Pepe Iborra at 2021-11-25T05:00:43-05:00 drop instance Semigroup InstalledModuleEnv Instead, introduce plusInstalledModuleEnv - - - - - b24e8d91 by Roland Senn at 2021-11-25T05:01:21-05:00 GHCi Debugger - Improve RTTI When processing the heap, use also `APClosures` to create additional type constraints. This adds more equations and therefore improves the unification process to infer the correct type of values at breakpoints. (Fix the `incr` part of #19559) - - - - - cf5279ed by Gergo ERDI at 2021-11-25T05:01:59-05:00 Use `simplify` in non-optimizing build pipeline (#20500) - - - - - c9cead1f by Gergo ERDI at 2021-11-25T05:01:59-05:00 Add specific optimization flag for fast PAP calls (#6084, #20500) - - - - - be0a9470 by Gergo ERDI at 2021-11-25T05:01:59-05:00 Add specific optimization flag for Cmm control flow analysis (#20500) - - - - - b52a9a3f by Gergo ERDI at 2021-11-25T05:01:59-05:00 Add `llvmOptLevel` to `DynFlags` (#20500) - - - - - f27a63fe by sheaf at 2021-11-25T05:02:39-05:00 Allow boring class declarations in hs-boot files There are two different ways of declaring a class in an hs-boot file: - a full declaration, where everything is written as it is in the .hs file, - an abstract declaration, where class methods and superclasses are left out. However, a declaration with no methods and a trivial superclass, such as: class () => C a was erroneously considered to be an abstract declaration, because the superclass is trivial. This is remedied by a one line fix in GHC.Tc.TyCl.tcClassDecl1. This patch also further clarifies the documentation around class declarations in hs-boot files. Fixes #20661, #20588. - - - - - cafb1f99 by Ben Gamari at 2021-11-25T05:03:15-05:00 compiler: Mark GHC.Prelude as Haddock no-home This significantly improves Haddock documentation generated by nix. - - - - - bd92c9b2 by Sebastian Graf at 2021-11-25T05:03:51-05:00 hadrian: Add `collect_stats` flavour transformer This is useful for later consumption with https://gitlab.haskell.org/bgamari/ghc-utils/-/blob/master/ghc_timings.py - - - - - 774fc4d6 by Ilias Tsitsimpis at 2021-11-25T08:34:54-05:00 Link against libatomic for 64-bit atomic operations Some platforms (e.g., armel) require linking against libatomic for 64-bit atomic operations. Fixes #20549 - - - - - 20101d9c by Greg Steuck at 2021-11-25T08:35:31-05:00 Permit multiple values in config_args for validate The whitespace expansion should be permitted to pass multiple arguments to configure. - - - - - e2c48b98 by Greg Steuck at 2021-11-25T08:36:09-05:00 Kill a use of %n format specifier This format has been used as a security exploit vector for decades now. Some operating systems (OpenBSD, Android, MSVC). It is targeted for removal in C2X standard: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2834.htm This requires extending the debug message function to return the number of bytes written (like printf(3)), to permit %n format specifier in one in one invocation of statsPrintf() in report_summary(). Implemented by Matthias Kilian (kili<AT>outback.escape.de) - - - - - ff0c45f3 by Bodigrim at 2021-11-26T16:01:09-05:00 Rename Data.ByteArray to Data.Array.ByteArray + add Trustworthy - - - - - 9907d540 by Bodigrim at 2021-11-26T16:01:09-05:00 Rename Data.Array.ByteArray -> Data.Array.Byte - - - - - 0c8e1b4d by Kai Prott at 2021-11-26T16:01:47-05:00 Improve error message for mis-typed plugins #20671 Previously, when a plugin could not be loaded because it was incorrectly typed, the error message only printed the expected but not the actual type. This commit augments the error message such that both types are printed and the corresponding module is printed as well. - - - - - 51bcb986 by Kai Prott at 2021-11-26T16:01:47-05:00 Remove duplicate import - - - - - 1830eea7 by Kai Prott at 2021-11-26T16:01:47-05:00 Simplify printQualification - - - - - 69e62032 by Kai Prott at 2021-11-26T16:01:47-05:00 Fix plugin type to GHC.Plugins.Plugin - - - - - 0a6776a3 by Kai Prott at 2021-11-26T16:01:47-05:00 Adapt plugin test case - - - - - 7e18b304 by Kai Prott at 2021-11-26T16:01:47-05:00 Reflect type change in the haddock comment - - - - - 02372be1 by Matthew Pickering at 2021-11-26T16:02:23-05:00 Allow keywords which can be used as variables to be used with OverloadedDotSyntax There are quite a few keywords which are allowed to be used as variables. Such as "as", "dependency" etc. These weren't accepted by OverloadedDotSyntax. The fix is pretty simple, use the varid production rather than raw VARID. Fixes #20723 - - - - - 13ef345c by John Ericson at 2021-11-27T19:41:11+00:00 Factor our `FP_CAPITALIZE_YES_NO` This deduplicates converting from yes/no to YES/NO in the configure scripts while also making it safer. - - - - - 88481c94 by John Ericson at 2021-11-27T19:46:16+00:00 Fix top-level configure script so --disable-foo works - - - - - f67060c6 by John Ericson at 2021-11-27T19:47:09+00:00 Make ambient MinGW support a proper settings Get rid of `USE_INPLACE_MINGW_TOOLCHAIN` and use a settings file entry instead. The CPP setting was originally introduced in f065b6b012. - - - - - 1dc0d7af by Ben Gamari at 2021-11-29T11:02:43-05:00 linker: Introduce linker_verbose debug output This splits the -Dl RTS debug output into two distinct flags: * `+RTS -Dl` shows errors and debug output which scales with at most O(# objects) * `+RTS -DL` shows debug output which scales with O(# symbols)t - - - - - 7ea665bf by Krzysztof Gogolewski at 2021-11-29T11:03:19-05:00 TTG: replace Void/NoExtCon with DataConCantHappen There were two ways to indicate that a TTG constructor is unused in a phase: `NoExtCon` and `Void`. This unifies the code, and uses the name 'DataConCantHappen', following the discussion at MR 7041. Updates haddock submodule - - - - - 14e9cab6 by Sylvain Henry at 2021-11-29T11:04:03-05:00 Use Monoid in hptSomeThingsBelowUs It seems to have a moderate but good impact on perf tests in CI. In particular: MultiLayerModules(normal) ghc/alloc 3125771138.7 3065532240.0 -1.9% So it's likely that huge projects will benefit from this. - - - - - 22bbf449 by Anton-Latukha at 2021-11-29T20:03:52+00:00 docs/users_guide/bugs.rst: Rewording It is either "slightly" || "significantly". If it is "bogus" - then no quotes around "optimization" & overall using word "bogus" or use quotes in that way in documentation is... Instead, something like "hack" or "heuristic" can be used there. - - - - - 9345bfed by Mitchell Rosen at 2021-11-30T01:32:22-05:00 Fix caluclation of nonmoving GC elapsed time Fixes #20751 - - - - - c7613493 by PHO at 2021-12-01T03:07:32-05:00 rts/ProfHeap.c: Use setlocale() on platforms where uselocale() is not available Not all platforms have per-thread locales. NetBSD doesn't have uselocale() in particular. Using setlocale() is of course not a safe thing to do, but it would be better than no GHC at all. - - - - - 4acfa0db by Ben Gamari at 2021-12-01T03:08:07-05:00 rts: Refactor SRT representation selection The goal here is to make the SRT selection logic a bit clearer and allow configurations which we currently don't support (e.g. using a full word in the info table even when TNTC is used). - - - - - 87bd9a67 by Ben Gamari at 2021-12-01T03:08:07-05:00 gitlab-ci: Introduce no_tntc job A manual job for testing the non-tables-next-to-code configuration. - - - - - 7acb945d by Carrie Xu at 2021-12-01T03:08:46-05:00 Dump non-module specific info to file #20316 - Change the dumpPrefix to FilePath, and default to non-module - Add dot to seperate dump-file-prefix and suffix - Modify user guide to introduce how dump files are named - This commit does not affect Ghci dump file naming. See also #17500 - - - - - 7bdca2ba by Ben Gamari at 2021-12-01T03:09:21-05:00 rts/RtsSymbols: Provide a proper prototype for environ Previously we relied on Sym_NeedsProto, but this gave the symbol a type which conflicts with the definition that may be provided by unistd.h. Fixes #20577. - - - - - 91d1a773 by Ben Gamari at 2021-12-01T03:09:21-05:00 hadrian: Don't pass empty paths via -I Previously we could in some cases add empty paths to `cc`'s include file search path. See #20578. - - - - - d8d57729 by Ben Gamari at 2021-12-01T03:09:21-05:00 ghc-cabal: Manually specify -XHaskell2010 Otherwise we end up with issues like #19631 when bootstrapping using GHC 9.2 and above. Fixes #19631. - - - - - 1c0c140a by Ben Gamari at 2021-12-01T03:09:21-05:00 ghc-compact: Update cabal file Improve documentation, bump bounds and cabal-version. - - - - - 322b6b45 by Ben Gamari at 2021-12-01T03:09:21-05:00 hadrian: Document fully_static flavour transformer - - - - - 4c434c9e by Ben Gamari at 2021-12-01T03:09:21-05:00 user-guide: Fix :since: of -XCApiFFI Closes #20504. - - - - - 0833ad55 by Matthew Pickering at 2021-12-01T03:09:58-05:00 Add failing test for #20674 - - - - - c2cb5e9a by Ben Gamari at 2021-12-01T03:10:34-05:00 testsuite: Print geometric mean of stat metrics As suggested in #20733. - - - - - 59b27945 by Ben Gamari at 2021-12-01T03:11:09-05:00 users-guide: Describe requirements of DWARF unwinding As requested in #20702 - - - - - c2f6cbef by Matthew Pickering at 2021-12-01T03:11:45-05:00 Fix several quoting issues in testsuite This fixes the ./validate script on my machine. I also took the step to add some linters which would catch problems like these in future. Fixes #20506 - - - - - bffd4074 by John Ericson at 2021-12-01T03:12:21-05:00 rts.cabal.in: Move `extra-source-files` so it is valid - - - - - 86c14db5 by John Ericson at 2021-12-01T03:12:21-05:00 Switch RTS cabal file / package conf to use Rts.h not Stg.h When we give cabal a configure script, it seems to begin checking whether or not Stg.h is valid, and then gets tripped up on all the register stuff which evidentally requires obscure command line flags to go. We can side-step this by making the test header Rts.h instead, which is more normal. I was a bit sketched out making this change, as I don't know why the Cabal library would suddenly beging checking the header. But I did confirm even without my RTS configure script the header doesn't compile stand-alone, and also the Stg.h is a probably-arbitrary choice since it dates all the way back to 2002 in 2cc5b907318f97e19b28b2ad8ed9ff8c1f401dcc. - - - - - defd8d54 by John Ericson at 2021-12-01T03:12:21-05:00 Avoid raw `echo` in `FPTOOLS_SET_PLATFORM_VARS` This ensures quiet configuring works. - - - - - b53f1227 by John Ericson at 2021-12-01T03:12:21-05:00 Factor our `$dir_$distdir_PKGDATA` make variable This makes a few things cleaner. - - - - - f124f2a0 by Ben Gamari at 2021-12-01T03:12:56-05:00 rts: Annotate benign race in pthread ticker's exit test Previously TSAN would report spurious data races due to the unsynchronized access of `exited`. I would have thought that using a relaxed load on `exited` would be enough to convince TSAN that the race was intentional, but apparently not. Closes #20690. - - - - - d3c7f9be by Viktor Dukhovni at 2021-12-01T03:13:34-05:00 Use POSIX shell syntax to redirect stdout/err FreeBSD (and likely NetBSD) /bin/sh does not support '>& word' to redirect stdout + stderr. (Also the preferred syntax in bash would be '&> word' to avoid surprises when `word` is "-" or a number). Resolves: #20760 - - - - - 1724ac37 by Ben Gamari at 2021-12-02T18:13:30-05:00 nativeGen/x86: Don't encode large shift offsets Handle the case of a shift larger than the width of the shifted value. This is necessary since x86 applies a mask of 0x1f to the shift amount, meaning that, e.g., `shr 47, $eax` will actually shift by 47 & 0x1f == 15. See #20626. (cherry picked from commit 31370f1afe1e2f071b3569fb5ed4a115096127ca) - - - - - 5b950a7f by Ben Gamari at 2021-12-02T18:13:30-05:00 cmm: narrow when folding signed quotients Previously the constant-folding behavior for MO_S_Quot and MO_S_Rem failed to narrow its arguments, meaning that a program like: %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8)) would be miscompiled. Specifically, this program should reduce as %lobits8(0x00e1::bits16) == -31 %quot(%lobits8(0x00e1::bits16), 3::bits8) == -10 %zx64(%quot(%lobits8(0x00e1::bits16), 3::bits8)) == 246 However, with this bug the `%lobits8(0x00e1::bits16)` would instead be treated as `+31`, resulting in the incorrect result of `75`. (cherry picked from commit 94e197e3dbb9a48991eb90a03b51ea13d39ba4cc) - - - - - 78b78ac4 by Ben Gamari at 2021-12-02T18:13:30-05:00 ncg/aarch64: Don't sign extend loads Previously we would emit the sign-extending LDS[HB] instructions for sub-word loads. However, this is wrong, as noted in #20638. - - - - - 35bbc251 by Ben Gamari at 2021-12-02T18:13:30-05:00 cmm: Disallow shifts larger than shiftee Previously primops.txt.pp stipulated that the word-size shift primops were only defined for shift offsets in [0, word_size). However, there was no further guidance for the definition of Cmm's sub-word size shift MachOps. Here we fix this by explicitly disallowing (checked in many cases by CmmLint) shift operations where the shift offset is larger than the shiftee. This is consistent with LLVM's shift operations, avoiding the miscompilation noted in #20637. - - - - - 2f6565cf by Ben Gamari at 2021-12-02T18:13:30-05:00 testsuite: Add testcases for various machop issues There were found by the test-primops testsuite. - - - - - 7094f4fa by Ben Gamari at 2021-12-02T18:13:30-05:00 nativeGen/aarch64: Don't rely on register width to determine amode We might be loading, e.g., a 16- or 8-bit value, in which case the register width is not reflective of the loaded element size. - - - - - 9c65197e by Ben Gamari at 2021-12-02T18:13:30-05:00 cmm/opt: Fold away shifts larger than shiftee width This is necessary for lint-correctness since we no longer allow such shifts in Cmm. - - - - - adc7f108 by Ben Gamari at 2021-12-02T18:13:30-05:00 nativeGen/aarch64: Fix handling of subword values Here we rework the handling of sub-word operations in the AArch64 backend, fixing a number of bugs and inconsistencies. In short, we now impose the invariant that all subword values are represented in registers in zero-extended form. Signed arithmetic operations are then responsible for sign-extending as necessary. Possible future work: * Use `CMP`s extended register form to avoid burning an instruction in sign-extending the second operand. * Track sign-extension state of registers to elide redundant sign extensions in blocks with frequent sub-word signed arithmetic. - - - - - e19e9e71 by Ben Gamari at 2021-12-02T18:13:31-05:00 CmmToC: Fix width of shift operations Under C's implicit widening rules, the result of an operation like (a >> b) where a::Word8 and b::Word will have type Word, yet we want Word. - - - - - ebaf7333 by Ben Gamari at 2021-12-02T18:13:31-05:00 CmmToC: Zero-extend sub-word size results As noted in Note [Zero-extending sub-word signed results] we must explicitly zero-extend the results of sub-word-sized signed operations. - - - - - 0aeaa8f3 by Ben Gamari at 2021-12-02T18:13:31-05:00 CmmToC: Always cast arguments as unsigned As noted in Note [When in doubt, cast arguments as unsigned], we must ensure that arguments have the correct signedness since some operations (e.g. `%`) have different semantics depending upon signedness. - - - - - e98dad1b by Ben Gamari at 2021-12-02T18:13:31-05:00 CmmToC: Cast possibly-signed results as unsigned C11 rule 6.3.1.1 dictates that all small integers used in expressions be implicitly converted to `signed int`. However, Cmm semantics require that the width of the operands be preserved with zero-extension semantics. For this reason we must recast sub-word arithmetic results as unsigned. - - - - - 44c08863 by Ben Gamari at 2021-12-02T18:13:31-05:00 testsuite: Specify expected word-size of machop tests These generally expect a particular word size. - - - - - fab2579e by Ben Gamari at 2021-12-02T18:14:06-05:00 hadrian: Don't rely on realpath in bindist Makefile As noted in #19963, `realpath` is not specified by POSIX and therefore cannot be assumed to be available. Here we provide a POSIX shell implementation of `realpath`, due to Julian Ospald and others. Closes #19963. - - - - - 99eb54bd by Kamil Dworakowski at 2021-12-02T21:45:10-05:00 Make openFile more tolerant of async excs (#18832) - - - - - 0e274c39 by nineonine at 2021-12-02T21:45:49-05:00 Require all dirty_MUT_VAR callers to do explicit stg_MUT_VAR_CLEAN_info comparison (#20088) - - - - - 81082cf4 by Matthew Pickering at 2021-12-03T10:12:04-05:00 Revert "Data.List specialization to []" This reverts commit bddecda1a4c96da21e3f5211743ce5e4c78793a2. This implements the first step in the plan formulated in #20025 to improve the communication and migration strategy for the proposed changes to Data.List. Requires changing the haddock submodule to update the test output. - - - - - a9e035a4 by sheaf at 2021-12-03T10:12:42-05:00 Test-suite: fix geometric mean of empty list The geometric mean computation panicked when it was given an empty list, which happens when there are no baselines. Instead, we should simply return 1. - - - - - d72720f9 by Matthew Pickering at 2021-12-06T16:27:35+00:00 Add section to the user guide about OS memory usage - - - - - 0fe45d43 by Viktor Dukhovni at 2021-12-07T06:27:12-05:00 List-monomorphic `foldr'` While a *strict* (i.e. constant space) right-fold on lists is not possible, the default `foldr'` is optimised for structures like `Seq`, that support efficient access to the right-most elements. The original default implementation seems to have a better constant factor for lists, so we add a monomorphic implementation in GHC.List. Should this be re-exported from `Data.List`? That would be a user-visible change if both `Data.Foldable` and `Data.List` are imported unqualified... - - - - - 7d2283b9 by Ben Gamari at 2021-12-07T06:27:47-05:00 compiler: Eliminate accidental loop in GHC.SysTools.BaseDir As noted in #20757, `GHC.SysTools.BaseDir.findToolDir` previously contained an loop, which would be triggered in the case that the search failed. Closes #20757. - - - - - 8044e232 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00 More specific documentation of foldr' caveats - - - - - d932e2d6 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00 Use italic big-O notation in Data.Foldable - - - - - 57c9c0a2 by Viktor Dukhovni at 2021-12-07T06:28:23-05:00 Fix user-guide typo - - - - - 324772bb by Ben Gamari at 2021-12-07T06:28:59-05:00 rts/Linker: Ensure that mmap_32bit_base is updated after mapping The amount of duplicated code in `mmapForLinker` hid the fact that some codepaths would fail to update `mmap_32bit_base` (specifically, on platforms like OpenBSD where `MAP_32BIT` is not supported). Refactor the function to make the implementation more obviously correct. Closes #20734. - - - - - 5dbdf878 by Ben Gamari at 2021-12-07T06:28:59-05:00 rts: +RTS -DL should imply +RTS -Dl Otherwise the user may be surprised by the missing context provided by the latter. - - - - - 7eb56064 by sheaf at 2021-12-07T06:29:38-05:00 More permissive parsing of higher-rank type IPs The parser now accepts implicit parameters with higher-rank types, such as `foo :: (?ip :: forall a. a -> a) => ...` Before this patch, we instead insisted on parentheses like so: `foo :: (?ip :: (forall a. a -> a)) => ...` The rest of the logic surrounding implicit parameters is unchanged; in particular, even with ImpredicativeTypes, this idiom is not likely to be very useful. Fixes #20654 - - - - - 427f9c12 by sheaf at 2021-12-07T13:32:55-05:00 Re-export GHC.Types from GHC.Exts Several times in the past, it has happened that things from GHC.Types were not re-exported from GHC.Exts, forcing users to import either GHC.Types or GHC.Prim, which are subject to internal change without notice. We now re-export GHC.Types from GHC.Exts, which should avoid this happening again in the future. In particular, we now re-export `Multiplicity` and `MultMul`, which we didn't before. Fixes #20695 - - - - - 483bd04d by Sebastian Graf at 2021-12-07T13:33:31-05:00 Explicit Data.List import list in check-ppr (#20789) `check-ppr` features an import of Data.List without an import list. After 81082cf4, this breaks the local validate flavour because of the compat warning and `-Werror`. So fix that. Fixes #20789. - - - - - cc2bf8e9 by Norman Ramsey at 2021-12-07T17:34:51-05:00 generalize GHC.Cmm.Dataflow to work over any node type See #20725. The commit includes source-code changes and a test case. - - - - - 4c6985cc by Sylvain Henry at 2021-12-07T17:35:30-05:00 Perf: remove an indirection when fetching the unique mask Slight decrease but still noticeable on CI: Baseline Test Metric value New value Change ----------------------------------------------------------------------------- ManyAlternatives(normal) ghc/alloc 747607676.0 747458936.0 -0.0% ManyConstructors(normal) ghc/alloc 4003722296.0 4003530032.0 -0.0% MultiLayerModules(normal) ghc/alloc 3064539560.0 3063984552.0 -0.0% MultiLayerModulesRecomp(normal) ghc/alloc 894700016.0 894700624.0 +0.0% PmSeriesG(normal) ghc/alloc 48410952.0 48262496.0 -0.3% PmSeriesS(normal) ghc/alloc 61561848.0 61415768.0 -0.2% PmSeriesT(normal) ghc/alloc 90975784.0 90829360.0 -0.2% PmSeriesV(normal) ghc/alloc 60405424.0 60259008.0 -0.2% T10421(normal) ghc/alloc 113275928.0 113137168.0 -0.1% T10421a(normal) ghc/alloc 79195676.0 79050112.0 -0.2% T10547(normal) ghc/alloc 28720176.0 28710008.0 -0.0% T10858(normal) ghc/alloc 180992412.0 180857400.0 -0.1% T11195(normal) ghc/alloc 283452220.0 283293832.0 -0.1% T11276(normal) ghc/alloc 137882128.0 137745840.0 -0.1% T11303b(normal) ghc/alloc 44453956.0 44309184.0 -0.3% T11374(normal) ghc/alloc 248118668.0 247979880.0 -0.1% T11545(normal) ghc/alloc 971994728.0 971852696.0 -0.0% T11822(normal) ghc/alloc 131544864.0 131399024.0 -0.1% T12150(optasm) ghc/alloc 79336468.0 79191888.0 -0.2% T12227(normal) ghc/alloc 495064180.0 494943040.0 -0.0% T12234(optasm) ghc/alloc 57198468.0 57053568.0 -0.3% T12425(optasm) ghc/alloc 90928696.0 90793440.0 -0.1% T12545(normal) ghc/alloc 1695417772.0 1695275744.0 -0.0% T12707(normal) ghc/alloc 956258984.0 956138864.0 -0.0% T13035(normal) ghc/alloc 102279484.0 102132616.0 -0.1% T13056(optasm) ghc/alloc 367196556.0 367066408.0 -0.0% T13253(normal) ghc/alloc 334365844.0 334255264.0 -0.0% T13253-spj(normal) ghc/alloc 125474884.0 125328672.0 -0.1% T13379(normal) ghc/alloc 359185604.0 359036960.0 -0.0% T13701(normal) ghc/alloc 2403026480.0 2402677464.0 -0.0% T13719(normal) ghc/alloc 4192234752.0 4192039448.0 -0.0% T14052(ghci) ghc/alloc 2745868552.0 2747706176.0 +0.1% T14052Type(ghci) ghc/alloc 7335937964.0 7336283280.0 +0.0% T14683(normal) ghc/alloc 2992557736.0 2992436872.0 -0.0% T14697(normal) ghc/alloc 363391248.0 363222920.0 -0.0% T15164(normal) ghc/alloc 1292578008.0 1292434240.0 -0.0% T15304(normal) ghc/alloc 1279603472.0 1279465944.0 -0.0% T15630(normal) ghc/alloc 161707776.0 161602632.0 -0.1% T16190(normal) ghc/alloc 276904644.0 276555264.0 -0.1% T16577(normal) ghc/alloc 7573033016.0 7572982752.0 -0.0% T16875(normal) ghc/alloc 34937980.0 34796592.0 -0.4% T17096(normal) ghc/alloc 287436348.0 287299368.0 -0.0% T17516(normal) ghc/alloc 1714727484.0 1714617664.0 -0.0% T17836(normal) ghc/alloc 1091095748.0 1090958168.0 -0.0% T17836b(normal) ghc/alloc 52467912.0 52321296.0 -0.3% T17977(normal) ghc/alloc 44971660.0 44826480.0 -0.3% T17977b(normal) ghc/alloc 40941128.0 40793160.0 -0.4% T18140(normal) ghc/alloc 82363124.0 82213056.0 -0.2% T18223(normal) ghc/alloc 1168448128.0 1168333624.0 -0.0% T18282(normal) ghc/alloc 131577844.0 131440400.0 -0.1% T18304(normal) ghc/alloc 86988664.0 86844432.0 -0.2% T18478(normal) ghc/alloc 742992400.0 742871136.0 -0.0% T18698a(normal) ghc/alloc 337654412.0 337526792.0 -0.0% T18698b(normal) ghc/alloc 398840772.0 398716472.0 -0.0% T18923(normal) ghc/alloc 68964992.0 68818768.0 -0.2% T1969(normal) ghc/alloc 764285884.0 764156168.0 -0.0% T19695(normal) ghc/alloc 1395577984.0 1395552552.0 -0.0% T20049(normal) ghc/alloc 89159032.0 89012952.0 -0.2% T3064(normal) ghc/alloc 191194856.0 191051816.0 -0.1% T3294(normal) ghc/alloc 1604762016.0 1604656488.0 -0.0% T4801(normal) ghc/alloc 296829368.0 296687824.0 -0.0% T5030(normal) ghc/alloc 364720540.0 364580152.0 -0.0% T5321FD(normal) ghc/alloc 271090004.0 270950824.0 -0.1% T5321Fun(normal) ghc/alloc 301244320.0 301102960.0 -0.0% T5631(normal) ghc/alloc 576154548.0 576022904.0 -0.0% T5642(normal) ghc/alloc 471105876.0 470967552.0 -0.0% T5837(normal) ghc/alloc 36328620.0 36186720.0 -0.4% T6048(optasm) ghc/alloc 103125988.0 102981024.0 -0.1% T783(normal) ghc/alloc 386945556.0 386795984.0 -0.0% T9020(optasm) ghc/alloc 247835012.0 247696704.0 -0.1% T9198(normal) ghc/alloc 47556208.0 47413784.0 -0.3% T9233(normal) ghc/alloc 682210596.0 682069960.0 -0.0% T9630(normal) ghc/alloc 1429689648.0 1429581168.0 -0.0% T9675(optasm) ghc/alloc 431092812.0 430943192.0 -0.0% T9872a(normal) ghc/alloc 1705052592.0 1705042064.0 -0.0% T9872b(normal) ghc/alloc 2180406760.0 2180395784.0 -0.0% T9872c(normal) ghc/alloc 1760508464.0 1760497936.0 -0.0% T9872d(normal) ghc/alloc 501517968.0 501309464.0 -0.0% T9961(normal) ghc/alloc 354037204.0 353891576.0 -0.0% TcPlugin_RewritePerf(normal) ghc/alloc 2381708520.0 2381550824.0 -0.0% WWRec(normal) ghc/alloc 589553520.0 589407216.0 -0.0% hard_hole_fits(normal) ghc/alloc 492122188.0 492470648.0 +0.1% hie002(normal) ghc/alloc 9336434800.0 9336443496.0 +0.0% parsing001(normal) ghc/alloc 537680944.0 537659824.0 -0.0% geo. mean -0.1% - - - - - aafa5079 by Bodigrim at 2021-12-09T04:26:35-05:00 Bump bytestring submodule to 0.11.2.0 Both tests import `Data.ByteString`, so the change in allocations is more or less expected. Metric Increase: T19695 T9630 - - - - - 803eefb1 by Matthew Pickering at 2021-12-09T04:27:11-05:00 package imports: Take into account package visibility when renaming In 806e49ae the package imports refactoring code was modified to rename package imports. There was a small oversight which meant the code didn't account for module visibility. This patch fixes that oversight. In general the "lookupPackageName" function is unsafe to use as it doesn't account for package visiblity/thinning/renaming etc, there is just one use in the compiler which would be good to audit. Fixes #20779 - - - - - 52bbea0f by Viktor Dukhovni at 2021-12-09T04:27:48-05:00 Fix typo and outdated link in Data.Foldable Amazing nobody had reported the "Foldabla" typo. :-( The Traversable docs got overhauled, leaving a stale link in Foldable to a section that got replaced. Gave the new section an anchor and updated the link. - - - - - a722859f by Viktor Dukhovni at 2021-12-09T04:27:48-05:00 A few more typos - - - - - d6177cb5 by Viktor Dukhovni at 2021-12-09T04:27:48-05:00 Drop O(n^2) warning on concat - - - - - 9f988525 by David Feuer at 2021-12-09T13:49:47+00:00 Improve mtimesDefault * Make 'mtimesDefault' use 'stimes' for the underlying monoid rather than the default 'stimes'. * Explain in the documentation why one might use `mtimesDefault`. - - - - - 2fca50d4 by Gergo ERDI at 2021-12-09T22:14:24-05:00 Use same optimization pipeline regardless of `optLevel` (#20500) - - - - - 6d031922 by Gergo ERDI at 2021-12-09T22:14:24-05:00 Add `Opt_CoreConstantFolding` to turn on constant folding (#20500) Previously, `-O1` and `-O2`, by way of their effect on the compilation pipeline, they implicitly turned on constant folding - - - - - b6f7d145 by Gergo ERDI at 2021-12-09T22:14:24-05:00 Remove `optLevel` from `DynFlags` (closes #20500) - - - - - 724df9c3 by Ryan Scott at 2021-12-09T22:15:00-05:00 Hadrian: Allow building with GHC 9.2 A separate issue is the fact that many of `hadrian`'s modules produce `-Wincomplete-uni-patterns` warnings under 9.2, but that is probably best left to a separate patch. - - - - - 80a25502 by Matthew Pickering at 2021-12-09T22:15:35-05:00 Use file hash cache when hashing object file dependencies This fixes the immediate problem that we hash the same file multiple different times which causes quite a noticeably performance regression. In the future we can probably do better than this by storing the implementation hash in the interface file rather than dependending on hashing the object file. Related to #20604 which notes some inefficiencies with the current recompilation logic. Closes #20790 ------------------------- Metric Decrease: T14052Type ------------------------- - - - - - f573cb16 by nineonine at 2021-12-10T06:16:41-05:00 rts: use allocation helpers from RtsUtils Just a tiny cleanup inspired by the following comment: https://gitlab.haskell.org/ghc/ghc/-/issues/19437#note_334271 I was just getting familiar with rts code base so I thought might as well do this. - - - - - 16eab39b by Matthew Pickering at 2021-12-10T06:17:16-05:00 Remove confusing haddock quotes in 'readInt' documentation As pointed out in #20776, placing quotes in this way linked to the 'Integral' type class which is nothing to do with 'readInt', the text should rather just be "integral", to suggest that the argument must be an integer. Closes #20776 - - - - - b4a55419 by Ben Gamari at 2021-12-10T06:17:52-05:00 docs: Drop old release notes Closes #20786 - - - - - 8d1f30e7 by Jakob Brünker at 2021-12-11T00:55:48-05:00 Add PromotedInfixT/PromotedUInfixT to TH Previously, it was not possible to refer to a data constructor using InfixT with a dynamically bound name (i.e. a name with NameFlavour `NameS` or `NameQ`) if a type constructor of the same name exists. This commit adds promoted counterparts to InfixT and UInfixT, analogously to how PromotedT is the promoted counterpart to ConT. Closes #20773 - - - - - 785859fa by Bodigrim at 2021-12-11T00:56:26-05:00 Bump text submodule to 2.0-rc2 - - - - - 352284de by Sylvain Henry at 2021-12-11T00:57:05-05:00 Perf: remove allocation in writeBlocks and fix comment (#14309) - - - - - 40a44f68 by Douglas Wilson at 2021-12-12T09:09:30-05:00 rts: correct stats when running with +RTS -qn1 Despite the documented care having been taken, several bugs are fixed here. When run with -qn1, when a SYNC_GC_PAR is requested we will have n_gc_threads == n_capabilities && n_gc_idle_threads == (n_gc_threads - 1) In this case we now: * Don't increment par_collections * Don't increment par_balanced_copied * Don't emit debug traces for idle threads * Take the fast path in scavenge_until_all_done, wakeup_gc_threads, and shutdown_gc_threads. Some ASSERTs have also been tightened. Fixes #19685 - - - - - 6b2947d2 by Matthew Pickering at 2021-12-12T09:10:06-05:00 iserv: Remove network dependent parts of libiserv As noted in #20794 the parts of libiserv and iserv-proxy depend on network, therefore are never built nor tested during CI. Due to this iserv-proxy had bitrotted due to the bound on bytestring being out of date. Given we don't test this code it seems undesirable to distribute it. Therefore, it's removed and an external maintainer can be responsible for testing it (via head.hackage if desired). Fixes #20794 - - - - - f04d1a49 by Ben Gamari at 2021-12-12T09:10:41-05:00 gitlab-ci: Bump fedora jobs to use Fedora 33 Annoyingly, this will require downstream changes in head.hackage, which depends upon the artifact produced by this job. Prompted by !6462. - - - - - 93783e6a by Andrey Mokhov at 2021-12-12T09:11:20-05:00 Drop --configure from Hadrian docs - - - - - 31bf380f by Oleg Grenrus at 2021-12-12T12:52:18-05:00 Use HasCallStack and error in GHC.List and .NonEmpty In addition to providing stack traces, the scary HasCallStack will hopefully make people think whether they want to use these functions, i.e. act as a documentation hint that something weird might happen. A single metric increased, which doesn't visibly use any method with `HasCallStack`. ------------------------- Metric Decrease: T9630 Metric Decrease: T19695 T9630 ------------------------- - - - - - 401ddd53 by Greg Steuck at 2021-12-12T12:52:56-05:00 Respect W^X in Linker.c:preloadObjectFile on OpenBSD This fixes -fexternal-interpreter for ghci. Fixes #20814. - - - - - c43ee6b8 by Andreas Klebinger at 2021-12-14T19:24:20+01:00 GHC.Utils.Misc.only: Add doc string. This function expects a singleton list as argument but only checks this in debug builds. I've added a docstring saying so. Fixes #20797 - - - - - 9ff54ea8 by Vaibhav Sagar at 2021-12-14T20:50:08-05:00 Data.Functor.Classes: fix Ord1 instance for Down - - - - - 8a2de3c2 by Tamar Christina at 2021-12-14T20:50:47-05:00 rts: update xxhash used by the linker's hashmap - - - - - 1c8d609a by alirezaghey at 2021-12-14T20:51:25-05:00 fix ambiguity in `const` documentation fixes #20412 - - - - - a5d8d47f by Joachim Breitner at 2021-12-14T20:52:00-05:00 Ghci environment: Do not remove shadowed ids Names defined earier but shadowed need to be kept around, e.g. for type signatures: ``` ghci> data T = T ghci> let t = T ghci> data T = T ghci> :t t t :: Ghci1.T ``` and indeed they can be used: ``` ghci> let t2 = Ghci1.T :: Ghci1.T ghci> :t t2 t2 :: Ghci1.T ``` However, previously this did not happen for ids (non-types), although they are still around under the qualified name internally: ``` ghci> let t = "other t" ghci> t' <interactive>:8:1: error: • Variable not in scope: t' • Perhaps you meant one of these: ‘Ghci2.t’ (imported from Ghci2), ‘t’ (line 7), ‘t2’ (line 5) ghci> Ghci2.t <interactive>:9:1: error: • GHC internal error: ‘Ghci2.t’ is not in scope during type checking, but it passed the renamer tcl_env of environment: [] • In the expression: Ghci2.t In an equation for ‘it’: it = Ghci2.t ``` This fixes the problem by simply removing the code that tries to remove shadowed ids from the environment. Now you can refer to shadowed ids using `Ghci2.t`, just like you can do for data and type constructors. This simplifies the code, makes terms and types more similar, and also fixes #20455. Now all names ever defined in GHCi are in `ic_tythings`, which is printed by `:show bindings`. But for that commands, it seems to be more ergonomic to only list those bindings that are not shadowed. Or, even if it is not more ergonomic, it’s the current behavour. So let's restore that by filtering in `icInScopeTTs`. Of course a single `TyThing` can be associated with many names. We keep it it in the bindings if _any_ of its names are still visible unqualifiedly. It's a judgement call. This commit also turns a rather old comment into a test files. The comment is is rather stale and things are better explained elsewhere. Fixes #925. Two test cases are regressing: T14052(ghci) ghc/alloc 2749444288.0 12192109912.0 +343.4% BAD T14052Type(ghci) ghc/alloc 7365784616.0 10767078344.0 +46.2% BAD This is not unexpected; the `ic_tythings list grows` a lot more if we don’t remove shadowed Ids. I tried to alleviate it a bit with earlier MRs, but couldn’t make up for it completely. Metric Increase: T14052 T14052Type - - - - - 7c2609d8 by Cheng Shao at 2021-12-14T20:52:37-05:00 base: fix clockid_t usage when it's a pointer type in C Closes #20607. - - - - - 55cb2aa7 by MichaWiedenmann1 at 2021-12-14T20:53:16-05:00 Fixes typo in documentation of the Semigroup instance of Equivalence - - - - - 82c39f4d by Ben Gamari at 2021-12-14T20:53:51-05:00 users-guide: Fix documentation for -shared flag This flag was previously called `--mk-dll`. It was renamed to `-shared` in b562cbe381d54e08dcafa11339e9a82e781ad557 but the documentation wasn't updated to match. - - - - - 4f654071 by Ben Gamari at 2021-12-14T20:53:51-05:00 compiler: Drop `Maybe ModLocation` from T_MergeForeign This field was entirely unused. - - - - - 71ecb55b by Ben Gamari at 2021-12-14T20:53:51-05:00 compiler: Use withFile instead of bracket A minor refactoring noticed by hlint. - - - - - 5686f47b by Ben Gamari at 2021-12-14T20:53:51-05:00 ghc-bin: Add --merge-objs mode This adds a new mode, `--merge-objs`, which can be used to produce merged GHCi library objects. As future work we will rip out the object-merging logic in Hadrian and Cabal and instead use this mode. Closes #20712. - - - - - 0198bb11 by Ben Gamari at 2021-12-14T20:54:27-05:00 libiserv: Rename Lib module to IServ As proposed in #20546. - - - - - ecaec722 by doyougnu at 2021-12-14T20:55:06-05:00 CmmToLlvm: Remove DynFlags, add LlvmCgConfig CodeOutput: LCGConfig, add handshake initLCGConfig Add two modules: GHC.CmmToLlvm.Config -- to hold the Llvm code gen config GHC.Driver.Config.CmmToLlvm -- for initialization, other utils CmmToLlvm: remove HasDynFlags, add LlvmConfig CmmToLlvm: add lcgContext to LCGConfig CmmToLlvm.Base: DynFlags --> LCGConfig Llvm: absorb LlvmOpts into LCGConfig CmmToLlvm.Ppr: swap DynFlags --> LCGConfig CmmToLlvm.CodeGen: swap DynFlags --> LCGConfig CmmToLlvm.CodeGen: swap DynFlags --> LCGConfig CmmToLlvm.Data: swap LlvmOpts --> LCGConfig CmmToLlvm: swap DynFlags --> LCGConfig CmmToLlvm: move LlvmVersion to CmmToLlvm.Config Additionally: - refactor Config and initConfig to hold LlvmVersion - push IO needed to get LlvmVersion to boundary between Cmm and LLvm code generation - remove redundant imports, this is much cleaner! CmmToLlvm.Config: store platformMisc_llvmTarget instead of all of platformMisc - - - - - 6b0fb9a0 by doyougnu at 2021-12-14T20:55:06-05:00 SysTools.Tasks Llvm.Types: remove redundant import Llvm.Types: remove redundant import SysTools.Tasks: remove redundant import - namely CmmToLlvm.Base - - - - - 80016022 by doyougnu at 2021-12-14T20:55:06-05:00 LLVM.CodeGen: use fast-string literals That is remove factorization of common strings and string building code for the LLVM code gen ops. Replace these with string literals to obey the FastString rewrite rule in GHC.Data.FastString and compute the string length at compile time - - - - - bc663f87 by doyougnu at 2021-12-14T20:55:06-05:00 CmmToLlvm.Config: strictify LlvmConfig field - - - - - 70f0aafe by doyougnu at 2021-12-14T20:55:06-05:00 CmmToLlvm: rename LCGConfig -> LlvmCgConfig CmmToLlvm: renamce lcgPlatform -> llvmCgPlatform CmmToLlvm: rename lcgContext -> llvmCgContext CmmToLlvm: rename lcgFillUndefWithGarbage CmmToLlvm: rename lcgSplitSections CmmToLlvm: lcgBmiVersion -> llvmCgBmiVersion CmmToLlvm: lcgLlvmVersion -> llvmCgLlvmVersion CmmToLlvm: lcgDoWarn -> llvmCgDoWarn CmmToLlvm: lcgLlvmConfig -> llvmCgLlvmConfig CmmToLlvm: llvmCgPlatformMisc --> llvmCgLlvmTarget - - - - - 34abbd81 by Greg Steuck at 2021-12-14T20:55:43-05:00 Add OpenBSD to llvm-targets This improves some tests that previously failed with: ghc: panic! (the 'impossible' happened) GHC version 9.3.20211211: Failed to lookup LLVM data layout Target: x86_64-unknown-openbsd Added the new generated lines to `llvm-targets` on an openbsd 7.0-current with clang 11.1.0. - - - - - 45bd6308 by Joachim Breitner at 2021-12-14T20:56:18-05:00 Test case from #19313 - - - - - f5a0b408 by Andrei Barbu at 2021-12-15T16:33:17-05:00 Plugin load order should follow the commandline order (fixes #17884) In the past the order was reversed because flags are consed onto a list. No particular behavior was documented. We now reverse the flags and document the behavior. - - - - - d13b9f20 by Cheng Shao at 2021-12-15T16:33:54-05:00 base: use `CUIntPtr` instead of `Ptr ()` as the autoconf detected Haskell type for C pointers When autoconf detects a C pointer type, we used to specify `Ptr ()` as the Haskell type. This doesn't work in some cases, e.g. in `wasi-libc`, `clockid_t` is a pointer type, but we expected `CClockId` to be an integral type, and `Ptr ()` lacks various integral type instances. - - - - - 89c1ffd6 by Cheng Shao at 2021-12-15T16:33:54-05:00 base: fix autoconf detection of C pointer types We used to attempt compiling `foo_t val; *val;` to determine if `foo_t` is a pointer type in C. This doesn't work if `foo_t` points to an incomplete type, and autoconf will detect `foo_t` as a floating point type in that case. Now we use `memset(val, 0, 0)` instead, and it works for incomplete types as well. - - - - - 6cea7311 by Cheng Shao at 2021-12-15T16:33:54-05:00 Add a note to base changelog - - - - - 3c3e5c03 by Ben Gamari at 2021-12-17T21:20:57-05:00 Regression test for renamer/typechecker performance (#20261) We use the parser generated by stack to ensure reproducibility - - - - - 5d5620bc by Krzysztof Gogolewski at 2021-12-17T21:21:32-05:00 Change isUnliftedTyCon to marshalablePrimTyCon (#20401) isUnliftedTyCon was used in three places: Ticky, Template Haskell and FFI checks. It was straightforward to remove it from Ticky and Template Haskell. It is now used in FFI only and renamed to marshalablePrimTyCon. Previously, it was fetching information from a field in PrimTyCon called is_unlifted. Instead, I've changed the code to compute liftedness based on the kind. isFFITy and legalFFITyCon are removed. They were only referred from an old comment that I removed. There were three functions to define a PrimTyCon, but the only difference was that they were setting is_unlifted to True or False. Everything is now done in mkPrimTyCon. I also added missing integer types in Ticky.hs, I think it was an oversight. Fixes #20401 - - - - - 9d77976d by Matthew Pickering at 2021-12-17T21:22:08-05:00 testsuite: Format metric results with comma separator As noted in #20763 the way the stats were printed was quite hard for a human to compare. Therefore we now insert the comma separator so that they are easier to compare at a glance. Before: ``` Baseline Test Metric value New value Change ----------------------------------------------------------------------------- Conversions(normal) run/alloc 107088.0 107088.0 +0.0% DeriveNull(normal) run/alloc 112050656.0 112050656.0 +0.0% InlineArrayAlloc(normal) run/alloc 1600040712.0 1600040712.0 +0.0% InlineByteArrayAlloc(normal) run/alloc 1440040712.0 1440040712.0 +0.0% InlineCloneArrayAlloc(normal) run/alloc 1600040872.0 1600040872.0 +0.0% MethSharing(normal) run/alloc 480097864.0 480097864.0 +0.0% T10359(normal) run/alloc 354344.0 354344.0 +0.0% ``` After ``` Baseline Test Metric value New value Change ---------------------------------------------------------------------------------- Conversions(normal) run/alloc 107,088 107,088 +0.0% DeriveNull(normal) run/alloc 112,050,656 112,050,656 +0.0% InlineArrayAlloc(normal) run/alloc 1,600,040,712 1,600,040,712 +0.0% InlineByteArrayAlloc(normal) run/alloc 1,440,040,712 1,440,040,712 +0.0% InlineCloneArrayAlloc(normal) run/alloc 1,600,040,872 1,600,040,872 +0.0% MethSharing(normal) run/alloc 480,097,864 480,097,864 +0.0% T10359(normal) run/alloc 354,344 354,344 +0.0% ``` Closes #20763 - - - - - 3f31bfe8 by Sylvain Henry at 2021-12-17T21:22:48-05:00 Perf: inline exprIsCheapX Allow specialization for the ok_app predicate. Perf improvements: Baseline Test Metric value New value Change ----------------------------------------------------------------------------- ManyAlternatives(normal) ghc/alloc 747317244.0 746444024.0 -0.1% ManyConstructors(normal) ghc/alloc 4005046448.0 4001548792.0 -0.1% MultiLayerModules(normal) ghc/alloc 3063361000.0 3063178472.0 -0.0% MultiLayerModulesRecomp(normal) ghc/alloc 894208428.0 894252496.0 +0.0% PmSeriesG(normal) ghc/alloc 48021692.0 47901592.0 -0.3% PmSeriesS(normal) ghc/alloc 61322504.0 61149008.0 -0.3% PmSeriesT(normal) ghc/alloc 90879364.0 90609048.0 -0.3% PmSeriesV(normal) ghc/alloc 60155376.0 59983632.0 -0.3% T10421(normal) ghc/alloc 112820720.0 112517208.0 -0.3% T10421a(normal) ghc/alloc 78783696.0 78557896.0 -0.3% T10547(normal) ghc/alloc 28331984.0 28354160.0 +0.1% T10858(normal) ghc/alloc 180715296.0 180226720.0 -0.3% T11195(normal) ghc/alloc 284139184.0 283981048.0 -0.1% T11276(normal) ghc/alloc 137830804.0 137688912.0 -0.1% T11303b(normal) ghc/alloc 44080856.0 43956152.0 -0.3% T11374(normal) ghc/alloc 249319644.0 249059288.0 -0.1% T11545(normal) ghc/alloc 971507488.0 971146136.0 -0.0% T11822(normal) ghc/alloc 131410208.0 131269664.0 -0.1% T12150(optasm) ghc/alloc 78866860.0 78762296.0 -0.1% T12227(normal) ghc/alloc 494467900.0 494138112.0 -0.1% T12234(optasm) ghc/alloc 56781044.0 56588256.0 -0.3% T12425(optasm) ghc/alloc 90462264.0 90240272.0 -0.2% T12545(normal) ghc/alloc 1694316588.0 1694128448.0 -0.0% T12707(normal) ghc/alloc 955665168.0 955005336.0 -0.1% T13035(normal) ghc/alloc 101875160.0 101713312.0 -0.2% T13056(optasm) ghc/alloc 366370168.0 365347632.0 -0.3% T13253(normal) ghc/alloc 333741472.0 332612920.0 -0.3% T13253-spj(normal) ghc/alloc 124947560.0 124427552.0 -0.4% T13379(normal) ghc/alloc 358997996.0 358879840.0 -0.0% T13701(normal) ghc/alloc 2400391456.0 2399956840.0 -0.0% T13719(normal) ghc/alloc 4193179228.0 4192476392.0 -0.0% T14052(ghci) ghc/alloc 2734741552.0 2735731808.0 +0.0% T14052Type(ghci) ghc/alloc 7323235724.0 7323042264.0 -0.0% T14683(normal) ghc/alloc 2990457260.0 2988899144.0 -0.1% T14697(normal) ghc/alloc 363606476.0 363452952.0 -0.0% T15164(normal) ghc/alloc 1291321780.0 1289491968.0 -0.1% T15304(normal) ghc/alloc 1277838020.0 1276208304.0 -0.1% T15630(normal) ghc/alloc 161074632.0 160388136.0 -0.4% T16190(normal) ghc/alloc 276567192.0 276235216.0 -0.1% T16577(normal) ghc/alloc 7564318656.0 7535598656.0 -0.4% T16875(normal) ghc/alloc 34867720.0 34752440.0 -0.3% T17096(normal) ghc/alloc 288477360.0 288156960.0 -0.1% T17516(normal) ghc/alloc 1712777224.0 1704655496.0 -0.5% T17836(normal) ghc/alloc 1092127336.0 1091709880.0 -0.0% T17836b(normal) ghc/alloc 52083516.0 51954056.0 -0.2% T17977(normal) ghc/alloc 44552228.0 44425448.0 -0.3% T17977b(normal) ghc/alloc 40540252.0 40416856.0 -0.3% T18140(normal) ghc/alloc 81908200.0 81678928.0 -0.3% T18223(normal) ghc/alloc 1166459176.0 1164418104.0 -0.2% T18282(normal) ghc/alloc 131123648.0 130740432.0 -0.3% T18304(normal) ghc/alloc 86486796.0 86223088.0 -0.3% T18478(normal) ghc/alloc 746029440.0 745619968.0 -0.1% T18698a(normal) ghc/alloc 337037580.0 336533824.0 -0.1% T18698b(normal) ghc/alloc 398324600.0 397696400.0 -0.2% T18923(normal) ghc/alloc 68496432.0 68286264.0 -0.3% T1969(normal) ghc/alloc 760424696.0 759641664.0 -0.1% T19695(normal) ghc/alloc 1421672472.0 1413682104.0 -0.6% T20049(normal) ghc/alloc 88601524.0 88336560.0 -0.3% T3064(normal) ghc/alloc 190808832.0 190659328.0 -0.1% T3294(normal) ghc/alloc 1604483120.0 1604339080.0 -0.0% T4801(normal) ghc/alloc 296501624.0 296388448.0 -0.0% T5030(normal) ghc/alloc 364336308.0 364206240.0 -0.0% T5321FD(normal) ghc/alloc 270688492.0 270386832.0 -0.1% T5321Fun(normal) ghc/alloc 300860396.0 300559200.0 -0.1% T5631(normal) ghc/alloc 575822760.0 575579160.0 -0.0% T5642(normal) ghc/alloc 470243356.0 468988784.0 -0.3% T5837(normal) ghc/alloc 35936468.0 35821360.0 -0.3% T6048(optasm) ghc/alloc 102587024.0 102222000.0 -0.4% T783(normal) ghc/alloc 386539204.0 386003344.0 -0.1% T9020(optasm) ghc/alloc 247435312.0 247324184.0 -0.0% T9198(normal) ghc/alloc 47170036.0 47054840.0 -0.2% T9233(normal) ghc/alloc 677186820.0 676550032.0 -0.1% T9630(normal) ghc/alloc 1456411516.0 1451045736.0 -0.4% T9675(optasm) ghc/alloc 427190224.0 426812568.0 -0.1% T9872a(normal) ghc/alloc 1704660040.0 1704681856.0 +0.0% T9872b(normal) ghc/alloc 2180109488.0 2180130856.0 +0.0% T9872c(normal) ghc/alloc 1760209640.0 1760231456.0 +0.0% T9872d(normal) ghc/alloc 501126052.0 500973488.0 -0.0% T9961(normal) ghc/alloc 353244688.0 353063104.0 -0.1% TcPlugin_RewritePerf(normal) ghc/alloc 2387276808.0 2387254168.0 -0.0% WWRec(normal) ghc/alloc 588651140.0 587684704.0 -0.2% hard_hole_fits(normal) ghc/alloc 492063812.0 491798360.0 -0.1% hie002(normal) ghc/alloc 9334355960.0 9334396872.0 +0.0% parsing001(normal) ghc/alloc 537410584.0 537421736.0 +0.0% geo. mean -0.2% - - - - - e04878b0 by Matthew Pickering at 2021-12-17T21:23:23-05:00 ci: Use correct metrics baseline It turns out there was already a function in the CI script to correctly set the baseline for performance tests but it was just never called. I now call it during the initialisation to set the correct baseline. I also made the make testsuite driver take into account the PERF_BASELINE_COMMIT environment variable Fixes #20811 - - - - - 1327c176 by Matthew Pickering at 2021-12-17T21:23:58-05:00 Add regression test for T20189 Closes #20189 - - - - - fc9b1755 by Matthew Pickering at 2021-12-17T21:24:33-05:00 Fix documentation formatting in Language.Haskell.TH.CodeDo Fixes #20543 - - - - - abef93f3 by Matthew Pickering at 2021-12-17T21:24:33-05:00 Expand documentation for MulArrowT constructor Fixes #20812 - - - - - 94c3ff66 by Cheng Shao at 2021-12-17T21:25:09-05:00 Binary: make withBinBuffer safe With this patch, withBinBuffer will construct a ByteString that properly captures the reference to the BinHandle internal MutableByteArray#, making it safe to convert a BinHandle to ByteString and use that ByteString outside the continuation. - - - - - a3552934 by Sebastian Graf at 2021-12-17T21:25:45-05:00 Demand: `Eq DmdType` modulo `defaultFvDmd` (#20827) Fixes #20827 by filtering out any default free variable demands (as per `defaultFvDmd`) prior to comparing the assocs of the `DmdEnv`. The details are in `Note [Demand type Equality]`. - - - - - 9529d859 by Sylvain Henry at 2021-12-17T21:26:24-05:00 Perf: avoid using (replicateM . length) when possible Extracted from !6622 - - - - - 887d8b4c by Matthew Pickering at 2021-12-17T21:26:59-05:00 testsuite: Ensure that -dcore-lint is not set for compiler performance tests This place ensures that the default -dcore-lint option is disabled by default when collect_compiler_stats is used but you can still pass -dcore-lint as an additional option (see T1969 which tests core lint performance). Fixes #20830 ------------------------- Metric Decrease: PmSeriesS PmSeriesT PmSeriesV T10858 T11195 T11276 T11374 T11822 T14052 T14052Type T17096 T17836 T17836b T18478 T18698a T18698b ------------------------- - - - - - 5ff47ff5 by Ben Gamari at 2021-12-21T01:46:00-05:00 codeGen: Introduce flag to bounds-check array accesses Here we introduce code generator support for instrument array primops with bounds checking, enabled with the `-fcheck-prim-bounds` flag. Introduced to debug #20769. - - - - - d47bb109 by Ben Gamari at 2021-12-21T01:46:00-05:00 rts: Add optional bounds checking in out-of-line primops - - - - - 8ea79a16 by Ben Gamari at 2021-12-21T01:46:00-05:00 Rename -fcatch-bottoms to -fcatch-nonexhaustive-cases As noted in #20601, the previous name was rather misleading. - - - - - 00b55bfc by Ben Gamari at 2021-12-21T01:46:00-05:00 Introduce -dlint flag As suggested in #20601, this is a short-hand for enabling the usual GHC-internal sanity checks one typically leans on when debugging runtime crashes. - - - - - 9728d6c2 by Sylvain Henry at 2021-12-21T01:46:39-05:00 Give plugins a better interface (#17957) Plugins were directly fetched from HscEnv (hsc_static_plugins and hsc_plugins). The tight coupling of plugins and of HscEnv is undesirable and it's better to store them in a new Plugins datatype and to use it in the plugins' API (e.g. withPlugins, mapPlugins...). In the process, the interactive context (used by GHCi) got proper support for different static plugins than those used for loaded modules. Bump haddock submodule - - - - - 9bc5ab64 by Greg Steuck at 2021-12-21T01:47:17-05:00 Use libc++ instead of libstdc++ on openbsd in addition to freebsd This is not entirely accurate because some openbsd architectures use gcc. Yet we don't have ghc ported to them and thus the approximation is good enough. Fixes ghcilink006 test - - - - - f92c9c0d by Greg Steuck at 2021-12-21T01:47:55-05:00 Only use -ldl conditionally to fix T3807 OpenBSD doesn't have this library and so the linker complains: ld.lld: error: unable to find library -ldl - - - - - ff657a81 by Greg Steuck at 2021-12-21T01:48:32-05:00 Mark `linkwhole` test as expected broken on OpenBSD per #20841 - - - - - 1a596d06 by doyougnu at 2021-12-22T00:12:27-05:00 Cmm: DynFlags to CmmConfig refactor add files GHC.Cmm.Config, GHC.Driver.Config.Cmm Cmm: DynFlag references --> CmmConfig Cmm.Pipeline: reorder imports, add handshake Cmm: DynFlag references --> CmmConfig Cmm.Pipeline: DynFlag references --> CmmConfig Cmm.LayoutStack: DynFlag references -> CmmConfig Cmm.Info.Build: DynFlag references -> CmmConfig Cmm.Config: use profile to retrieve platform Cmm.CLabel: unpack NCGConfig in labelDynamic Cmm.Config: reduce CmmConfig surface area Cmm.Config: add cmmDoCmmSwitchPlans field Cmm.Config: correct cmmDoCmmSwitchPlans flag The original implementation dispatches work in cmmImplementSwitchPlans in an `otherwise` branch, hence we must add a not to correctly dispatch Cmm.Config: add cmmSplitProcPoints simplify Config remove cmmBackend, and cmmPosInd Cmm.CmmToAsm: move ncgLabelDynamic to CmmToAsm Cmm.CLabel: remove cmmLabelDynamic function Cmm.Config: rename cmmOptDoLinting -> cmmDoLinting testsuite: update CountDepsAst CountDepsParser - - - - - d7cc8f19 by Matthew Pickering at 2021-12-22T00:13:02-05:00 ci: Fix master CI I made a mistake in the bash script so there were errors about "$CI_MERGE_REQUEST_DIFF_BASE_SHA" not existing. - - - - - 09b6cb45 by Alan Zimmerman at 2021-12-22T00:13:38-05:00 Fix panic trying to -ddump-parsed-ast for implicit fixity A declaration such as infixr ++++ is supplied with an implicit fixity of 9 in the parser, but uses an invalid SrcSpan to capture this. Use of this span triggers a panic. Fix the problem by not recording an exact print annotation for the non-existent fixity source. Closes #20846 - - - - - 3ed90911 by Matthew Pickering at 2021-12-22T14:47:40-05:00 testsuite: Remove reqlib modifier The reqlib modifer was supposed to indicate that a test needed a certain library in order to work. If the library happened to be installed then the test would run as normal. However, CI has never run these tests as the packages have not been installed and we don't want out tests to depend on things which might get externally broken by updating the compiler. The new strategy is to run these tests in head.hackage, where the tests have been cabalised as well as possible. Some tests couldn't be transferred into the normal style testsuite but it's better than never running any of the reqlib tests. https://gitlab.haskell.org/ghc/head.hackage/-/merge_requests/169 A few submodules also had reqlib tests and have been updated to remove it. Closes #16264 #20032 #17764 #16561 - - - - - ac3e8c52 by Matthew Pickering at 2021-12-22T14:48:16-05:00 perf ci: Start searching form the performance baseline If you specify PERF_BASELINE_COMMIT then this can fail if the specific commit you selected didn't have perf test metrics. (This can happen in CI for example if a build fails on master). Therefore instead of just reporting all tests as new, we start searching downwards from this point to try and find a good commit to report numbers from. - - - - - 9552781a by Matthew Pickering at 2021-12-22T14:48:51-05:00 Mark T16525b as fragile on windows See ticket #20852 - - - - - 13a6d85a by Andreas Klebinger at 2021-12-23T10:55:36-05:00 Make callerCC profiling mode represent entry counter flag. Fixes #20854 - - - - - 80daefce by Matthew Pickering at 2021-12-23T10:56:11-05:00 Properly filter for module visibility in resolvePackageImport This completes the fix for #20779 / !7123. Beforehand, the program worked by accident because the two versions of the library happened to be ordered properly (due to how the hashes were computed). In the real world I observed them being the other way around which meant the final lookup failed because we weren't filtering for visibility. I modified the test so that it failed (and it's fixed by this patch). - - - - - e6191d39 by Krzysztof Gogolewski at 2021-12-25T18:26:44+01:00 Fix typos - - - - - 3219610e by Greg Steuck at 2021-12-26T22:12:43-05:00 Use POSIX-compliant egrep expression to fix T8832 on OpenBSD - - - - - fd42ab5f by Matthew Pickering at 2021-12-28T09:47:53+00:00 Multiple Home Units Multiple home units allows you to load different packages which may depend on each other into one GHC session. This will allow both GHCi and HLS to support multi component projects more naturally. Public Interface ~~~~~~~~~~~~~~~~ In order to specify multiple units, the -unit @⟨filename⟩ flag is given multiple times with a response file containing the arguments for each unit. The response file contains a newline separated list of arguments. ``` ghc -unit @unitLibCore -unit @unitLib ``` where the `unitLibCore` response file contains the normal arguments that cabal would pass to `--make` mode. ``` -this-unit-id lib-core-0.1.0.0 -i -isrc LibCore.Utils LibCore.Types ``` The response file for lib, can specify a dependency on lib-core, so then modules in lib can use modules from lib-core. ``` -this-unit-id lib-0.1.0.0 -package-id lib-core-0.1.0.0 -i -isrc Lib.Parse Lib.Render ``` Then when the compiler starts in --make mode it will compile both units lib and lib-core. There is also very basic support for multiple home units in GHCi, at the moment you can start a GHCi session with multiple units but only the :reload is supported. Most commands in GHCi assume a single home unit, and so it is additional work to work out how to modify the interface to support multiple loaded home units. Options used when working with Multiple Home Units There are a few extra flags which have been introduced specifically for working with multiple home units. The flags allow a home unit to pretend it’s more like an installed package, for example, specifying the package name, module visibility and reexported modules. -working-dir ⟨dir⟩ It is common to assume that a package is compiled in the directory where its cabal file resides. Thus, all paths used in the compiler are assumed to be relative to this directory. When there are multiple home units the compiler is often not operating in the standard directory and instead where the cabal.project file is located. In this case the -working-dir option can be passed which specifies the path from the current directory to the directory the unit assumes to be it’s root, normally the directory which contains the cabal file. When the flag is passed, any relative paths used by the compiler are offset by the working directory. Notably this includes -i and -I⟨dir⟩ flags. -this-package-name ⟨name⟩ This flag papers over the awkward interaction of the PackageImports and multiple home units. When using PackageImports you can specify the name of the package in an import to disambiguate between modules which appear in multiple packages with the same name. This flag allows a home unit to be given a package name so that you can also disambiguate between multiple home units which provide modules with the same name. -hidden-module ⟨module name⟩ This flag can be supplied multiple times in order to specify which modules in a home unit should not be visible outside of the unit it belongs to. The main use of this flag is to be able to recreate the difference between an exposed and hidden module for installed packages. -reexported-module ⟨module name⟩ This flag can be supplied multiple times in order to specify which modules are not defined in a unit but should be reexported. The effect is that other units will see this module as if it was defined in this unit. The use of this flag is to be able to replicate the reexported modules feature of packages with multiple home units. Offsetting Paths in Template Haskell splices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When using Template Haskell to embed files into your program, traditionally the paths have been interpreted relative to the directory where the .cabal file resides. This causes problems for multiple home units as we are compiling many different libraries at once which have .cabal files in different directories. For this purpose we have introduced a way to query the value of the -working-dir flag to the Template Haskell API. By using this function we can implement a makeRelativeToProject function which offsets a path which is relative to the original project root by the value of -working-dir. ``` import Language.Haskell.TH.Syntax ( makeRelativeToProject ) foo = $(makeRelativeToProject "./relative/path" >>= embedFile) ``` > If you write a relative path in a Template Haskell splice you should use the makeRelativeToProject function so that your library works correctly with multiple home units. A similar function already exists in the file-embed library. The function in template-haskell implements this function in a more robust manner by honouring the -working-dir flag rather than searching the file system. Closure Property for Home Units ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For tools or libraries using the API there is one very important closure property which must be adhered to: > Any dependency which is not a home unit must not (transitively) depend on a home unit. For example, if you have three packages p, q and r, then if p depends on q which depends on r then it is illegal to load both p and r as home units but not q, because q is a dependency of the home unit p which depends on another home unit r. If you are using GHC by the command line then this property is checked, but if you are using the API then you need to check this property yourself. If you get it wrong you will probably get some very confusing errors about overlapping instances. Limitations of Multiple Home Units ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are a few limitations of the initial implementation which will be smoothed out on user demand. * Package thinning/renaming syntax is not supported * More complicated reexports/renaming are not yet supported. * It’s more common to run into existing linker bugs when loading a large number of packages in a session (for example #20674, #20689) * Backpack is not yet supported when using multiple home units. * Dependency chasing can be quite slow with a large number of modules and packages. * Loading wired-in packages as home units is currently not supported (this only really affects GHC developers attempting to load template-haskell). * Barely any normal GHCi features are supported, it would be good to support enough for ghcid to work correctly. Despite these limitations, the implementation works already for nearly all packages. It has been testing on large dependency closures, including the whole of head.hackage which is a total of 4784 modules from 452 packages. Internal Changes ~~~~~~~~~~~~~~~~ * The biggest change is that the HomePackageTable is replaced with the HomeUnitGraph. The HomeUnitGraph is a map from UnitId to HomeUnitEnv, which contains information specific to each home unit. * The HomeUnitEnv contains: - A unit state, each home unit can have different package db flags - A set of dynflags, each home unit can have different flags - A HomePackageTable * LinkNode: A new node type is added to the ModuleGraph, this is used to place the linking step into the build plan so linking can proceed in parralel with other packages being built. * New invariant: Dependencies of a ModuleGraphNode can be completely determined by looking at the value of the node. In order to achieve this, downsweep now performs a more complete job of downsweeping and then the dependenices are recorded forever in the node rather than being computed again from the ModSummary. * Some transitive module calculations are rewritten to use the ModuleGraph which is more efficient. * There is always an active home unit, which simplifies modifying a lot of the existing API code which is unit agnostic (for example, in the driver). The road may be bumpy for a little while after this change but the basics are well-tested. One small metric increase, which we accept and also submodule update to haddock which removes ExtendedModSummary. Closes #10827 ------------------------- Metric Increase: MultiLayerModules ------------------------- Co-authored-by: Fendor <power.walross at gmail.com> - - - - - 72824c63 by Richard Eisenberg at 2021-12-28T10:09:28-05:00 Skip computing superclass origins for equalities This yields a small, but measurable, performance improvement. - - - - - 8b6aafb2 by Matthew Pickering at 2021-12-29T14:09:47-05:00 Cabal: Update submodule Closes #20874 - - - - - 44a5507f by Peter Trommler at 2021-12-29T14:10:22-05:00 RTS: Fix CloneStack.c when no table next to code Function `lookupIPE` does not modify its argument. Reflect this in the type. Module `CloneStack.c` relies on this for RTS without tables next to code. Fixes #20879 - - - - - 246d2782 by sheaf at 2022-01-02T04:20:09-05:00 User's guide: newtype decls can use GADTSyntax The user's guide failed to explicitly mention that GADTSyntax can be used to declare newtypes, so we add an example and a couple of explanations. Also explains that `-XGADTs` generalises `-XExistentialQuantification`. Fixes #20848 and #20865. - - - - - f212cece by Hécate Moonlight at 2022-01-02T04:20:47-05:00 Add a source-repository stanza to rts/rts.cabal - - - - - d9e49195 by Greg Steuck at 2022-01-03T05:18:24+00:00 Replace `seq` with POSIX-standard printf(1) in ManyAlternatives test The test now passes on OpenBSD instead of generating broken source which was rejected by GHC with ManyAlternatives.hs:5:1: error: The type signature for ‘f’ lacks an accompanying binding - - - - - 80e416ae by Greg Steuck at 2022-01-03T05:18:24+00:00 Replace `seq` with POSIX-standard in PmSeriesG test - - - - - 8fa52f5c by Eric Lindblad at 2022-01-03T16:48:51-05:00 fix typo - - - - - a49f5889 by Roland Senn at 2022-01-03T16:49:29-05:00 Add regressiontest for #18045 Issue #18045 got fixed by !6971. - - - - - 7f10686e by sheaf at 2022-01-03T16:50:07-05:00 Add test for #20894 - - - - - 5111028e by sheaf at 2022-01-04T19:56:13-05:00 Check quoted TH names are in the correct namespace When quoting (using a TH single or double quote) a built-in name such as the list constructor (:), we didn't always check that the resulting 'Name' was in the correct namespace. This patch adds a check in GHC.Rename.Splice to ensure we get a Name that is in the term-level/type-level namespace, when using a single/double tick, respectively. Fixes #20884. - - - - - 1de94daa by George Thomas at 2022-01-04T19:56:51-05:00 Fix Haddock parse error in GHC.Exts.Heap.FFIClosures.hs - - - - - e59bd46a by nineonine at 2022-01-05T18:07:18+00:00 Add regression test (#13997) - - - - - c080b443 by Sylvain Henry at 2022-01-06T02:24:54-05:00 Perf: use SmallArray for primops' Ids cache (#20857) SmallArray doesn't perform bounds check (faster). Make primop tags start at 0 to avoid index arithmetic. - - - - - ec26c38b by Sylvain Henry at 2022-01-06T02:24:54-05:00 Use primOpIds cache more often (#20857) Use primOpId instead of mkPrimOpId in a few places to benefit from Id caching. I had to mess a little bit with the module hierarchy to fix cycles and to avoid adding too many new dependencies to count-deps tests. - - - - - f7fc62e2 by Greg Steuck at 2022-01-06T07:56:22-05:00 Disable T2615 on OpenBSD, close #20869 - - - - - 978ea35e by Greg Steuck at 2022-01-06T07:57:00-05:00 Change ulimit -n in openFile008 back to 1024 The test only wants 1000 descriptors, so changing the limit to double that *in the context of just this test* makes no sense. This is a manual revert of 8f7194fae23bdc6db72fc5784933f50310ce51f9. The justification given in the description doesn't instill confidence. As of HEAD, the test fails on OpenBSD where ulimit -n is hard-limited to 1024. The test suite attempts to change it to 2048, which fails. The test proceeds with the unchanged default of 512 and naturally the test program fails due to the low ulimit. The fixed test now passes. - - - - - 7b783c9d by Matthew Pickering at 2022-01-07T18:25:06-05:00 Thoughtful forcing in CoreUnfolding We noticed that the structure of CoreUnfolding could leave double the amount of CoreExprs which were retained in the situation where the template but not all the predicates were forced. This observation was then confirmed using ghc-debug: ``` (["ghc:GHC.Core:App","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 237) (["ghc:GHC.Core:App","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 1) (["ghc:GHC.Core:Case","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 12) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","BLACKHOLE"],Count 1) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 78) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","THUNK_1_0","ghc-prim:GHC.Types:False","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","THUNK_1_0","THUNK_1_0"],Count 3) (["ghc:GHC.Core:Cast","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","BLACKHOLE"],Count 31) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 4307) (["ghc:GHC.Core:Lam","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 6) (["ghc:GHC.Core:Let","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 29) (["ghc:GHC.Core:Lit","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","ghc-prim:GHC.Types:True"],Count 1) (["ghc:GHC.Core:Tick","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 36) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","THUNK_1_0","THUNK_1_0","THUNK_1_0"],Count 1) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","THUNK_1_0","THUNK_1_0"],Count 6) (["ghc:GHC.Core:Var","ghc-prim:GHC.Types:True","ghc-prim:GHC.Types:False","ghc-prim:GHC.Types:True","THUNK_1_0"],Count 2) ``` Where we can see that the first argument is forced but there are still thunks remaining which retain the old expr. For my test case (a very big module, peak of 3 000 000 core terms) this reduced peak memory usage by 1G (12G -> 11G). Fixes #20905 - - - - - f583eb8e by Joachim Breitner at 2022-01-07T18:25:41-05:00 Remove dangling references to Note [Type-checking overloaded labels] that note was removed in 4196969c53c55191e644d9eb258c14c2bc8467da - - - - - 2b6c2179 by Matthew Pickering at 2022-01-11T19:37:45-05:00 hadrian: Add bootstrap scripts for building without cabal-install These scripts are originally from the cabal-install repo with a few small tweaks. This utility allows you to build hadrian without cabal-install, which can be useful for packagers. If you are a developer then build hadrian using cabal-install. If you want to bootstrap with ghc-8.10.5 then run the ./bootstrap script with the `plan-bootstrap-8.10.5.json` file. bootstrap.py -d plan-bootstrap-8.10.5.json -w /path/to-ghc The result of the bootstrap script will be a hadrian binary in `_build/bin/hadrian`. There is a script (using nix) which can be used to generate the bootstrap plans for the range of supported GHC versions using nix. generate_bootstrap_plans Otherwise you can run the commands in ./generate_bootstrap_plans directly. Fixes #17103 - - - - - a8fb4251 by Zubin Duggal at 2022-01-11T19:37:45-05:00 hadrian: allow offline bootstrapping This patch adds the ability to fetch and store dependencies needed for boostrapping hadrian. By default the script will download the dependencies from the network but some package managers disallow network access so there are also options to build given a supplied tarball. The -s option allos you to provide the tarball bootstrap.py -d plan-bootstrap-8.10.5.json -w /path/to-ghc -s sources-tarball.tar.gz Which dependencies you need can be queried using the `list-sources` option. bootstrap.py list-sources -d plan-bootstrap-8.10.5.json This produces `fetch_plan.json` which tells you where to get each source from. You can instruct the script to create the tarball using the `fetch` option. bootstrap.py fetch -d plan-bootstrap-8.10.5.json -o sources-tarball.tar.gz Together these commands mean you can build GHC without needing cabal-install. Fixes #17103 - - - - - 02cf4bc6 by Zubin Duggal at 2022-01-11T19:37:45-05:00 hadrian: Fully implement source distributions (#19317) We use `git ls-files` to get the list of files to include in the source distribution. Also implements the `-testsuite` and `-extra-tarballs` distributions. - - - - - 85473a09 by Zubin Duggal at 2022-01-11T19:37:45-05:00 ci: test bootstrapping and use hadrian for source dists - - - - - 759f3421 by Matthew Pickering at 2022-01-11T19:38:21-05:00 ci: Nightly, run one head.hackage job with core-lint and one without This fixes serious skew in the performance numbers because the packages were build with core-lint. Fixes #20826 - - - - - 6737c8e1 by Ben Gamari at 2022-01-11T19:38:56-05:00 rts: Depend explicitly on libc As noted in #19029, currently `ghc-prim` explicitly lists `libc` in `extra-libraries`, resulting in incorrect link ordering with the `extra-libraries: pthread` in `libHSrts`. Fix this by adding an explicit dependency on `libc` to `libHSrts`. Closes #19029. - - - - - 247cd336 by Ben Gamari at 2022-01-11T19:39:32-05:00 rts: Only declare environ when necessary Previously we would unconditionally provide a declaration for `environ`, even if `<unistd.h>` already provided one. This would result in `-Werror` builds failing on some platforms. Also `#include <unistd.h>` to ensure that the declaration is visible. Fixes #20861. - - - - - b65e7274 by Greg Steuck at 2022-01-11T19:40:10-05:00 Skip T18623 on OpenBSD The bug it regresses didn't happen on this OS (no RLIMIT_AS) and the regression doesn't work (ulimit: -v: unknown option) - - - - - c6300cb3 by Greg Steuck at 2022-01-11T19:40:50-05:00 Skip T16180 on OpenBSD due to bug #14012 - - - - - addf8e54 by sheaf at 2022-01-11T19:41:28-05:00 Kind TyCons: require KindSignatures, not DataKinds Uses of a TyCon in a kind signature required users to enable DataKinds, which didn't make much sense, e.g. in type U = Type type MyMaybe (a :: U) = MyNothing | MyJust a Now the DataKinds error is restricted to data constructors; the use of kind-level type constructors is instead gated behind -XKindSignatures. This patch also adds a convenience pattern synonym for patching on both a TyCon or a TcTyCon stored in a TcTyThing, used in tcTyVar and tc_infer_id. fixes #20873 - - - - - 34d8bc24 by sheaf at 2022-01-11T19:42:07-05:00 Fix parsing & printing of unboxed sums The pretty-printing of partially applied unboxed sums was incorrect, as we incorrectly dropped the first half of the arguments, even for a partial application such as (# | #) @IntRep @DoubleRep Int# which lead to the nonsensical (# DoubleRep | Int# #). This patch also allows users to write unboxed sum type constructors such as (# | #) :: TYPE r1 -> TYPE r2 -> TYPE (SumRep '[r1,r2]). Fixes #20858 and #20859. - - - - - 49731fed by sheaf at 2022-01-11T19:42:46-05:00 TcPlugins: `newWanted` uses the provided `CtLoc` The `GHC.Tc.Plugin.newWanted` function takes a `CtLoc` as an argument, but it used to discard the location information, keeping only the `CtOrigin`. It would then retrieve the source location from the `TcM` environment using `getCtLocM`. This patch changes this so that `GHC.Tc.Plugin.newWanted` passes on the full `CtLoc`. This means that authors of type-checking plugins no longer need to manually set the `CtLoc` environment in the `TcM` monad if they want to create a new Wanted constraint with the given `CtLoc` (in particular, for setting the `SrcSpan` of an emitted constraint). This makes the `newWanted` function consistent with `newGiven`, which always used the full `CtLoc` instead of using the environment. Fixes #20895 - - - - - 23d215fc by Krzysztof Gogolewski at 2022-01-11T19:43:22-05:00 warnPprTrace: pass separately the reason This makes it more similar to pprTrace, pprPanic etc. - - - - - 833216a3 by Matthew Pickering at 2022-01-11T19:43:57-05:00 Use interactive flags when printing expressions in GHCi The documentation states that the interactive flags should be use for any interactive expressions. The interactive flags are used when typechecking these expressions but not when printing. The session flags (modified by :set) are only used when loading a module. Fixes #20909 - - - - - 19b13698 by Matthew Pickering at 2022-01-11T19:43:57-05:00 Enable :seti in a multi component repl Part of #20889 - - - - - 7ca43a3f by Matthew Pickering at 2022-01-11T19:44:33-05:00 Change assertions in Stats.c to warnings (and introduce WARN macro) ASSERT should be used in situations where something very bad will happen later on if a certain invariant doesn't hold. The idea is that IF we catch the assertion earlier then it will be easier to work out what's going on at that point rather than at some indeterminate point in the future of the program. The assertions in Stats.c do not obey this philsophy and it is quite annoying if you are running a debug build (or a ticky compiler) and one of these assertions fails right at the end of your program, before the ticky report is printed out so you don't get any profiling information. Given that nothing terrible happens if these assertions are not true, or at least the terrible thing will happen in very close proximity to the assertion failure, these assertions use the new WARN macro which prints the assertion failure to stdout but does not exit the program. Of course, it would be better to fix these metrics to not trigger the assertion in the first place but if they did fail again in the future it is frustrating to be bamboozled in this manner. Fixes #20899 - - - - - e505dbd3 by Greg Steuck at 2022-01-11T19:45:11-05:00 Remove from error the parenthesized amount of memory requested Diagnostics for outofmem test on OpenBSD includes the amount of memory that it failed to allocate. This seems like an irrelevant detail that could change over time and isn't required for determining if test passed. Typical elided text is '(requested 2148532224 bytes)' - - - - - 7911aaa9 by Greg Steuck at 2022-01-11T19:45:50-05:00 Feed /dev/null into cgrun025 The test currently times out waiting for end of stdin in getContents. The expected output indicates that nothing should come for the test to pass as written. It is unclear how the test was supposed to pass, but this looks like a sufficient hack to make it work. - - - - - ed39d15c by Greg Steuck at 2022-01-11T19:46:28-05:00 Disable keep-cafs{,-fail} tests on OpenBSD They are likely broken for the same reason as FreeBSD where the tests are already disabled. - - - - - 35bea01b by Peter Trommler at 2022-01-11T19:47:04-05:00 RTS: Remove unused file xxhash.c - - - - - c2099059 by Matthew Pickering at 2022-01-11T19:47:39-05:00 RTTI: Substitute the [rk] skolems into kinds (Fixes #10616 and #10617) Co-authored-by: Roland Senn <rsx at bluewin.ch> - - - - - 92f3e6e4 by Matthew Pickering at 2022-01-11T19:48:15-05:00 docs: MonadComprehension desugar using Alternative rather than MonadPlus Fixes #20928 - - - - - 7b0c9384 by Sylvain Henry at 2022-01-12T23:25:49-05:00 Abstract BangOpts Avoid requiring to pass DynFlags to mkDataConRep/buildDataCon. When we load an interface file, these functions don't use the flags. This is preliminary work to decouple the loader from the type-checker for #14335. - - - - - a31ace56 by Sylvain Henry at 2022-01-12T23:25:49-05:00 Untangled GHC.Types.Id.Make from the driver - - - - - 81a8f7a7 by Zubin Duggal at 2022-01-12T23:26:24-05:00 testsuite: Fix import on python 3.10 - - - - - 66831b94 by Ben Gamari at 2022-01-13T14:50:13-05:00 hadrian: Include bash completion script in bindist See #20802. - - - - - be33d61a by Sebastian Graf at 2022-01-13T14:50:49-05:00 release notes: Changes to CPR analysis - - - - - c2a6c3eb by Sebastian Graf at 2022-01-13T14:50:49-05:00 release notes: Changes to Demand analysis - - - - - 9ccc445a by Eric Lindblad at 2022-01-14T10:35:46-05:00 add NUMJOBS - - - - - 564b89ae by Eric Lindblad at 2022-01-14T10:35:46-05:00 Revert "add NUMJOBS" This reverts commit c0b854e929f82c680530e944e12fad24f9e14f8e - - - - - 2dfc268c by Eric Lindblad at 2022-01-14T10:35:46-05:00 update URLs - - - - - 1aace894 by Eric Lindblad at 2022-01-14T10:35:46-05:00 reinsert target - - - - - 52a4f5ab by Andreas Klebinger at 2022-01-14T10:36:21-05:00 Add test for #20938. - - - - - e2b60be8 by Ben Gamari at 2022-01-15T03:41:16-05:00 rts: Consolidate RtsSymbols from libc Previously (9ebda74ec5331911881d734b21fbb31c00a0a22f) `environ` was added to `RtsSymbols` to ensure that environment was correctly propagated when statically linking. However, this introduced #20577 since platforms are inconsistent in whether they provide a prototype for `environ`. I fixed this by providing a prototype but while doing so dropped symbol-table entry, presumably thinking that it was redundant due to the entry in the mingw-specific table. Here I reintroduce the symbol table entry for `environ` and move libc symbols shared by Windows and Linux into a new macro, `RTS_LIBC_SYMBOLS`, avoiding this potential confusion. - - - - - 0dc72395 by Tamar Christina at 2022-01-15T03:41:55-05:00 winio: fix heap corruption and various leaks. - - - - - 4031ef62 by Eric Lindblad at 2022-01-15T20:11:55+00:00 wikipedia link - - - - - a13aff98 by Eric Lindblad at 2022-01-17T08:25:51-05:00 ms link - - - - - f161e890 by sheaf at 2022-01-17T14:52:50+00:00 Use diagnostic infrastructure in GHC.Tc.Errors - - - - - 18c797b8 by Jens Petersen at 2022-01-18T16:12:14-05:00 hadrian BinaryDist: version ghc in ghciScriptWrapper like we do for the non-Hadrian wrapper script. Otherwise if $bindir/ghc is a different ghc version then versioned ghci will incorrectly run the other ghc version instead. (Normally this would only happen if there are parallel ghc versions installed in bindir.) All the other wrapper scripts already have versioned executablename - - - - - 310424d0 by Matthew Pickering at 2022-01-18T16:12:50-05:00 Correct type of static forms in hsExprType The simplest way to do this seemed to be to persist the whole type in the extension field from the typechecker so that the few relevant places * Desugaring can work out the return type by splitting this type rather than calling `dsExpr` (slightly more efficient). * hsExprType can just return the correct type. * Zonking has to now zonk the type as well The other option we considered was wiring in StaticPtr but that is actually quite tricky because StaticPtr refers to StaticPtrInfo which has field selectors (which we can't easily wire in). Fixes #20150 - - - - - 7ec783de by Matthew Pickering at 2022-01-18T16:12:50-05:00 Add test for using type families with static pointers Issue was reported on #13306 - - - - - 2d205154 by Sebastian Graf at 2022-01-18T16:13:25-05:00 Stricten the Strict State monad I found it weird that most of the combinators weren't actually strict. Making `pure` strict in the state should hopefully give Nested CPR an easier time to unbox the nested state. - - - - - 5a6efd21 by Ben Gamari at 2022-01-18T16:14:01-05:00 rts/winio: Fix #18382 Here we refactor WinIO's IO completion scheme, squashing a memory leak and fixing #18382. To fix #18382 we drop the special thread status introduced for IoPort blocking, BlockedOnIoCompletion, as well as drop the non-threaded RTS's special dead-lock detection logic (which is redundant to the GC's deadlock detection logic), as proposed in #20947. Previously WinIO relied on foreign import ccall "wrapper" to create an adjustor thunk which can be attached to the OVERLAPPED structure passed to the operating system. It would then use foreign import ccall "dynamic" to back out the original continuation from the adjustor. This roundtrip is significantly more expensive than the alternative, using a StablePtr. Furthermore, the implementation let the adjustor leak, meaning that every IO request would leak a page of memory. Fixes T18382. - - - - - 01254ceb by Matthew Pickering at 2022-01-18T16:14:37-05:00 Add note about heap invariant Closed #20904 - - - - - 21510698 by Sergey Vinokurov at 2022-01-18T16:15:12-05:00 Improve detection of lld linker Newer lld versions may include vendor info in --version output and thus the version string may not start with ‘LLD’. Fixes #20907 - - - - - 95e7964b by Peter Trommler at 2022-01-18T20:46:08-05:00 Fix T20638 on big-endian architectures The test reads a 16 bit value from an array of 8 bit values. Naturally, that leads to different values read on big-endian architectures than on little-endian. In this case the value read is 0x8081 on big-endian and 0x8180 on little endian. This patch changes the argument of the `and` machop to mask bit 7 which is the only bit different. The test still checks that bit 15 is zero, which was the original issue in #20638. Fixes #20906. - - - - - fd0019a0 by Eric Lindblad at 2022-01-18T20:46:48-05:00 ms and gh links - - - - - 85dc61ee by Zubin Duggal at 2022-01-18T20:47:23-05:00 ci: Fix subtlety with not taking effect because of time_it (#20898) - - - - - 592e4113 by Anselm Schüler at 2022-01-19T13:31:49-05:00 Note that ImpredicativeTypes doesn’t allow polymorphic instances See #20939 - - - - - 3b009e1a by Ben Gamari at 2022-01-19T13:32:25-05:00 base: Add CTYPE pragmas to all foreign types Fixes #15531 by ensuring that we know the corresponding C type for all marshalling wrappers. Closes #15531. - - - - - 516eeb9e by Robert Hensing at 2022-01-24T21:28:24-05:00 Add -fcompact-unwind This gives users the choice to enable __compact_unwind sections when linking. These were previously hardcoded to be removed. This can be used to solved the problem "C++ does not catch exceptions when used with Haskell-main and linked by ghc", https://gitlab.haskell.org/ghc/ghc/-/issues/11829 It does not change the default behavior, because I can not estimate the impact this would have. When Apple first introduced the compact unwind ABI, a number of open source projects have taken the easy route of disabling it, avoiding errors or even just warnings shortly after its introduction. Since then, about a decade has passed, so it seems quite possible that Apple itself, and presumably many programs with it, have successfully switched to the new format, to the point where the old __eh_frame section support is in disrepair. Perhaps we should get along with the program, but for now we can test the waters with this flag, and use it to fix packages that need it. - - - - - 5262b1e5 by Robert Hensing at 2022-01-24T21:28:24-05:00 Add test case for C++ exception handling - - - - - a5c94092 by Sebastian Graf at 2022-01-24T21:29:00-05:00 Write Note [Strict State monad] to explain what G.U.M.State.Strict does As requested by Simon after review of !7342. I also took liberty to define the `Functor` instance by hand, as the derived one subverts the invariants maintained by the pattern synonym (as already stated in `Note [The one-shot state monad trick]`). - - - - - 9b0d56d3 by Eric Lindblad at 2022-01-24T21:29:38-05:00 links - - - - - 4eac8e72 by Ben Gamari at 2022-01-24T21:30:13-05:00 ghc-heap: Drop mention of BlockedOnIOCompletion Fixes bootstrap with GHC 9.0 after 5a6efd218734dbb5c1350531680cd3f4177690f1 - - - - - 7d7b9a01 by Ryan Scott at 2022-01-24T21:30:49-05:00 Hadrian: update the index-state to allow building with GHC 9.0.2 Fixes #20984. - - - - - aa50e118 by Peter Trommler at 2022-01-24T21:31:25-05:00 testsuite: Mark test that require RTS linker - - - - - 871ce2a3 by Matthew Pickering at 2022-01-25T17:27:30-05:00 ci: Move (most) deb9 jobs to deb10 deb9 is now end-of-life so we are dropping support for producing bindists. - - - - - 9d478d51 by Ryan Scott at 2022-01-25T17:28:06-05:00 DeriveGeneric: look up datacon fixities using getDataConFixityFun Previously, `DeriveGeneric` would look up the fixity of a data constructor using `getFixityEnv`, but this is subtly incorrect for data constructors defined in external modules. This sort of situation can happen with `StandaloneDeriving`, as noticed in #20994. In fact, the same bug has occurred in the past in #9830, and while that bug was fixed for `deriving Read` and `deriving Show`, the fix was never extended to `DeriveGeneric` due to an oversight. This patch corrects that oversight. Fixes #20994. - - - - - 112e9e9e by Zubin Duggal at 2022-01-25T17:28:41-05:00 Fix Werror on alpine - - - - - 781323a3 by Matthew Pickering at 2022-01-25T17:29:17-05:00 Widen T12545 acceptance window This test has been the scourge of contributors for a long time. It has caused many failed CI runs and wasted hours debugging a test which barely does anything. The fact is does nothing is the reason for the flakiness and it's very sensitive to small changes in initialisation costs, in particular adding wired-in things can cause this test to fluctuate quite a bit. Therefore we admit defeat and just bump the threshold up to 10% to catch very large regressions but otherwise don't care what this test does. Fixes #19414 - - - - - e471a680 by sheaf at 2022-01-26T12:01:45-05:00 Levity-polymorphic arrays and mutable variables This patch makes the following types levity-polymorphic in their last argument: - Array# a, SmallArray# a, Weak# b, StablePtr# a, StableName# a - MutableArray# s a, SmallMutableArray# s a, MutVar# s a, TVar# s a, MVar# s a, IOPort# s a The corresponding primops are also made levity-polymorphic, e.g. `newArray#`, `readArray#`, `writeMutVar#`, `writeIOPort#`, etc. Additionally, exception handling functions such as `catch#`, `raise#`, `maskAsyncExceptions#`,... are made levity/representation-polymorphic. Now that Array# and MutableArray# also work with unlifted types, we can simply re-define ArrayArray# and MutableArrayArray# in terms of them. This means that ArrayArray# and MutableArrayArray# are no longer primitive types, but simply unlifted newtypes around Array# and MutableArrayArray#. This completes the implementation of the Pointer Rep proposal https://github.com/ghc-proposals/ghc-proposals/pull/203 Fixes #20911 ------------------------- Metric Increase: T12545 ------------------------- ------------------------- Metric Decrease: T12545 ------------------------- - - - - - 6e94ba54 by Andreas Klebinger at 2022-01-26T12:02:21-05:00 CorePrep: Don't try to wrap partial applications of primops in profiling ticks. This fixes #20938. - - - - - b55d7db3 by sheaf at 2022-01-26T12:03:01-05:00 Ensure that order of instances doesn't matter The insert_overlapping used in lookupInstEnv used to return different results depending on the order in which instances were processed. The problem was that we could end up discarding an overlapping instance in favour of a more specific non-overlapping instance. This is a problem because, even though we won't choose the less-specific instance for matching, it is still useful for pruning away other instances, because it has the overlapping flag set while the new instance doesn't. In insert_overlapping, we now keep a list of "guard" instances, which are instances which are less-specific that one that matches (and hence which we will discard in the end), but want to keep around solely for the purpose of eliminating other instances. Fixes #20946 - - - - - 61f62062 by sheaf at 2022-01-26T12:03:40-05:00 Remove redundant SOURCE import in FitTypes Fixes #20995 - - - - - e8405829 by sheaf at 2022-01-26T12:04:15-05:00 Fix haddock markup in GHC.Tc.Errors.Types - - - - - 590a2918 by Simon Peyton Jones at 2022-01-26T19:45:22-05:00 Make RULE matching insensitive to eta-expansion This patch fixes #19790 by making the rule matcher do on-the-fly eta reduction. See Note [Eta reduction the target] in GHC.Core.Rules I found I also had to careful about casts when matching; see Note [Casts in the target] and Note [Casts in the template] Lots more comments and Notes in the rule matcher - - - - - c61ac4d8 by Matthew Pickering at 2022-01-26T19:45:58-05:00 alwaysRerun generation of ghcconfig This file needs to match exactly what is passed as the testCompiler. Before this change the settings for the first compiler to be tested woudl be stored and not regenerated if --test-compiler changed. - - - - - b5132f86 by Matthew Pickering at 2022-01-26T19:45:58-05:00 Pass config.stage argument to testsuite - - - - - 83d3ad31 by Zubin Duggal at 2022-01-26T19:45:58-05:00 hadrian: Allow testing of the stage1 compiler (#20755) - - - - - a5924b38 by Joachim Breitner at 2022-01-26T19:46:34-05:00 Simplifier: Do the right thing if doFloatFromRhs = False If `doFloatFromRhs` is `False` then the result from `prepareBinding` should not be used. Previously it was in ways that are silly (but not completly wrong, as the simplifier would clean that up again, so no test case). This was spotted by Simon during a phone call. Fixes #20976 - - - - - ce488c2b by Simon Peyton Jones at 2022-01-26T19:47:09-05:00 Better occurrence analysis with casts This patch addresses #20988 by refactoring the way the occurrence analyser deals with lambdas. Previously it used collectBinders to split off a group of binders, and deal with them together. Now I deal with them one at a time in occAnalLam, which allows me to skip casts easily. See Note [Occurrence analysis for lambda binders] about "lambda-groups" This avoidance of splitting out a list of binders has some good consequences. Less code, more efficient, and I think, more clear. The Simplifier needed a similar change, now that lambda-groups can inlude casts. It turned out that I could simplify the code here too, in particular elminating the sm_bndrs field of StrictBind. Simpler, more efficient. Compile-time metrics improve slightly; here are the ones that are +/- 0.5% or greater: Baseline Test Metric value New value Change -------------------------------------------------------------------- T11303b(normal) ghc/alloc 40,736,702 40,543,992 -0.5% T12425(optasm) ghc/alloc 90,443,459 90,034,104 -0.5% T14683(normal) ghc/alloc 2,991,496,696 2,956,277,288 -1.2% T16875(normal) ghc/alloc 34,937,866 34,739,328 -0.6% T17977b(normal) ghc/alloc 37,908,550 37,709,096 -0.5% T20261(normal) ghc/alloc 621,154,237 618,312,480 -0.5% T3064(normal) ghc/alloc 190,832,320 189,952,312 -0.5% T3294(normal) ghc/alloc 1,604,674,178 1,604,608,264 -0.0% T5321FD(normal) ghc/alloc 270,540,489 251,888,480 -6.9% GOOD T5321Fun(normal) ghc/alloc 300,707,814 281,856,200 -6.3% GOOD WWRec(normal) ghc/alloc 588,460,916 585,536,400 -0.5% geo. mean -0.3% Metric Decrease: T5321FD T5321Fun - - - - - 4007905d by Roland Senn at 2022-01-26T19:47:47-05:00 Cleanup tests in directory ghci.debugger. Fixes #21009 * Remove wrong comment about panic in `break003.script`. * Improve test `break008`. * Add test `break028` to `all.T` * Fix wrong comments in `print019.script`, `print026.script` and `result001.script`. * Remove wrong comments from `print024.script` and `print031.script`. * Replace old module name with current name in `print035.script`. - - - - - 3577defb by Matthew Pickering at 2022-01-26T19:48:22-05:00 ci: Move source-tarball and test-bootstrap into full-build - - - - - 6e09b3cf by Matthew Pickering at 2022-01-27T02:39:35-05:00 ci: Add ENABLE_NUMA flag to explicitly turn on libnuma dependency In recent releases a libnuma dependency has snuck into our bindists because the images have started to contain libnuma. We now explicitly pass `--disable-numa` to configure unless explicitly told not to by using the `ENABLE_NUMA` environment variable. So this is tested, there is one random validate job which builds with --enable-numa so that the code in the RTS is still built. Fixes #20957 and #15444 - - - - - f4ce4186 by Simon Peyton Jones at 2022-01-27T02:40:11-05:00 Improve partial signatures As #20921 showed, with partial signatures, it is helpful to use the same algorithm (namely findInferredDiff) for * picking the constraints to retain for the /group/ in Solver.decideQuantification * picking the contraints to retain for the /individual function/ in Bind.chooseInferredQuantifiers This is still regrettably declicate, but it's a step forward. - - - - - 0573aeab by Simon Peyton Jones at 2022-01-27T02:40:11-05:00 Add an Outputable instance for RecTcChecker - - - - - f0adea14 by Ryan Scott at 2022-01-27T02:40:47-05:00 Expand type synonyms in markNominal `markNominal` is repsonsible for setting the roles of type variables that appear underneath an `AppTy` to be nominal. However, `markNominal` previously did not expand type synonyms, so in a data type like this: ```hs data M f a = MkM (f (T a)) type T a = Int ``` The `a` in `M f a` would be marked nominal, even though `T a` would simply expand to `Int`. The fix is simple: call `coreView` as appropriate in `markNominal`. This is much like the fix for #14101, but in a different spot. Fixes #20999. - - - - - 18df4013 by Simon Peyton Jones at 2022-01-27T08:22:30-05:00 Define and use restoreLclEnv This fixes #20981. See Note [restoreLclEnv vs setLclEnv] in GHC.Tc.Utils.Monad. I also use updLclEnv rather than get/set when I can, because it's then much clearer that it's an update rather than an entirely new TcLclEnv coming from who-knows-where. - - - - - 31088dd3 by David Feuer at 2022-01-27T08:23:05-05:00 Add test supplied in T20996 which uses data family result kind polymorphism David (@treeowl) writes: > Following @kcsongor, I've used ridiculous data family result kind > polymorphism in `linear-generics`, and am currently working on getting > it into `staged-gg`. If it should be removed, I'd appreciate a heads up, > and I imagine Csongor would too. > > What do I need by ridiculous polymorphic result kinds? Currently, data > families are allowed to have result kinds that end in `Type` (or maybe > `TYPE r`? I'm not sure), but not in concrete data kinds. However, they > *are* allowed to have polymorphic result kinds. This leads to things I > think most of us find at least quite *weird*. For example, I can write > > ```haskell > data family Silly :: k > data SBool :: Bool -> Type where > SFalse :: SBool False > STrue :: SBool True > SSSilly :: SBool Silly > type KnownBool b where > kb :: SBool b > instance KnownBool False where kb = SFalse > instance KnownBool True where kb = STrue > instance KnownBool Silly where kb = Silly > ``` > > Basically, every kind now has potentially infinitely many "legit" inhabitants. > > As horrible as that is, it's rather useful for GHC's current native > generics system. It's possible to use these absurdly polymorphic result > kinds to probe the structure of generic representations in a relatively > pleasant manner. It's a sort of "formal type application" reminiscent of > the notion of a formal power series (see the test case below). I suspect > a system more like `kind-generics` wouldn't need this extra probing > power, but nothing like that is natively available as yet. > > If the ridiculous result kind polymorphism is banished, we'll still be > able to do what we need as long as we have stuck type families. It's > just rather less ergonomical: a stuck type family has to be used with a > concrete marker type argument. Closes #20996 Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 8fd2ac25 by Andreas Abel at 2022-01-27T18:34:54-05:00 Whitespace only - - - - - 7a854743 by Andreas Abel at 2022-01-27T18:34:54-05:00 Ctd. #18087: complete :since: info for all warnings in users guide Some warnings have been there "forever" and I could not trace back the exact genesis, so I wrote "since at least 5.04". The flag `helpful-errors` could have been added in 7.2 already. I wrote 7.4 since I have no 7.2 available and it is not recognized by 7.0. - - - - - f75411e8 by Andreas Abel at 2022-01-27T18:34:54-05:00 Re #18087 user's guide: add a note that -Wxxx used to be -fwarn-xxx The warning option syntax -W was introduced in GHC 8. The note should clarify what e.g. "since 7.6" means in connection with "-Wxxx": That "-fwarn-xxx" was introduced in 7.6.1. [ci skip] - - - - - 3cae7fde by Peter Trommler at 2022-01-27T18:35:30-05:00 testsuite: Fix AtomicPrimops test on big endian - - - - - 6cc6080c by Ben Gamari at 2022-01-27T18:36:05-05:00 users-guide: Document GHC_CHARENC environment variable As noted in #20963, this was introduced in 1b56c40578374a15b4a2593895710c68b0e2a717 but was no documentation was added at that point. Closes #20963. - - - - - ee21e2de by Ben Gamari at 2022-01-27T18:36:41-05:00 rts: Clean up RTS flags usage message Align flag descriptions and acknowledge that some flags may not be available unless the user linked with `-rtsopts` (as noted in #20961). Fixes #20961. - - - - - 7f8ce19e by Simon Peyton Jones at 2022-01-27T18:37:17-05:00 Fix getHasGivenEqs The second component is supposed to be "insoluble equalities arising from givens". But we were getting wanteds too; and that led to an outright duplication of constraints. It's not harmful, but it's not right either. I came across this when debugging something else. Easily fixed. - - - - - f9ef2d26 by Simon Peyton Jones at 2022-01-27T18:37:17-05:00 Set the TcLclEnv when solving a ForAll constraint Fix a simple omission in GHC.Tc.Solver.Canonical.solveForAll, where we ended up with the wrong TcLclEnv captured in an implication. Result: unhelpful error message (#21006) - - - - - bc6ba8ef by Sylvain Henry at 2022-01-28T12:14:41-05:00 Make most shifts branchless - - - - - 62a6d037 by Simon Peyton Jones at 2022-01-28T12:15:17-05:00 Improve boxity in deferAfterPreciseException As #20746 showed, the demand analyser behaved badly in a key I/O library (`GHC.IO.Handle.Text`), by unnessarily boxing and reboxing. This patch adjusts the subtle function deferAfterPreciseException; it's quite easy, just a bit subtle. See the new Note [deferAfterPreciseException] And this MR deals only with Problem 2 in #20746. Problem 1 is still open. - - - - - 42c47cd6 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/trace: Shrink tracing flags - - - - - cee66e71 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/EventLog: Mark various internal globals as static - - - - - 6b0cea29 by Ben Gamari at 2022-01-29T02:40:45-05:00 Propagate PythonCmd to make build system - - - - - 2e29edb7 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts: Refactor event types Previously we would build the eventTypes array at runtime during RTS initialization. However, this is completely unnecessary; it is completely static data. - - - - - bb15c347 by Ben Gamari at 2022-01-29T02:40:45-05:00 rts/eventlog: Ensure that flushCount is initialized - - - - - 268efcc9 by Matthew Pickering at 2022-01-29T02:41:21-05:00 Rework the handling of SkolemInfo The main purpose of this patch is to attach a SkolemInfo directly to each SkolemTv. This fixes the large number of bugs which have accumulated over the years where we failed to report errors due to having "no skolem info" for particular type variables. Now the origin of each type varible is stored on the type variable we can always report accurately where it cames from. Fixes #20969 #20732 #20680 #19482 #20232 #19752 #10946 #19760 #20063 #13499 #14040 The main changes of this patch are: * SkolemTv now contains a SkolemInfo field which tells us how the SkolemTv was created. Used when reporting errors. * Enforce invariants relating the SkolemInfoAnon and level of an implication (ic_info, ic_tclvl) to the SkolemInfo and level of the type variables in ic_skols. * All ic_skols are TcTyVars -- Check is currently disabled * All ic_skols are SkolemTv * The tv_lvl of the ic_skols agrees with the ic_tclvl * The ic_info agrees with the SkolInfo of the implication. These invariants are checked by a debug compiler by checkImplicationInvariants. * Completely refactor kcCheckDeclHeader_sig which kept doing my head in. Plus, it wasn't right because it wasn't skolemising the binders as it decomposed the kind signature. The new story is described in Note [kcCheckDeclHeader_sig]. The code is considerably shorter than before (roughly 240 lines turns into 150 lines). It still has the same awkward complexity around computing arity as before, but that is a language design issue. See Note [Arity inference in kcCheckDeclHeader_sig] * I added new type synonyms MonoTcTyCon and PolyTcTyCon, and used them to be clear which TcTyCons have "finished" kinds etc, and which are monomorphic. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] * I renamed etaExpandAlgTyCon to splitTyConKind, becuase that's a better name, and it is very useful in kcCheckDeclHeader_sig, where eta-expansion isn't an issue. * Kill off the nasty `ClassScopedTvEnv` entirely. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 0a1d0944 by Ben Gamari at 2022-01-29T14:52:55-05:00 Drop SPARC NCG - - - - - 313afb3d by Ben Gamari at 2022-01-29T14:52:56-05:00 A few comment cleanups - - - - - d85a527f by Ben Gamari at 2022-01-29T14:52:56-05:00 Rip out SPARC register support - - - - - c6bede69 by Ben Gamari at 2022-01-29T14:52:56-05:00 rts: Rip out SPARC support - - - - - a67c2471 by Ben Gamari at 2022-01-29T14:52:56-05:00 Rip out remaining SPARC support - - - - - 5771b690 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Drop RegPair SPARC was its last and only user. - - - - - 512ed3f1 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Make RealReg a newtype Now that RegPair is gone we no longer need to pay for the additional box. - - - - - 88fea6aa by Ben Gamari at 2022-01-29T14:52:56-05:00 rts: Drop redundant #include <Arena.h> - - - - - ea2a4034 by Ben Gamari at 2022-01-29T14:52:56-05:00 CmmToAsm: Drop ncgExpandTop This was only needed for SPARC's synthetic instructions. - - - - - 88fce740 by Ben Gamari at 2022-01-29T14:54:04-05:00 rel-notes: Note dropping of SPARC support - - - - - eb956cf1 by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite: Force-enable caret diagnostics in T17786 Otherwise GHC realizes that it's not attached to a proper tty and will disable caret diagnostics. - - - - - d07799ab by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite: Make T7275 more robust against CCid changes The cost-center numbers are somewhat unstable; normalise them out. - - - - - c76c8050 by Ben Gamari at 2022-01-30T06:27:19-05:00 rts: Don't allocate closurePtrs# pointers on C stack Previously `closurePtrs#` would allocate an aray of the size of the closure being decoded on the C stack. This was ripe for overflowing the C stack overflow. This resulted in `T12492` failing on Windows. - - - - - 3af95f7a by Ben Gamari at 2022-01-30T06:27:19-05:00 testsuite/T4029: Don't depend on echo On Windows the `cmd.exe` shell may be used to execute the command, which will print `ECHO is on.` instead of a newline if you give it no argument. Avoid this by rather using `printf`. - - - - - 3531c478 by Ben Gamari at 2022-01-30T06:27:19-05:00 Use PATH_FMT instead of %s to format `pathchar *` A few %s occurrences have snuck in over the past months. - - - - - ee5c4f9d by Zubin Duggal at 2022-01-31T16:51:55+05:30 Improve migration strategy for the XDG compliance change to the GHC application directory. We want to always use the old path (~/.ghc/..) if it exists. But we never want to create the old path. This ensures that the migration can eventually be completed once older GHC versions are no longer in circulation. Fixes #20684, #20669, #20660 - - - - - 60a54a8f by doyougnu at 2022-01-31T18:46:11-05:00 StgToCmm: decouple DynFlags, add StgToCmmConfig StgToCmm: add Config, remove CgInfoDownwards StgToCmm: runC api change to take StgToCmmConfig StgToCmm: CgInfoDownad -> StgToCmmConfig StgToCmm.Monad: update getters/setters/withers StgToCmm: remove CallOpts in StgToCmm.Closure StgToCmm: remove dynflag references StgToCmm: PtrOpts removed StgToCmm: add TMap to config, Prof - dynflags StgToCmm: add omit yields to config StgToCmm.ExtCode: remove redundant import StgToCmm.Heap: remove references to dynflags StgToCmm: codeGen api change, DynFlags -> Config StgToCmm: remove dynflags in Env and StgToCmm StgToCmm.DataCon: remove dynflags references StgToCmm: remove dynflag references in DataCon StgToCmm: add backend avx flags to config StgToCmm.Prim: remove dynflag references StgToCmm.Expr: remove dynflag references StgToCmm.Bind: remove references to dynflags StgToCmm: move DoAlignSanitisation to Cmm.Type StgToCmm: remove PtrOpts in Cmm.Parser.y DynFlags: update ipInitCode api StgToCmm: Config Module is single source of truth StgToCmm: Lazy config breaks IORef deadlock testsuite: bump countdeps threshold StgToCmm.Config: strictify fields except UpdFrame Strictifying UpdFrameOffset causes the RTS build with stage1 to deadlock. Additionally, before the deadlock performance of the RTS is noticeably slower. StgToCmm.Config: add field descriptions StgToCmm: revert strictify on Module in config testsuite: update CountDeps tests StgToCmm: update comment, fix exports Specifically update comment about loopification passed into dynflags then stored into stgToCmmConfig. And remove getDynFlags from Monad.hs exports Types.Name: add pprFullName function StgToCmm.Ticky: use pprFullname, fixup ExtCode imports Cmm.Info: revert cmmGetClosureType removal StgToCmm.Bind: use pprFullName, Config update comments StgToCmm: update closureDescription api StgToCmm: SAT altHeapCheck StgToCmm: default render for Info table, ticky Use default rendering contexts for info table and ticky ticky, which should be independent of command line input. testsuite: bump count deps pprFullName: flag for ticky vs normal style output convertInfoProvMap: remove unused parameter StgToCmm.Config: add backend flags to config StgToCmm.Config: remove Backend from Config StgToCmm.Prim: refactor Backend call sites StgToCmm.Prim: remove redundant imports StgToCmm.Config: refactor vec compatibility check StgToCmm.Config: add allowQuotRem2 flag StgToCmm.Ticky: print internal names with parens StgToCmm.Bind: dispatch ppr based on externality StgToCmm: Add pprTickyname, Fix ticky naming Accidently removed the ctx for ticky SDoc output. The only relevant flag is sdocPprDebug which was accidental set to False due to using defaultSDocContext without altering the flag. StgToCmm: remove stateful fields in config fixup: config: remove redundant imports StgToCmm: move Sequel type to its own module StgToCmm: proliferate getCallMethod updated api StgToCmm.Monad: add FCodeState to Monad Api StgToCmm: add second reader monad to FCode fixup: Prim.hs: missed a merge conflict fixup: Match countDeps tests to HEAD StgToCmm.Monad: withState -> withCgState To disambiguate it from mtl withState. This withState shouldn't be returning the new state as a value. However, fixing this means tackling the knot tying in CgState and so is very difficult since it changes when the thunk of the knot is forced which either leads to deadlock or to compiler panic. - - - - - 58eccdbc by Ben Gamari at 2022-01-31T18:46:47-05:00 codeGen: Fix two buglets in -fbounds-check logic @Bodigrim noticed that the `compareByteArray#` bounds-checking logic had flipped arguments and an off-by-one. For the sake of clarity I also refactored occurrences of `cmmOffset` to rather use `cmmOffsetB`. I suspect the former should be retired. - - - - - 584f03fa by Simon Peyton Jones at 2022-01-31T18:47:23-05:00 Make typechecker trace less strict Fixes #21011 - - - - - 60ac7300 by Elton at 2022-02-01T12:28:49-05:00 Use braces in TH case pprint (fixes #20893) This patch ensures that the pretty printer formats `case` statements using braces (instead of layout) to remain consistent with the formatting of other statements (like `do`) - - - - - fdda93b0 by Elton at 2022-02-01T12:28:49-05:00 Use braces in TH LambdaCase and where clauses This patch ensures that the pretty printer formats LambdaCase and where clauses using braces (instead of layout) to remain consistent with the formatting of other statements (like `do` and `case`) - - - - - 06185102 by Ben Gamari at 2022-02-01T12:29:26-05:00 Consistently upper-case "Note [" This was achieved with git ls-tree --name-only HEAD -r | xargs sed -i -e 's/note \[/Note \[/g' - - - - - 88fba8a4 by Ben Gamari at 2022-02-01T12:29:26-05:00 Fix a few Note inconsistencies - - - - - 05548a22 by Douglas Wilson at 2022-02-02T19:26:06-05:00 rts: Address failures to inline - - - - - 074945de by Simon Peyton Jones at 2022-02-02T19:26:41-05:00 Two small improvements in the Simplifier As #20941 describes, this patch implements a couple of small fixes to the Simplifier. They make a difference principally with -O0, so few people will notice. But with -O0 they can reduce the number of Simplifer iterations. * In occurrence analysis we avoid making x = (a,b) into a loop breaker because we want to be able to inline x, or (more likely) do case-elimination. But HEAD does not treat x = let y = blah in (a,b) in the same way. We should though, because we are going to float that y=blah out of the x-binding. A one-line fix in OccurAnal. * The crucial function exprIsConApp_maybe uses getUnfoldingInRuleMatch (rightly) but the latter was deeply strange. In HEAD, if rule-rewriting was off (-O0) we only looked inside stable unfoldings. Very stupid. The patch simplifies. * I also noticed that in simplStableUnfolding we were failing to delete the DFun binders from the usage. So I added that. Practically zero perf change across the board, except that we get more compiler allocation in T3064 (which is compiled with -O0). There's a good reason: we get better code. But there are lots of other small compiler allocation decreases: Metrics: compile_time/bytes allocated --------------------- Baseline Test Metric value New value Change ----------------------------------------------------------------- PmSeriesG(normal) ghc/alloc 44,260,817 44,184,920 -0.2% PmSeriesS(normal) ghc/alloc 52,967,392 52,891,632 -0.1% PmSeriesT(normal) ghc/alloc 75,498,220 75,421,968 -0.1% PmSeriesV(normal) ghc/alloc 52,341,849 52,265,768 -0.1% T10421(normal) ghc/alloc 109,702,291 109,626,024 -0.1% T10421a(normal) ghc/alloc 76,888,308 76,809,896 -0.1% T10858(normal) ghc/alloc 125,149,038 125,073,648 -0.1% T11276(normal) ghc/alloc 94,159,364 94,081,640 -0.1% T11303b(normal) ghc/alloc 40,230,059 40,154,368 -0.2% T11822(normal) ghc/alloc 107,424,540 107,346,088 -0.1% T12150(optasm) ghc/alloc 76,486,339 76,426,152 -0.1% T12234(optasm) ghc/alloc 55,585,046 55,507,352 -0.1% T12425(optasm) ghc/alloc 88,343,288 88,265,312 -0.1% T13035(normal) ghc/alloc 98,919,768 98,845,600 -0.1% T13253-spj(normal) ghc/alloc 121,002,153 120,851,040 -0.1% T16190(normal) ghc/alloc 290,313,131 290,074,152 -0.1% T16875(normal) ghc/alloc 34,756,121 34,681,440 -0.2% T17836b(normal) ghc/alloc 45,198,100 45,120,288 -0.2% T17977(normal) ghc/alloc 39,479,952 39,404,112 -0.2% T17977b(normal) ghc/alloc 37,213,035 37,137,728 -0.2% T18140(normal) ghc/alloc 79,430,588 79,350,680 -0.1% T18282(normal) ghc/alloc 128,303,182 128,225,384 -0.1% T18304(normal) ghc/alloc 84,904,713 84,831,952 -0.1% T18923(normal) ghc/alloc 66,817,241 66,731,984 -0.1% T20049(normal) ghc/alloc 86,188,024 86,107,920 -0.1% T5837(normal) ghc/alloc 35,540,598 35,464,568 -0.2% T6048(optasm) ghc/alloc 99,812,171 99,736,032 -0.1% T9198(normal) ghc/alloc 46,380,270 46,304,984 -0.2% geo. mean -0.0% Metric Increase: T3064 - - - - - d2cce453 by Morrow at 2022-02-02T19:27:21-05:00 Fix @since annotation on Nat - - - - - 6438fed9 by Simon Peyton Jones at 2022-02-02T19:27:56-05:00 Refactor the escaping kind check for data constructors As #20929 pointed out, we were in-elegantly checking for escaping kinds in `checkValidType`, even though that check was guaranteed to succeed for type signatures -- it's part of kind-checking a type. But for /data constructors/ we kind-check the pieces separately, so we still need the check. This MR is a pure refactor, moving the test from `checkValidType` to `checkValidDataCon`. No new tests; external behaviour doesn't change. - - - - - fb05e5ac by Andreas Klebinger at 2022-02-02T19:28:31-05:00 Replace sndOfTriple with sndOf3 I also cleaned up the imports slightly while I was at it. - - - - - fbc77d3a by Matthew Pickering at 2022-02-02T19:29:07-05:00 testsuite: Honour PERF_BASELINE_COMMIT when computing allowed metric changes We now get all the commits between the PERF_BASELINE_COMMIT and HEAD and check any of them for metric changes. Fixes #20882 - - - - - 0a82ae0d by Simon Peyton Jones at 2022-02-02T23:49:58-05:00 More accurate unboxing This patch implements a fix for #20817. It ensures that * The final strictness signature for a function accurately reflects the unboxing done by the wrapper See Note [Finalising boxity for demand signatures] and Note [Finalising boxity for let-bound Ids] * A much better "layer-at-a-time" implementation of the budget for how many worker arguments we can have See Note [Worker argument budget] Generally this leads to a bit more worker/wrapper generation, because instead of aborting entirely if the budget is exceeded (and then lying about boxity), we unbox a bit. Binary sizes in increase slightly (around 1.8%) because of the increase in worker/wrapper generation. The big effects are to GHC.Ix, GHC.Show, GHC.IO.Handle.Internals. If we did a better job of dropping dead code, this effect might go away. Some nofib perf improvements: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- VSD +1.8% -0.5% 0.017 0.017 0.0% awards +1.8% -0.1% +2.3% +2.3% 0.0% banner +1.7% -0.2% +0.3% +0.3% 0.0% bspt +1.8% -0.1% +3.1% +3.1% 0.0% eliza +1.8% -0.1% +1.2% +1.2% 0.0% expert +1.7% -0.1% +9.6% +9.6% 0.0% fannkuch-redux +1.8% -0.4% -9.3% -9.3% 0.0% kahan +1.8% -0.1% +22.7% +22.7% 0.0% maillist +1.8% -0.9% +21.2% +21.6% 0.0% nucleic2 +1.7% -5.1% +7.5% +7.6% 0.0% pretty +1.8% -0.2% 0.000 0.000 0.0% reverse-complem +1.8% -2.5% +12.2% +12.2% 0.0% rfib +1.8% -0.2% +2.5% +2.5% 0.0% scc +1.8% -0.4% 0.000 0.000 0.0% simple +1.7% -1.3% +17.0% +17.0% +7.4% spectral-norm +1.8% -0.1% +6.8% +6.7% 0.0% sphere +1.7% -2.0% +13.3% +13.3% 0.0% tak +1.8% -0.2% +3.3% +3.3% 0.0% x2n1 +1.8% -0.4% +8.1% +8.1% 0.0% -------------------------------------------------------------------------------- Min +1.1% -5.1% -23.6% -23.6% 0.0% Max +1.8% +0.0% +36.2% +36.2% +7.4% Geometric Mean +1.7% -0.1% +6.8% +6.8% +0.1% Compiler allocations in CI have a geometric mean of +0.1%; many small decreases but there are three bigger increases (7%), all because we do more worker/wrapper than before, so there is simply more code to compile. That's OK. Perf benchmarks in perf/should_run improve in allocation by a geo mean of -0.2%, which is good. None get worse. T12996 improves by -5.8% Metric Decrease: T12996 Metric Increase: T18282 T18923 T9630 - - - - - d1ef6288 by Peter Trommler at 2022-02-02T23:50:34-05:00 Cmm: fix equality of expressions Compare expressions and types when comparing `CmmLoad`s. Fixes #21016 - - - - - e59446c6 by Peter Trommler at 2022-02-02T23:50:34-05:00 Check type first then expression - - - - - b0e1ef4a by Matthew Pickering at 2022-02-03T14:44:17-05:00 Add failing test for #20791 The test produces different output on static vs dynamic GHC builds. - - - - - cae1fb17 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Frontend01 passes with static GHC - - - - - e343526b by Matthew Pickering at 2022-02-03T14:44:17-05:00 Don't initialise plugins when there are no pipelines to run - - - - - abac45fc by Matthew Pickering at 2022-02-03T14:44:17-05:00 Mark prog003 as expected_broken on static way #20704 - - - - - 13300dfd by Matthew Pickering at 2022-02-03T14:44:17-05:00 Filter out -rtsopts in T16219 to make static/dynamic ways agree - - - - - d89439f2 by Matthew Pickering at 2022-02-03T14:44:17-05:00 T13168: Filter out rtsopts for consistency between dynamic and static ways - - - - - 00180cdf by Matthew Pickering at 2022-02-03T14:44:17-05:00 Accept new output for T14335 test This test was previously not run due to #20960 - - - - - 1accdcff by Matthew Pickering at 2022-02-03T14:44:17-05:00 Add flushes to plugin tests which print to stdout Due to #20791 you need to explicitly flush as otherwise the output from these tests doesn't make it to stdout. - - - - - d820f2e8 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Remove ghc_plugin_way Using ghc_plugin_way had the unintended effect of meaning certain tests weren't run at all when ghc_dynamic=true, if you delete this modifier then the tests work in both the static and dynamic cases. - - - - - aa5ef340 by Matthew Pickering at 2022-02-03T14:44:17-05:00 Unbreak T13168 on windows Fixes #14276 - - - - - 84ab0153 by Matthew Pickering at 2022-02-03T14:44:53-05:00 Rewrite CallerCC parser using ReadP This allows us to remove the dependency on parsec and hence transitively on text. Also added some simple unit tests for the parser and fixed two small issues in the documentation. Fixes #21033 - - - - - 4e6780bb by Matthew Pickering at 2022-02-03T14:45:28-05:00 ci: Add debian 11 jobs (validate/release/nightly) Fixes #21002 - - - - - eddaa591 by Ben Gamari at 2022-02-04T10:01:59-05:00 compiler: Introduce and use RoughMap for instance environments Here we introduce a new data structure, RoughMap, inspired by the previous `RoughTc` matching mechanism for checking instance matches. This allows [Fam]InstEnv to be implemented as a trie indexed by these RoughTc signatures, reducing the complexity of instance lookup and FamInstEnv merging (done during the family instance conflict test) from O(n) to O(log n). The critical performance improvement currently realised by this patch is in instance matching. In particular the RoughMap mechanism allows us to discount many potential instances which will never match for constraints involving type variables (see Note [Matching a RoughMap]). In realistic code bases matchInstEnv was accounting for 50% of typechecker time due to redundant work checking instances when simplifying instance contexts when deriving instances. With this patch the cost is significantly reduced. The larger constants in InstEnv creation do mean that a few small tests regress in allocations slightly. However, the runtime of T19703 is reduced by a factor of 4. Moreover, the compilation time of the Cabal library is slightly improved. A couple of test cases are included which demonstrate significant improvements in compile time with this patch. This unfortunately does not fix the testcase provided in #19703 but does fix #20933 ------------------------- Metric Decrease: T12425 Metric Increase: T13719 T9872a T9872d hard_hole_fits ------------------------- Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com> - - - - - 62d670eb by Matthew Pickering at 2022-02-04T10:02:35-05:00 testsuite: Run testsuite dependency calculation before GHC is built The main motivation for this patch is to allow tests to be added to the testsuite which test things about the source tree without needing to build GHC. In particular the notes linter can easily start failing and by integrating it into the testsuite the process of observing these changes is caught by normal validation procedures rather than having to run the linter specially. With this patch I can run ``` ./hadrian/build test --flavour=devel2 --only="uniques" ``` In a clean tree to run the checkUniques linter without having to build GHC. Fixes #21029 - - - - - 4bd52410 by Hécate Moonlight at 2022-02-04T16:14:10-05:00 Add the Ix class to Foreign C integral types Related CLC proposal is here: https://github.com/haskell/core-libraries-committee/issues/30 - - - - - de6d7692 by Ben Gamari at 2022-02-04T16:14:47-05:00 Drop dead code - - - - - b79206f1 by Ben Gamari at 2022-02-04T16:14:47-05:00 Add comments - - - - - 58d7faac by Ben Gamari at 2022-02-04T16:14:47-05:00 cmm: Introduce cmmLoadBWord and cmmLoadGCWord - - - - - 7217156c by Ben Gamari at 2022-02-04T16:14:47-05:00 Introduce alignment in CmmLoad - - - - - 99ea5f2c by Ben Gamari at 2022-02-04T16:14:47-05:00 Introduce alignment to CmmStore - - - - - 606b59a5 by Ben Gamari at 2022-02-04T16:14:47-05:00 Fix array primop alignment - - - - - 1cf9616a by Ben Gamari at 2022-02-04T16:14:47-05:00 llvmGen: Handle unaligned loads/stores This allows us to produce valid code for indexWord8ArrayAs*# on platforms that lack unaligned memory access. - - - - - 8c18feba by Ben Gamari at 2022-02-04T16:14:47-05:00 primops: Fix documentation of setByteArray# Previously the documentation was subtly incorrect regarding the bounds of the operation. Fix this and add a test asserting that a zero-length operation is in fact a no-op. - - - - - 88480e55 by nineonine at 2022-02-04T20:35:45-05:00 Fix unsound behavior of unlifted datatypes in ghci (#20194) Previously, directly calling a function that pattern matches on an unlifted data type which has at least two constructors in GHCi resulted in a segfault. This happened due to unaccounted return frame info table pointer. The fix is to pop the above mentioned frame info table pointer when unlifted things are returned. See Note [Popping return frame for unlifted things] authors: bgamari, nineonine - - - - - a5c7068c by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Add Outputable instance for Messages c.f. #20980 - - - - - bf495f72 by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Add a missing restoreLclEnv The commit commit 18df4013f6eaee0e1de8ebd533f7e96c4ee0ff04 Date: Sat Jan 22 01:12:30 2022 +0000 Define and use restoreLclEnv omitted to change one setLclEnv to restoreLclEnv, namely the one in GHC.Tc.Errors.warnRedundantConstraints. This new commit fixes the omission. - - - - - 6af8e71e by Simon Peyton Jones at 2022-02-04T20:36:20-05:00 Improve errors for non-existent labels This patch fixes #17469, by improving matters when you use non-existent field names in a record construction: data T = MkT { x :: Int } f v = MkT { y = 3 } The check is now made in the renamer, in GHC.Rename.Env.lookupRecFieldOcc. That in turn led to a spurious error in T9975a, which is fixed by making GHC.Rename.Names.extendGlobalRdrEnvRn fail fast if it finds duplicate bindings. See Note [Fail fast on duplicate definitions] in that module for more details. This patch was originated and worked on by Alex D (@nineonine) - - - - - 299acff0 by nineonine at 2022-02-05T19:21:49-05:00 Exit with failure when -e fails (fixes #18411 #9916 #17560) - - - - - 549292eb by Matthew Pickering at 2022-02-05T19:22:25-05:00 Make implication tidying agree with Note [Tidying multiple names at once] Note [Tidying multiple names at once] indicates that if multiple variables have the same name then we shouldn't prioritise one of them and instead rename them all to a1, a2, a3... etc This patch implements that change, some error message changes as expected. Closes #20932 - - - - - 2e9248b7 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts/m32: Accept any address within 4GB of program text Previously m32 would assume that the program image was located near the start of the address space and therefore assume that it wanted pages in the bottom 4GB of address space. Instead we now check whether they are within 4GB of whereever the program is loaded. This is necessary on Windows, which now tends to place the image in high memory. The eventual goal is to use m32 to allocate memory for linker sections on Windows. - - - - - 86589b89 by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts: Generalize mmapForLinkerMarkExecutable Renamed to mprotectForLinker and allowed setting of arbitrary protection modes. - - - - - 88ef270a by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts/m32: Add consistency-checking infrastructure This adds logic, enabled in the `-debug` RTS for checking the internal consistency of the m32 allocator. This area has always made me a bit nervous so this should help me sleep better at night in exchange for very little overhead. - - - - - 2d6f0b17 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts/m32: Free large objects back to the free page pool Not entirely convinced that this is worth doing. - - - - - e96f50be by GHC GitLab CI at 2022-02-06T01:43:56-05:00 rts/m32: Increase size of free page pool to 256 pages - - - - - fc083b48 by Ben Gamari at 2022-02-06T01:43:56-05:00 rts: Dump memory map on memory mapping failures Fixes #20992. - - - - - 633296bc by Ben Gamari at 2022-02-06T01:43:56-05:00 Fix macro redefinition warnings for PRINTF * Move `PRINTF` macro from `Stats.h` to `Stats.c` as it's only needed in the latter. * Undefine `PRINTF` at the end of `Messages.h` to avoid leaking it. - - - - - 37d435d2 by John Ericson at 2022-02-06T01:44:32-05:00 Purge DynFlags from GHC.Stg Also derive some more instances. GHC doesn't need them, but downstream consumers may need to e.g. put stuff in maps. - - - - - 886baa34 by Peter Trommler at 2022-02-06T10:58:18+01:00 RTS: Fix cabal specification In 35bea01b xxhash.c was removed. Remove the extra-source-files stanza referring to it. - - - - - 27581d77 by Alex D at 2022-02-06T20:50:44-05:00 hadrian: remove redundant import - - - - - 4ff19981 by John Ericson at 2022-02-07T11:04:43-05:00 GHC.HsToCore.Coverage: No more HscEnv, less DynFlags Progress towards #20730 - - - - - b09389a6 by John Ericson at 2022-02-07T11:04:43-05:00 Create `CoverageConfig` As requested by @mpickering to collect the information we project from `HscEnv` - - - - - ff867c46 by Greg Steuck at 2022-02-07T11:05:24-05:00 Avoid using removed utils/checkUniques in validate Asked the question: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7460/diffs#4061f4d17546e239dd10d78c6b48668c2a288e02_1_0 - - - - - a9355e84 by sheaf at 2022-02-08T05:27:25-05:00 Allow HasField in quantified constraints We perform validity checking on user-written HasField instances, for example to disallow: data Foo a = Foo { fld :: Int } instance HasField "fld" (Foo a) Bool However, these checks were also being made on quantified constraints, e.g. data Bar where Bar :: (forall a. HasField s (Foo a) Int) => Proxy s -> Bar This patch simply skips validity checking for quantified constraints, in line with what we already do for equality constraints such as Coercible. Fixes #20989 - - - - - 6d77d3d8 by sheaf at 2022-02-08T05:28:05-05:00 Relax TyEq:N: allow out-of-scope newtype DataCon The 'bad_newtype' assertion in GHC.Tc.Solver.Canonical.canEqCanLHSFinish failed to account for the possibility that the newtype constructor might not be in scope, in which case we don't provide any guarantees about canonicalising away a newtype on the RHS of a representational equality. Fixes #21010 - - - - - a893d2f3 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Remove linter dependency on lint-submods - - - - - 457a5b9c by Ben Gamari at 2022-02-08T05:28:42-05:00 notes-util: initial commit - - - - - 1a943859 by Ben Gamari at 2022-02-08T05:28:42-05:00 gitlab-ci: Add lint-notes job - - - - - bc5cbce6 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Add notes linter to testsuite - - - - - 38c6e301 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Fix some notes - - - - - c3aac0f8 by Matthew Pickering at 2022-02-08T05:28:42-05:00 Add suggestion mode to notes-util - - - - - 5dd29aea by Cale Gibbard at 2022-02-08T05:29:18-05:00 `hscSimpleIface` drop fingerprint param and ret `hscSimpleIface` does not depend on or modify the `Maybe Fingerprint` it is given, only passes it through, so get rid of the extraneous passing. Perhaps the intent was that there would be an iface fingerprint check of some sort? but this was never done. If/when we we want to do that, we can add it back then. - - - - - 4bcbd731 by Cale Gibbard at 2022-02-08T05:29:54-05:00 Document `hscIncrementalFrontend` and flip bool - - - - - b713db1e by John Ericson at 2022-02-08T05:30:29-05:00 StgToCmm: Get rid of GHC.Driver.Session imports `DynFlags` is gone, but let's move a few trivial things around to get rid of its module too. - - - - - f115c382 by Gleb Popov at 2022-02-08T05:31:05-05:00 Fix build on recent FreeBSD. Recent FreeBSD versions gained the sched_getaffinity function, which made two mutually exclusive #ifdef blocks to be enabled. - - - - - 3320ab40 by Ben Gamari at 2022-02-08T10:42:04-05:00 rts/MemoryMap: Use mach_-prefixed type names There appears to be some inconsistency in system-call type naming across Darwin toolchains. Specifically: * the `address` argument to `mach_vm_region` apparently wants to be a `mach_vm_address_t *`, not a `vm_address_t *` * the `vmsize` argument to `mach_vm_region` wants to be a `mach_vm_size_t`, not a `vm_size_t` - - - - - b33f0cfa by Richard Eisenberg at 2022-02-08T10:42:41-05:00 Document that reifyRoles includes kind parameters Close #21056 - - - - - bd493ed6 by PHO at 2022-02-08T10:43:19-05:00 Don't try to build stage1 with -eventlog if stage0 doesn't provide it Like -threaded, stage0 isn't guaranteed to have an event-logging RTS. - - - - - 03c2de0f by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Use absolute paths for config.libdir Fixes #21052 - - - - - ef294525 by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Clean up old/redundant predicates - - - - - a39ed908 by Matthew Pickering at 2022-02-09T03:56:22-05:00 testsuite: Add missing dependency on ghcconfig - - - - - a172be07 by PHO at 2022-02-09T03:56:59-05:00 Implement System.Environment.getExecutablePath for NetBSD and also use it from GHC.BaseDir.getBaseDir - - - - - 62fa126d by PHO at 2022-02-09T03:57:37-05:00 Fix a portability issue in m4/find_llvm_prog.m4 `test A == B' is a Bash extension, which doesn't work on platforms where /bin/sh is not Bash. - - - - - fd9981e3 by Ryan Scott at 2022-02-09T03:58:13-05:00 Look through untyped TH splices in tcInferAppHead_maybe Previously, surrounding a head expression with a TH splice would defeat `tcInferAppHead_maybe`, preventing some expressions from typechecking that used to typecheck in previous GHC versions (see #21038 for examples). This is simple enough to fix: just look through `HsSpliceE`s in `tcInferAppHead_maybe`. I've added some additional prose to `Note [Application chains and heads]` in `GHC.Tc.Gen.App` to accompany this change. Fixes #21038. - - - - - 00975981 by sheaf at 2022-02-09T03:58:53-05:00 Add test for #21037 This program was rejected by GHC 9.2, but is accepted on newer versions of GHC. This patch adds a regression test. Closes #21037 - - - - - fad0b2b0 by Ben Gamari at 2022-02-09T08:29:46-05:00 Rename -merge-objs flag to --merge-objs For consistency with --make and friends. - - - - - 1dbe5b2a by Matthew Pickering at 2022-02-09T08:30:22-05:00 driver: Filter out our own boot module in hptSomeThingsBelow hptSomeThingsBelow would return a list of modules which contain the .hs-boot file for a particular module. This caused some problems because we would try and find the module in the HPT (but it's not there when we're compiling the module itself). Fixes #21058 - - - - - 2b1cced1 by Sylvain Henry at 2022-02-09T20:42:23-05:00 NCG: minor code factorization - - - - - e01ffec2 by Sylvain Henry at 2022-02-09T20:42:23-05:00 ByteCode: avoid out-of-bound read Cf https://gitlab.haskell.org/ghc/ghc/-/issues/18431#note_287139 - - - - - 53c26e79 by Ziyang Liu at 2022-02-09T20:43:02-05:00 Include ru_name in toHsRule message See #18147 - - - - - 3df06922 by Ben Gamari at 2022-02-09T20:43:39-05:00 rts: Rename MemoryMap.[ch] -> ReportMemoryMap.[ch] - - - - - e219ac82 by Ben Gamari at 2022-02-09T20:43:39-05:00 rts: Move mmapForLinker and friends to linker/MMap.c They are not particularly related to linking. - - - - - 30e205ca by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/linker: Drop dead IA64 code - - - - - 4d3a306d by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/linker/MMap: Use MemoryAccess in mmapForLinker - - - - - 1db4f1fe by Ben Gamari at 2022-02-09T20:43:39-05:00 linker: Don't use MAP_FIXED As noted in #21057, we really shouldn't be using MAP_FIXED. I would much rather have the process crash with a "failed to map" error than randomly overwrite existing mappings. Closes #21057. - - - - - 1eeae25c by Ben Gamari at 2022-02-09T20:43:39-05:00 rts/mmap: Refactor mmapForLinker Here we try to separate the policy decisions of where to place mappings from the mechanism of creating the mappings. This makes things significantly easier to follow. - - - - - ac2d18a7 by sheaf at 2022-02-09T20:44:18-05:00 Add some perf tests for coercions This patch adds some performance tests for programs that create large coercions. This is useful because the existing test coverage is not very representative of real-world situations. In particular, this adds a test involving an extensible records library, a common pain-point for users. - - - - - 48f25715 by Andreas Klebinger at 2022-02-10T04:35:35-05:00 Add late cost centre support This allows cost centres to be inserted after the core optimization pipeline has run. - - - - - 0ff70427 by Andreas Klebinger at 2022-02-10T04:36:11-05:00 Docs:Mention that safe calls don't keep their arguments alive. - - - - - 1d3ed168 by Ben Gamari at 2022-02-10T04:36:46-05:00 PEi386: Drop Windows Vista fallback in addLibrarySearchPath We no longer support Windows Vista. - - - - - 2a6f2681 by Ben Gamari at 2022-02-10T04:36:46-05:00 linker/PEi386: Make addLibrarySearchPath long-path aware Previously `addLibrarySearchPath` failed to normalise the added path to UNC form before passing it to `AddDllDirectory`. Consequently, the call was subject to the MAX_PATH restriction, leading to the failure of `test-defaulting-plugin-fail`, among others. Happily, this also nicely simplifies the implementation. Closes #21059. - - - - - 2a47ee9c by Daniel Gröber at 2022-02-10T19:18:58-05:00 ghc-boot: Simplify writePackageDb permissions handling Commit ef8a3fbf1 ("ghc-boot: Fix metadata handling of writeFileAtomic") introduced a somewhat over-engineered fix for #14017 by trying to preserve the current permissions if the target file already exists. The problem in the issue is simply that the package db cache file should be world readable but isn't if umask is too restrictive. In fact the previous fix only handles part of this problem. If the file isn't already there in a readable configuration it wont make it so which isn't really ideal either. Rather than all that we now simply always force all the read access bits to allow access while leaving the owner at the system default as it's just not our business to mess with it. - - - - - a1d97968 by Ben Gamari at 2022-02-10T19:19:34-05:00 Bump Cabal submodule Adapts GHC to the factoring-out of `Cabal-syntax`. Fixes #20991. Metric Decrease: haddock.Cabal - - - - - 89cf8caa by Morrow at 2022-02-10T19:20:13-05:00 Add metadata to integer-gmp.cabal - - - - - c995b7e7 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix event type of EVENT_IPE This leads to corrupted eventlogs because the size of EVENT_IPE is completely wrong. Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de - - - - - 59ba8fb3 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix event type of MEM_RETURN This leads to corrupted eventlogs because the size of EVENT_MEM_RETURN is completely wrong. Fixes a bug introduced in 2e29edb7421c21902b47d130d45f60d3f584a0de - - - - - 19413d09 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Delete misleading comment in gen_event_types.py Not all events start with CapNo and there's not logic I could see which adds this to the length. - - - - - e06f49c0 by Matthew Pickering at 2022-02-10T19:20:48-05:00 eventlog: Fix size of TICKY_COUNTER_BEGIN_SAMPLE - - - - - 2f99255b by Matthew Pickering at 2022-02-10T19:21:24-05:00 Fix copy-pasto in prof-late-ccs docs - - - - - 19deb002 by Matthew Pickering at 2022-02-10T19:21:59-05:00 Refine tcSemigroupWarnings to work in ghc-prim ghc-prim doesn't depend on base so can't have any Monoid or Semigroup instances. However, attempting to load these definitions ran into issues when the interface for `GHC.Base` did exist as that would try and load the interface for `GHC.Types` (which is the module we are trying to compile and has no interface). The fix is to just not do this check when we are compiling a module in ghc-prim. Fixes #21069 - - - - - 34dec6b7 by sheaf at 2022-02-11T17:55:34-05:00 Decrease the size of the LargeRecord test This test was taking too long to run, so this patch makes it smaller. ------------------------- Metric Decrease: LargeRecord ------------------------- - - - - - 9cab90d9 by Matthew Pickering at 2022-02-11T22:27:19-05:00 Make sure all platforms have a release job The release bindists are currently a mixture of validate and release builds. This is bad because the validate builds don't have profiling libraries. The fix is to make sure there is a release job for each platform we want to produce a release for.t Fixes #21066 - - - - - 4bce3575 by Matthew Pickering at 2022-02-11T22:27:54-05:00 testsuite: Make sure all tests trigger ghc rebuild I made a mistake when implementing #21029 which meant that certain tests didn't trigger a GHC recompilation. By adding the `test:ghc` target to the default settings all tests will now depend on this target unless explicitly opting out via the no_deps modifier. - - - - - 90a26f8b by Sylvain Henry at 2022-02-11T22:28:34-05:00 Fix documentation about Word64Rep/Int64Rep (#16964) - - - - - 0e93023e by Andreas Klebinger at 2022-02-12T13:59:41+00:00 Tag inference work. This does three major things: * Enforce the invariant that all strict fields must contain tagged pointers. * Try to predict the tag on bindings in order to omit tag checks. * Allows functions to pass arguments unlifted (call-by-value). The former is "simply" achieved by wrapping any constructor allocations with a case which will evaluate the respective strict bindings. The prediction is done by a new data flow analysis based on the STG representation of a program. This also helps us to avoid generating redudant cases for the above invariant. StrictWorkers are created by W/W directly and SpecConstr indirectly. See the Note [Strict Worker Ids] Other minor changes: * Add StgUtil module containing a few functions needed by, but not specific to the tag analysis. ------------------------- Metric Decrease: T12545 T18698b T18140 T18923 LargeRecord Metric Increase: LargeRecord ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13253-spj T13379 T15164 T18282 T18304 T18698a T1969 T20049 T3294 T4801 T5321FD T5321Fun T783 T9233 T9675 T9961 T19695 WWRec ------------------------- - - - - - 744f8a11 by Greg Steuck at 2022-02-12T17:13:55-05:00 Only check the exit code in derefnull & divbyzero tests on OpenBSD - - - - - eeead9fc by Ben Gamari at 2022-02-13T03:26:14-05:00 rts/Adjustor: Ensure that allocateExecPage succeeded Previously we failed to handle the case that `allocateExecPage` failed. - - - - - afdfaff0 by Ben Gamari at 2022-02-13T03:26:14-05:00 rts: Drop DEC Alpha adjustor implementation The last Alpha chip was produced in 2004. - - - - - 191dfd2d by Ben Gamari at 2022-02-13T03:26:14-05:00 rts/adjustor: Split Windows path out of NativeAmd64 - - - - - be591e27 by Ben Gamari at 2022-02-13T03:26:14-05:00 rts: Initial commit of AdjustorPool - - - - - d6d48b16 by Ben Gamari at 2022-02-13T03:26:14-05:00 Introduce initAdjustors - - - - - eab37902 by Ben Gamari at 2022-02-13T03:26:14-05:00 adjustors/NativeAmd64: Use AdjustorPool - - - - - 974e73af by Ben Gamari at 2022-02-13T03:26:14-05:00 adjustors/NativeAmd64Mingw: Use AdjustorPool - - - - - 95fab83f by Ben Gamari at 2022-02-13T03:26:14-05:00 configure: Fix result reporting of adjustors method check - - - - - ef5cf55d by nikshalark at 2022-02-13T03:26:16-05:00 (#21044) Documented arithmetic functions in base. Didn't get it right the ninth time. Now everything's formatted correctly. - - - - - acb482cc by Takenobu Tani at 2022-02-16T05:27:17-05:00 Relax load_load_barrier for aarch64 This patch relaxes the instruction for load_load_barrier(). Current load_load_barrier() implements full-barrier with `dmb sy`. It's too strong to order load-load instructions. We can relax it by using `dmb ld`. If current load_load_barrier() is used for full-barriers (load/store - load/store barrier), this patch is not suitable. See also linux-kernel's smp_rmb() implementation: https://github.com/torvalds/linux/blob/v5.14/arch/arm64/include/asm/barrier.h#L90 Hopefully, it's better to use `dmb ishld` rather than `dmb ld` to improve performance. However, I can't validate effects on a real many-core Arm machine. - - - - - 84eaa26f by Oleg Grenrus at 2022-02-16T05:27:56-05:00 Add test for #20562 - - - - - 2c28620d by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00 rts: remove struct StgRetry, it is never used - - - - - 74bf9bb5 by Adam Sandberg Ericsson at 2022-02-16T05:28:32-05:00 rts: document some closure types - - - - - 316312ec by nineonine at 2022-02-16T05:29:08-05:00 ghci: fix -ddump-stg-cg (#21052) The pre-codegen Stg AST dump was not available in ghci because it was performed in 'doCodeGen'. This was now moved to 'coreToStg' area. - - - - - a6411d74 by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00 docs: mention -fprof-late-ccs in the release notes And note which compiler version it was added in. - - - - - 4127e86d by Adam Sandberg Ericsson at 2022-02-16T05:29:43-05:00 docs: fix release notes formatting - - - - - 4e6c8019 by Matthew Pickering at 2022-02-17T05:25:28-05:00 Always define __GLASGOW_HASKELL_PATCHLEVEL1/2__ macros As #21076 reports if you are using `-Wcpp-undef` then you get warnings when using the `MIN_VERSION_GLASGOW_HASKELL` macro because __GLASGOW_HASKELL_PATCHLEVEL2__ is very rarely explicitliy set (as version numbers are not 4 components long). This macro was introduced in 3549c952b535803270872adaf87262f2df0295a4 and it seems the bug has existed ever since. Fixes #21076 - - - - - 67dd5724 by Ben Gamari at 2022-02-17T05:26:03-05:00 rts/AdjustorPool: Silence unused function warning bitmap_get is only used in the DEBUG RTS configuration. Fixes #21079. - - - - - 4b04f7e1 by Zubin Duggal at 2022-02-20T13:56:15-05:00 Track object file dependencies for TH accurately (#20604) `hscCompileCoreExprHook` is changed to return a list of `Module`s required by a splice. These modules are accumulated in the TcGblEnv (tcg_th_needed_mods). Dependencies on the object files of these modules are recording in the interface. The data structures in `LoaderState` are replaced with more efficient versions to keep track of all the information required. The MultiLayerModulesTH_Make allocations increase slightly but runtime is faster. Fixes #20604 ------------------------- Metric Increase: MultiLayerModulesTH_Make ------------------------- - - - - - 92ab3ff2 by sheaf at 2022-02-20T13:56:55-05:00 Use diagnostics for "missing signature" errors This patch makes the "missing signature" errors from "GHC.Rename.Names" use the diagnostic infrastructure. This encompasses missing type signatures for top-level bindings and pattern synonyms, as well as missing kind signatures for type constructors. This patch also renames TcReportMsg to TcSolverReportMsg, and adds a few convenience functions to compute whether such a TcSolverReportMsg is an expected/actual message. - - - - - 845284a5 by sheaf at 2022-02-20T13:57:34-05:00 Generically: remove redundant Semigroup constraint This patch removes a redundant Semigroup constraint on the Monoid instance for Generically. This constraint can cause trouble when one wants to derive a Monoid instance via Generically through a type that doesn't itself have a Semigroup instance, for example: data Point2D a = Point2D !a !a newtype Vector2D a = Vector2D { tip :: Point2D a } deriving ( Semigroup, Monoid ) via Generically ( Point2D ( Sum a ) ) In this case, we should not require there to be an instance Semigroup ( Point2D ( Sum a ) ) as all we need is an instance for the generic representation of Point2D ( Sum a ), i.e. Semigroup ( Rep ( Point2D ( Sum a) ) () ). - - - - - 6b468f7f by Ben Gamari at 2022-02-20T13:58:10-05:00 Bump time submodule to 1.12.1 - - - - - 2f0ceecc by Zubin Duggal at 2022-02-20T19:06:19+00:00 hadrian: detect if 'main' is not a haskell file and add it to appropriate list of sources - - - - - 7ce1b694 by Zubin Duggal at 2022-02-21T11:18:58+00:00 Reinstallable GHC This patch allows ghc and its dependencies to be built using a normal invocation of cabal-install. Each componenent which relied on generated files or additional configuration now has a Setup.hs file. There are also various fixes to the cabal files to satisfy cabal-install. There is a new hadrian command which will build a stage2 compiler and then a stage3 compiler by using cabal. ``` ./hadrian/build build-cabal ``` There is also a new CI job which tests running this command. For the 9.4 release we will upload all the dependent executables to hackage and then end users will be free to build GHC and GHC executables via cabal. There are still some unresolved questions about how to ensure soundness when loading plugins into a reinstalled GHC (#20742) which will be tighted up in due course. Fixes #19896 - - - - - 78fbc3a3 by Matthew Pickering at 2022-02-21T15:14:28-05:00 hadrian: Enable late-ccs when building profiled_ghc - - - - - 2b890c89 by Matthew Pickering at 2022-02-22T15:59:33-05:00 testsuite: Don't print names of all fragile tests on all runs This information about fragile tests is pretty useless but annoying on CI where you have to scroll up a long way to see the actual issues. - - - - - 0b36801f by sheaf at 2022-02-22T16:00:14-05:00 Forbid standalone instances for built-in classes `check_special_inst_head` includes logic that disallows hand-written instances for built-in classes such as Typeable, KnownNat and KnownSymbol. However, it also allowed standalone deriving declarations. This was because we do want to allow standalone deriving instances with Typeable as they are harmless, but we certainly don't want to allow instances for e.g. KnownNat. This patch ensures that we don't allow derived instances for KnownNat, KnownSymbol (and also KnownChar, which was previously omitted entirely). Fixes #21087 - - - - - ace66dec by Krzysztof Gogolewski at 2022-02-22T16:30:59-05:00 Remove -Wunticked-promoted-constructors from -Wall Update manual; explain ticks as optional disambiguation rather than the preferred default. This is a part of #20531. - - - - - 558c7d55 by Hugo at 2022-02-22T16:31:01-05:00 docs: fix error in annotation guide code snippet - - - - - a599abba by Richard Eisenberg at 2022-02-23T08:16:07-05:00 Kill derived constraints Co-authored by: Sam Derbyshire Previously, GHC had three flavours of constraint: Wanted, Given, and Derived. This removes Derived constraints. Though serving a number of purposes, the most important role of Derived constraints was to enable better error messages. This job has been taken over by the new RewriterSets, as explained in Note [Wanteds rewrite wanteds] in GHC.Tc.Types.Constraint. Other knock-on effects: - Various new Notes as I learned about under-described bits of GHC - A reshuffling around the AST for implicit-parameter bindings, with better integration with TTG. - Various improvements around fundeps. These were caused by the fact that, previously, fundep constraints were all Derived, and Derived constraints would get dropped. Thus, an unsolved Derived didn't stop compilation. Without Derived, this is no longer possible, and so we have to be considerably more careful around fundeps. - A nice little refactoring in GHC.Tc.Errors to center the work on a new datatype called ErrorItem. Constraints are converted into ErrorItems at the start of processing, and this allows for a little preprocessing before the main classification. - This commit also cleans up the behavior in generalisation around functional dependencies. Now, if a variable is determined by functional dependencies, it will not be quantified. This change is user facing, but it should trim down GHC's strange behavior around fundeps. - Previously, reportWanteds did quite a bit of work, even on an empty WantedConstraints. This commit adds a fast path. - Now, GHC will unconditionally re-simplify constraints during quantification. See Note [Unconditionally resimplify constraints when quantifying], in GHC.Tc.Solver. Close #18398. Close #18406. Solve the fundep-related non-confluence in #18851. Close #19131. Close #19137. Close #20922. Close #20668. Close #19665. ------------------------- Metric Decrease: LargeRecord T9872b T9872b_defer T9872d TcPlugin_RewritePerf ------------------------- - - - - - 2ed22ba1 by Matthew Pickering at 2022-02-23T08:16:43-05:00 Introduce predicate for when to enable source notes (needSourceNotes) There were situations where we were using debugLevel == 0 as a proxy for whether to retain source notes but -finfo-table-map also enables and needs source notes so we should act consistently in both cases. Ticket #20847 - - - - - 37deb893 by Matthew Pickering at 2022-02-23T08:16:43-05:00 Use SrcSpan from the binder as initial source estimate There are some situations where we end up with no source notes in useful positions in an expression. In this case we currently fail to provide any source information about where an expression came from. This patch improves the initial estimate by using the position from the top-binder as the guess for the location of the whole inner expression. It provides quite a course estimate but it's better than nothing. Ticket #20847 - - - - - 59b7f764 by Cheng Shao at 2022-02-23T08:17:24-05:00 Don't emit foreign exports initialiser code for empty CAF list - - - - - c7f32f76 by John Ericson at 2022-02-23T13:58:36-05:00 Prepare rechecking logic for new type in a few ways Combine `MustCompile and `NeedsCompile` into a single case. `CompileReason` is put inside to destinguish the two. This makes a number of things easier. `Semigroup RecompileRequired` is no longer used, to make sure we skip doing work where possible. `recompThen` is very similar, but helps remember. `checkList` is rewritten with `recompThen`. - - - - - e60d8df8 by John Ericson at 2022-02-23T13:58:36-05:00 Introduce `MaybeValidated` type to remove invalid states The old return type `(RecompRequired, Maybe _)`, was confusing because it was inhabited by values like `(UpToDate, Nothing)` that made no sense. The new type ensures: - you must provide a value if it is up to date. - you must provide a reason if you don't provide a value. it is used as the return value of: - `checkOldIface` - `checkByteCode` - `checkObjects` - - - - - f07b13e3 by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: refactor X86 codegen Preliminary work done to make working on #5444 easier. Mostly make make control-flow easier to follow: * renamed genCCall into genForeignCall * split genForeignCall into the part dispatching on PrimTarget (genPrim) and the one really generating code for a C call (cf ForeignTarget and genCCall) * made genPrim/genSimplePrim only dispatch on MachOp: each MachOp now has its own code generation function. * out-of-line primops are not handled in a partial `outOfLineCmmOp` anymore but in the code generation functions directly. Helper functions have been introduced (e.g. genLibCCall) for code sharing. * the latter two bullets make code generated for primops that are only sometimes out-of-line (e.g. Pdep or Memcpy) and the logic to select between inline/out-of-line much more localized * avoided passing is32bit as an argument as we can easily get it from NatM state when we really need it * changed genCCall type to avoid it being partial (it can't handle PrimTarget) * globally removed 12 calls to `panic` thanks to better control flow and types ("parse, don't validate" ftw!). - - - - - 6fa7591e by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: refactor the way registers are handled * add getLocalRegReg to avoid allocating a CmmLocal just to call getRegisterReg * 64-bit registers: in the general case we must always use the virtual higher part of the register, so we might as well always return it with the lower part. The only exception is to implement 64-bit to 32-bit conversions. We now have to explicitly discard the higher part when matching on Reg64/RegCode64 datatypes instead of explicitly fetching the higher part from the lower part: much safer default. - - - - - bc8de322 by Sylvain Henry at 2022-02-23T13:59:23-05:00 NCG: inline some 64-bit primops on x86/32-bit (#5444) Several 64-bit operation were implemented with FFI calls on 32-bit architectures but we can easily implement them with inline assembly code. Also remove unused hs_int64ToWord64 and hs_word64ToInt64 C functions. - - - - - 7b7c6b95 by Matthew Pickering at 2022-02-23T14:00:00-05:00 Simplify/correct implementation of getModuleInfo - - - - - 6215b04c by Matthew Pickering at 2022-02-23T14:00:00-05:00 Remove mg_boot field from ModuleGraph It was unused in the compiler so I have removed it to streamline ModuleGraph. - - - - - 818ff2ef by Matthew Pickering at 2022-02-23T14:00:01-05:00 driver: Remove needsTemplateHaskellOrQQ from ModuleGraph The idea of the needsTemplateHaskellOrQQ query is to check if any of the modules in a module graph need Template Haskell then enable -dynamic-too if necessary. This is quite imprecise though as it will enable -dynamic-too for all modules in the module graph even if only one module uses template haskell, with multiple home units, this is obviously even worse. With -fno-code we already have similar logic to enable code generation just for the modules which are dependeded on my TemplateHaskell modules so we use the same code path to decide whether to enable -dynamic-too rather than using this big hammer. This is part of the larger overall goal of moving as much statically known configuration into the downsweep as possible in order to have fully decided the build plan and all the options before starting to build anything. I also included a fix to #21095, a long standing bug with with the logic which is supposed to enable the external interpreter if we don't have the internal interpreter. Fixes #20696 #21095 - - - - - b6670af6 by Matthew Pickering at 2022-02-23T14:00:40-05:00 testsuite: Normalise output of ghci011 and T7627 The outputs of these tests vary on the order interface files are loaded so we normalise the output to correct for these inconsequential differences. Fixes #21121 - - - - - 9ed3bc6e by Peter Trommler at 2022-02-23T14:01:16-05:00 testsuite: Fix ipeMap test Pointers to closures must be untagged before use. Produce closures of different types so we get different info tables. Fixes #21112 - - - - - 7d426148 by Ziyang Liu at 2022-02-24T04:53:34-05:00 Allow `return` in more cases in ApplicativeDo The doc says that the last statement of an ado-block can be one of `return E`, `return $ E`, `pure E` and `pure $ E`. But `return` is not accepted in a few cases such as: ```haskell -- The ado-block only has one statement x :: F () x = do return () -- The ado-block only has let-statements besides the `return` y :: F () y = do let a = True return () ``` These currently require `Monad` instances. This MR fixes it. Normally `return` is accepted as the last statement because it is stripped in constructing an `ApplicativeStmt`, but this cannot be done in the above cases, so instead we replace `return` by `pure`. A similar but different issue (when the ado-block contains `BindStmt` or `BodyStmt`, the second last statement cannot be `LetStmt`, even if the last statement uses `pure`) is fixed in !6786. - - - - - a5ea7867 by John Ericson at 2022-02-24T20:23:49-05:00 Clarify laws of TestEquality It is unclear what `TestEquality` is for. There are 3 possible choices. Assuming ```haskell data Tag a where TagInt1 :: Tag Int TagInt2 :: Tag Int ``` Weakest -- type param equality semi-decidable --------------------------------------------- `Just Refl` merely means the type params are equal, the values being compared might not be. `Nothing` means the type params may or may not be not equal. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Nothing -- oopsie is allowed testEquality TagInt1 TagInt2 = Just Refl testEquality TagInt2 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl ``` This option is better demonstrated with a different type: ```haskell data Tag' a where TagInt1 :: Tag Int TagInt2 :: Tag a ``` ```haskell instance TestEquality Tag' where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt1 TagInt2 = Nothing -- can't be sure testEquality TagInt2 TagInt1 = Nothing -- can't be sure testEquality TagInt2 TagInt2 = Nothing -- can't be sure ``` Weaker -- type param equality decidable --------------------------------------- `Just Refl` merely means the type params are equal, the values being compared might not be. `Nothing` means the type params are not equal. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt1 TagInt2 = Just Refl testEquality TagInt2 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl ``` Strong -- Like `Eq` ------------------- `Just Refl` means the type params are equal, and the values are equal according to `Eq`. ```haskell instance TestEquality Tag where testEquality TagInt1 TagInt1 = Just Refl testEquality TagInt2 TagInt2 = Just Refl testEquality _ _ = Nothing ``` Strongest -- unique value concrete type --------------------------------------- `Just Refl` means the type params are equal, and the values are equal, and the class assume if the type params are equal the values must also be equal. In other words, the type is a singleton type when the type parameter is a closed term. ```haskell -- instance TestEquality -- invalid instance because two variants for `Int` ``` ------ The discussion in https://github.com/haskell/core-libraries-committee/issues/21 has decided on the "Weaker" option (confusingly formerly called the "Weakest" option). So that is what is implemented. - - - - - 06c18990 by Zubin Duggal at 2022-02-24T20:24:25-05:00 TH: fix pretty printing of GADTs with multiple constuctors (#20842) - - - - - 6555b68c by Matthew Pickering at 2022-02-24T20:25:06-05:00 Move linters into the tree This MR moves the GHC linters into the tree, so that they can be run directly using Hadrian. * Query all files tracked by Git instead of using changed files, so that we can run the exact same linting step locally and in a merge request. * Only check that the changelogs don't contain TBA when RELEASE=YES. * Add hadrian/lint script, which runs all the linting steps. * Ensure the hlint job exits with a failure if hlint is not installed (otherwise we were ignoring the failure). Given that hlint doesn't seem to be available in CI at the moment, I've temporarily allowed failure in the hlint job. * Run all linting tests in CI using hadrian. - - - - - b99646ed by Matthew Pickering at 2022-02-24T20:25:06-05:00 Add rule for generating HsBaseConfig.h If you are running the `lint:{base/compiler}` command locally then this improves the responsiveness because we don't re-run configure everytime if the header file already exists. - - - - - d0deaaf4 by Matthew Pickering at 2022-02-24T20:25:06-05:00 Suggestions due to hlint It turns out this job hasn't been running for quite a while (perhaps ever) so there are quite a few failures when running the linter locally. - - - - - 70bafefb by nineonine at 2022-02-24T20:25:42-05:00 ghci: show helpful error message when loading module with SIMD vector operations (#20214) Previously, when trying to load module with SIMD vector operations, ghci would panic in 'GHC.StgToByteCode.findPushSeq'. Now, a more helpful message is displayed. - - - - - 8ed3d5fd by Matthew Pickering at 2022-02-25T10:24:12+00:00 Remove test-bootstrap and cabal-reinstall jobs from fast-ci [skip ci] - - - - - 8387dfbe by Mario Blažević at 2022-02-25T21:09:41-05:00 template-haskell: Fix two prettyprinter issues Fix two issues regarding printing numeric literals. Fixing #20454. - - - - - 4ad8ce0b by sheaf at 2022-02-25T21:10:22-05:00 GHCi: don't normalise partially instantiated types This patch skips performing type normalisation when we haven't fully instantiated the type. That is, in tcRnExpr (used only for :type in GHCi), skip normalisation if the result type responds True to isSigmaTy. Fixes #20974 - - - - - f35aca4d by Ben Gamari at 2022-02-25T21:10:57-05:00 rts/adjustor: Always place adjustor templates in data section @nrnrnr points out that on his machine ld.lld rejects text relocations. Generalize the Darwin text-relocation avoidance logic to account for this. - - - - - cddb040a by Andreas Klebinger at 2022-02-25T21:11:33-05:00 Ticky: Gate tag-inference dummy ticky-counters behind a flag. Tag inference included a way to collect stats about avoided tag-checks. This was dony by emitting "dummy" ticky entries with counts corresponding to predicted/unpredicated tag checks. This behaviour for ticky is now gated behind -fticky-tag-checks. I also documented ticky-LNE in the process. - - - - - 948bf2d0 by Ben Gamari at 2022-02-25T21:12:09-05:00 Fix comment reference to T4818 - - - - - 9c3edeb8 by Ben Gamari at 2022-02-25T21:12:09-05:00 simplCore: Correctly extend in-scope set in rule matching Note [Matching lets] in GHC.Core.Rules claims the following: > We use GHC.Core.Subst.substBind to freshen the binding, using an > in-scope set that is the original in-scope variables plus the > rs_bndrs (currently floated let-bindings). However, previously the implementation didn't actually do extend the in-scope set with rs_bndrs. This appears to be a regression which was introduced by 4ff4d434e9a90623afce00b43e2a5a1ccbdb4c05. Moreover, the originally reasoning was subtly wrong: we must rather use the in-scope set from rv_lcl, extended with rs_bndrs, not that of `rv_fltR` Fixes #21122. - - - - - 7f9f49c3 by sheaf at 2022-02-25T21:12:47-05:00 Derive some stock instances for OverridingBool This patch adds some derived instances to `GHC.Data.Bool.OverridingBool`. It also changes the order of the constructors, so that the derived `Ord` instance matches the behaviour for `Maybe Bool`. Fixes #20326 - - - - - 140438a8 by nineonine at 2022-02-25T21:13:23-05:00 Add test for #19271 - - - - - ac9f4606 by sheaf at 2022-02-25T21:14:04-05:00 Allow qualified names in COMPLETE pragmas The parser didn't allow qualified constructor names to appear in COMPLETE pragmas. This patch fixes that. Fixes #20551 - - - - - 677c6c91 by Sylvain Henry at 2022-02-25T21:14:44-05:00 Testsuite: remove arch conditional in T8832 Taken from !3658 - - - - - ad04953b by Sylvain Henry at 2022-02-25T21:15:23-05:00 Allow hscGenHardCode to not return CgInfos This is a minor change in preparation for the JS backend: CgInfos aren't mandatory and the JS backend won't return them. - - - - - 929c280f by Sylvain Henry at 2022-02-25T21:15:24-05:00 Derive Enum instances for CCallConv and Safety This is used by the JS backend for serialization. - - - - - 75e4e090 by Sebastian Graf at 2022-02-25T21:15:59-05:00 base: Improve documentation of `throwIO` (#19854) Now it takes a better account of precise vs. imprecise exception semantics. Fixes #19854. - - - - - 61a203ba by Matthew Pickering at 2022-02-26T02:06:51-05:00 Make typechecking unfoldings from interfaces lazier The old logic was unecessarily strict in loading unfoldings because when reading the unfolding we would case on the result of attempting to load the template before commiting to which type of unfolding we were producing. Hence trying to inspect any of the information about an unfolding would force the template to be loaded. This also removes a potentially hard to discover bug where if the template failed to be typechecked for some reason then we would just not return an unfolding. Instead we now panic so these bad situations which should never arise can be identified. - - - - - 2be74460 by Matthew Pickering at 2022-02-26T02:06:51-05:00 Use a more up-to-date snapshot of the current rules in the simplifier As the prescient (now deleted) note warns in simplifyPgmIO we have to be a bit careful about when we gather rules from the EPS so that we get the rules for imported bindings. ``` -- Get any new rules, and extend the rule base -- See Note [Overall plumbing for rules] in GHC.Core.Rules -- We need to do this regularly, because simplification can -- poke on IdInfo thunks, which in turn brings in new rules -- behind the scenes. Otherwise there's a danger we'll simply -- miss the rules for Ids hidden inside imported inlinings ``` Given the previous commit, the loading of unfoldings is now even more delayed so we need to be more careful to read the EPS rule base closer to the point where we decide to try rules. Without this fix GHC performance regressed by a noticeably amount because the `zip` rule was not brought into scope eagerly enough which led to a further series of unfortunate events in the simplifer which tipped `substTyWithCoVars` over the edge of the size threshold, stopped it being inlined and increased allocations by 10% in some cases. Furthermore, this change is noticeably in the testsuite as it changes T19790 so that the `length` rules from GHC.List fires earlier. ------------------------- Metric Increase: T9961 ------------------------- - - - - - b8046195 by Matthew Pickering at 2022-02-26T02:06:52-05:00 Improve efficiency of extending a RuleEnv with a new RuleBase Essentially we apply the identity: > lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) > = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 The latter being more efficient as we don't construct an intermediate map. This is now quite important as each time we try and apply rules we need to combine the current EPS RuleBase with the HPT and ModGuts rule bases. - - - - - 033e9f0f by sheaf at 2022-02-26T02:07:30-05:00 Error on anon wildcards in tcAnonWildCardOcc The code in tcAnonWildCardOcc assumed that it could never encounter anonymous wildcards in illegal positions, because the renamer would have ruled them out. However, it's possible to sneak past the checks in the renamer by using Template Haskell. It isn't possible to simply pass on additional information when renaming Template Haskell brackets, because we don't know in advance in what context the bracket will be spliced in (see test case T15433b). So we accept that we might encounter these bogus wildcards in the typechecker and throw the appropriate error. This patch also migrates the error messages for illegal wildcards in types to use the diagnostic infrastructure. Fixes #15433 - - - - - 32d8fe3a by sheaf at 2022-02-26T14:15:33+01:00 Core Lint: ensure primops can be eta-expanded This patch adds a check to Core Lint, checkCanEtaExpand, which ensures that primops and other wired-in functions with no binding such as unsafeCoerce#, oneShot, rightSection... can always be eta-expanded, by checking that the remaining argument types have a fixed RuntimeRep. Two subtleties came up: - the notion of arity in Core looks through newtypes, so we may need to unwrap newtypes in this check, - we want to avoid calling hasNoBinding on something whose unfolding we are in the process of linting, as this would cause a loop; to avoid this we add some information to the Core Lint environment that holds this information. Fixes #20480 - - - - - 0a80b436 by Peter Trommler at 2022-02-26T17:21:59-05:00 testsuite: Require LLVM for T15155l - - - - - 38cb920e by Oleg Grenrus at 2022-02-28T07:14:04-05:00 Add Monoid a => Monoid (STM a) instance - - - - - d734ef8f by Hécate Moonlight at 2022-02-28T07:14:42-05:00 Make modules in base stable. fix #18963 - - - - - fbf005e9 by Sven Tennie at 2022-02-28T19:16:01-05:00 Fix some hlint issues in ghc-heap This does not fix all hlint issues as the criticised index and length expressions seem to be fine in context. - - - - - adfddf7d by Matthew Pickering at 2022-02-28T19:16:36-05:00 hadrian: Suggest to the user to run ./configure if missing a setting If a setting is missing from the configuration file it's likely the user needs to reconfigure. Fixes #20476 - - - - - 4f0208e5 by Andreas Klebinger at 2022-02-28T19:17:12-05:00 CLabel cleanup: Remove these smart constructors for these reasons: * mkLocalClosureTableLabel : Does the same as the non-local variant. * mkLocalClosureLabel : Does the same as the non-local variant. * mkLocalInfoTableLabel : Decide if we make a local label based on the name and just use mkInfoTableLabel everywhere. - - - - - 065419af by Matthew Pickering at 2022-02-28T19:17:47-05:00 linking: Don't pass --hash-size and --reduce-memory-overhead to ld These flags were added to help with the high linking cost of the old split-objs mode. Now we are using split-sections these flags appear to make no difference to memory usage or time taken to link. I tested various configurations linking together the ghc library with -split-sections enabled. | linker | time (s) | | ------ | ------ | | gold | 0.95 | | ld | 1.6 | | ld (hash-size = 31, reduce-memory-overheads) | 1.6 | | ldd | 0.47 | Fixes #20967 - - - - - 3e65ef05 by Teo Camarasu at 2022-02-28T19:18:27-05:00 template-haskell: fix typo in docstring for Overlap - - - - - 80f9133e by Teo Camarasu at 2022-02-28T19:18:27-05:00 template-haskell: fix docstring for Bytes It seems like a commented out section of code was accidentally included in the docstring for a field. - - - - - 54774268 by Matthew Pickering at 2022-03-01T16:23:10-05:00 Fix longstanding issue with moduleGraphNodes - no hs-boot files case In the case when we tell moduleGraphNodes to drop hs-boot files the idea is to collapse hs-boot files into their hs file nodes. In the old code * nodeDependencies changed edges from IsBoot to NonBoot * moduleGraphNodes just dropped boot file nodes The net result is that any dependencies of the hs-boot files themselves were dropped. The correct thing to do is * nodeDependencies changes edges from IsBoot to NonBoot * moduleGraphNodes merges dependencies of IsBoot and NonBoot nodes. The result is a properly quotiented dependency graph which contains no hs-boot files nor hs-boot file edges. Why this didn't cause endless issues when compiling with boot files, we will never know. - - - - - c84dc506 by Matthew Pickering at 2022-03-01T16:23:10-05:00 driver: Properly add an edge between a .hs and its hs-boot file As noted in #21071 we were missing adding this edge so there were situations where the .hs file would get compiled before the .hs-boot file which leads to issues with -j. I fixed this properly by adding the edge in downsweep so the definition of nodeDependencies can be simplified to avoid adding this dummy edge in. There are plenty of tests which seem to have these redundant boot files anyway so no new test. #21094 tracks the more general issue of identifying redundant hs-boot and SOURCE imports. - - - - - 7aeb6d29 by sheaf at 2022-03-01T16:23:51-05:00 Core Lint: collect args through floatable ticks We were not looking through floatable ticks when collecting arguments in Core Lint, which caused `checkCanEtaExpand` to fail on something like: ```haskell reallyUnsafePtrEquality = \ @a -> (src<loc> reallyUnsafePtrEquality#) @Lifted @a @Lifted @a ``` We fix this by using `collectArgsTicks tickishFloatable` instead of `collectArgs`, to be consistent with the behaviour of eta expansion outlined in Note [Eta expansion and source notes] in GHC.Core.Opt.Arity. Fixes #21152. - - - - - 75caafaa by Matthew Pickering at 2022-03-02T01:14:59-05:00 Ticky profiling improvements. This adds a number of changes to ticky-ticky profiling. When an executable is profiled with IPE profiling it's now possible to associate id-related ticky counters to their source location. This works by emitting the info table address as part of the counter which can be looked up in the IPE table. Add a `-ticky-ap-thunk` flag. This flag prevents the use of some standard thunks which are precompiled into the RTS. This means reduced cache locality and increased code size. But it allows better attribution of execution cost to specific source locations instead of simple attributing it to the standard thunk. ticky-ticky now uses the `arg` field to emit additional information about counters in json format. When ticky-ticky is used in combination with the eventlog eventlog2html can be used to generate a html table from the eventlog similar to the old text output for ticky-ticky. - - - - - aeea6bd5 by doyougnu at 2022-03-02T01:15:39-05:00 StgToCmm.cgTopBinding: no isNCG, use binBlobThresh This is a one line change. It is a fixup from MR!7325, was pointed out in review of MR!7442, specifically: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7442#note_406581 The change removes isNCG check from cgTopBinding. Instead it changes the type of binBlobThresh in DynFlags from Word to Maybe Word, where a Just 0 or a Nothing indicates an infinite threshold and thus the disable CmmFileEmbed case in the original check. This improves the cohesion of the module because more NCG related Backend stuff is moved into, and checked in, StgToCmm.Config. Note, that the meaning of a Just 0 or a Nothing in binBlobThresh is indicated in a comment next to its field in GHC.StgToCmm.Config. DynFlags: binBlobThresh: Word -> Maybe Word StgToCmm.Config: binBlobThesh add not ncg check DynFlags.binBlob: move Just 0 check to dflags init StgToCmm.binBlob: only check isNCG, Just 0 check to dflags StgToCmm.Config: strictify binBlobThresh - - - - - b27b2af3 by sheaf at 2022-03-02T14:08:36-05:00 Introduce ConcreteTv metavariables This patch introduces a new kind of metavariable, by adding the constructor `ConcreteTv` to `MetaInfo`. A metavariable with `ConcreteTv` `MetaInfo`, henceforth a concrete metavariable, can only be unified with a type that is concrete (that is, a type that answers `True` to `GHC.Core.Type.isConcrete`). This solves the problem of dangling metavariables in `Concrete#` constraints: instead of emitting `Concrete# ty`, which contains a secret existential metavariable, we simply emit a primitive equality constraint `ty ~# concrete_tv` where `concrete_tv` is a fresh concrete metavariable. This means we can avoid all the complexity of canonicalising `Concrete#` constraints, as we can just re-use the existing machinery for `~#`. To finish things up, this patch then removes the `Concrete#` special predicate, and instead introduces the special predicate `IsRefl#` which enforces that a coercion is reflexive. Such a constraint is needed because the canonicaliser is quite happy to rewrite an equality constraint such as `ty ~# concrete_tv`, but such a rewriting is not handled by the rest of the compiler currently, as we need to make use of the resulting coercion, as outlined in the FixedRuntimeRep plan. The big upside of this approach (on top of simplifying the code) is that we can now selectively implement PHASE 2 of FixedRuntimeRep, by changing individual calls of `hasFixedRuntimeRep_MustBeRefl` to `hasFixedRuntimeRep` and making use of the obtained coercion. - - - - - 81b7c436 by Matthew Pickering at 2022-03-02T14:09:13-05:00 Make -dannot-lint not panic on let bound type variables After certain simplifier passes we end up with let bound type variables which are immediately inlined in the next pass. The core diff utility implemented by -dannot-lint failed to take these into account and paniced. Progress towards #20965 - - - - - f596c91a by sheaf at 2022-03-02T14:09:51-05:00 Improve out-of-order inferred type variables Don't instantiate type variables for :type in `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting `r1` but not `r2` in the type forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ... This fixes #21088. This patch also changes the primop pretty-printer to ensure that we put all the inferred type variables first. For example, the type of reallyUnsafePtrEquality# is now forall {l :: Levity} {k :: Levity} (a :: TYPE (BoxedRep l)) (b :: TYPE (BoxedRep k)). a -> b -> Int# This means we avoid running into issue #21088 entirely with the types of primops. Users can still write a type signature where the inferred type variables don't come first, however. This change to primops had a knock-on consequence, revealing that we were sometimes performing eta reduction on keepAlive#. This patch updates tryEtaReduce to avoid eta reducing functions with no binding, bringing it in line with tryEtaReducePrep, and thus fixing #21090. - - - - - 1617fed3 by Richard Eisenberg at 2022-03-02T14:10:28-05:00 Make inert_cycle_breakers into a stack. Close #20231. - - - - - c8652a0a by Richard Eisenberg at 2022-03-02T14:11:03-05:00 Make Constraint not *apart* from Type. More details in Note [coreView vs tcView] Close #21092. - - - - - 91a10cb0 by doyougnu at 2022-03-02T14:11:43-05:00 GenStgAlt 3-tuple synonym --> Record type This commit alters GenStgAlt from a type synonym to a Record with field accessors. In pursuit of #21078, this is not a required change but cleans up several areas for nicer code in the upcoming js-backend, and in GHC itself. GenStgAlt: 3-tuple -> record Stg.Utils: GenStgAlt 3-tuple -> record Stg.Stats: StgAlt 3-tuple --> record Stg.InferTags.Rewrite: StgAlt 3-tuple -> record Stg.FVs: GenStgAlt 3-tuple -> record Stg.CSE: GenStgAlt 3-tuple -> record Stg.InferTags: GenStgAlt 3-tuple --> record Stg.Debug: GenStgAlt 3-tuple --> record Stg.Lift.Analysis: GenStgAlt 3-tuple --> record Stg.Lift: GenStgAlt 3-tuple --> record ByteCode.Instr: GenStgAlt 3-tuple --> record Stg.Syntax: add GenStgAlt helper functions Stg.Unarise: GenStgAlt 3-tuple --> record Stg.BcPrep: GenStgAlt 3-tuple --> record CoreToStg: GenStgAlt 3-tuple --> record StgToCmm.Expr: GenStgAlt 3-tuple --> record StgToCmm.Bind: GenStgAlt 3-tuple --> record StgToByteCode: GenStgAlt 3-tuple --> record Stg.Lint: GenStgAlt 3-tuple --> record Stg.Syntax: strictify GenStgAlt GenStgAlt: add haddock, some cleanup fixup: remove calls to pure, single ViewPattern StgToByteCode: use case over viewpatterns - - - - - 73864f00 by Matthew Pickering at 2022-03-02T14:12:19-05:00 base: Remove default method from bitraversable The default instance leads to an infinite loop. bisequenceA is defined in terms of bisquence which is defined in terms of bitraverse. ``` bitraverse f g = (defn of bitraverse) bisequenceA . bimap f g = (defn of bisequenceA) bitraverse id id . bimap f g = (defn of bitraverse) ... ``` Any instances defined without an explicitly implementation are currently broken, therefore removing it will alert users to an issue in their code. CLC issue: https://github.com/haskell/core-libraries-committee/issues/47 Fixes #20329 #18901 - - - - - 9579bf35 by Matthew Pickering at 2022-03-02T14:12:54-05:00 ci: Add check to CI to ensure compiler uses correct BIGNUM_BACKEND - - - - - c48a7c3a by Sylvain Henry at 2022-03-03T07:37:12-05:00 Use Word64# primops in Word64 Num instance Taken froù!3658 - - - - - ce65d0cc by Matthew Pickering at 2022-03-03T07:37:48-05:00 hadrian: Correctly set whether we have a debug compiler when running tests For example, running the `slow-validate` flavour would incorrectly run the T16135 test which would fail with an assertion error, despite the fact that is should be skipped when we have a debug compiler. - - - - - e0c3e757 by Matthew Pickering at 2022-03-03T13:48:41-05:00 docs: Add note to unsafeCoerce function that you might want to use coerce [skip ci] Fixes #15429 - - - - - 559d4cf3 by Matthew Pickering at 2022-03-03T13:49:17-05:00 docs: Add note to RULES documentation about locally bound variables [skip ci] Fixes #20100 - - - - - c534b3dd by Matthew Pickering at 2022-03-03T13:49:53-05:00 Replace ad-hoc CPP with constant from GHC.Utils.Constant Fixes #21154 - - - - - de56cc7e by Krzysztof Gogolewski at 2022-03-04T12:44:26-05:00 Update documentation of LiberalTypeSynonyms We no longer require LiberalTypeSynonyms to use 'forall' or an unboxed tuple in a synonym. I also removed that kind checking before expanding synonyms "could be changed". This was true when type synonyms were thought of macros, but with the extensions such as SAKS or matchability I don't see it changing. - - - - - c0a39259 by Simon Jakobi at 2022-03-04T12:45:01-05:00 base: Mark GHC.Bits not-home for haddock Most (all) of the exports are re-exported from the preferable Data.Bits. - - - - - 3570eda5 by Sylvain Henry at 2022-03-04T12:45:42-05:00 Fix comments about Int64/Word64 primops - - - - - 6f84ee33 by Artem Pelenitsyn at 2022-03-05T01:06:47-05:00 remove MonadFail instances of ST CLC proposal: https://github.com/haskell/core-libraries-committee/issues/33 The instances had `fail` implemented in terms of `error`, whereas the idea of the `MonadFail` class is that the `fail` method should be implemented in terms of the monad itself. - - - - - 584cd5ae by sheaf at 2022-03-05T01:07:25-05:00 Don't allow Float#/Double# literal patterns This patch does the following two things: 1. Fix the check in Core Lint to properly throw an error when it comes across Float#/Double# literal patterns. The check was incorrect before, because it expected the type to be Float/Double instead of Float#/Double#. 2. Add an error in the parser when the user writes a floating-point literal pattern such as `case x of { 2.0## -> ... }`. Fixes #21115 - - - - - 706deee0 by Greg Steuck at 2022-03-05T17:44:10-08:00 Make T20214 terminate promptly be setting input to /dev/null It was hanging and timing out on OpenBSD before. - - - - - 14e90098 by Simon Peyton Jones at 2022-03-07T14:05:41-05:00 Always generalise top-level bindings Fix #21023 by always generalising top-level binding; change the documentation of -XMonoLocalBinds to match. - - - - - c9c31c3c by Matthew Pickering at 2022-03-07T14:06:16-05:00 hadrian: Add little flavour transformer to build stage2 with assertions This can be useful to build a `perf+assertions` build or even better `default+no_profiled_libs+omit_pragmas+assertions`. - - - - - 89c14a6c by Matthew Pickering at 2022-03-07T14:06:16-05:00 ci: Convert all deb10 make jobs into hadrian jobs This is the first step in converting all the CI configs to use hadrian rather than make. (#21129) The metrics increase due to hadrian using --hyperlinked-source for haddock builds. (See #21156) ------------------------- Metric Increase: haddock.Cabal haddock.base haddock.compiler ------------------------- - - - - - 7bfae2ee by Matthew Pickering at 2022-03-07T14:06:16-05:00 Replace use of BIN_DIST_PREP_TAR_COMP with BIN_DIST_NAME And adds a check to make sure we are not accidently settings BIN_DIST_PREP_TAR_COMP when using hadrian. - - - - - 5b35ca58 by Matthew Pickering at 2022-03-07T14:06:16-05:00 Fix gen_contents_index logic for hadrian bindist - - - - - 273bc133 by Krzysztof Gogolewski at 2022-03-07T14:06:52-05:00 Fix reporting constraints in pprTcSolverReportMsg 'no_instance_msg' and 'no_deduce_msg' were omitting the first wanted. - - - - - 5874a30a by Simon Jakobi at 2022-03-07T14:07:28-05:00 Improve setBit for Natural Previously the default definition was used, which involved allocating intermediate Natural values. Fixes #21173. - - - - - 7a02aeb8 by Matthew Pickering at 2022-03-07T14:08:03-05:00 Remove leftover trace in testsuite - - - - - 6ce6c250 by Andreas Klebinger at 2022-03-07T23:48:56-05:00 Expand and improve the Note [Strict Worker Ids]. I've added an explicit mention of the invariants surrounding those. As well as adding more direct cross references to the Strict Field Invariant. - - - - - d0f892fe by Ryan Scott at 2022-03-07T23:49:32-05:00 Delete GenericKind_ in favor of GenericKind_DC When deriving a `Generic1` instance, we need to know what the last type variable of a data type is. Previously, there were two mechanisms to determine this information: * `GenericKind_`, where `Gen1_` stored the last type variable of a data type constructor (i.e., the `tyConTyVars`). * `GenericKind_DC`, where `Gen1_DC` stored the last universally quantified type variable in a data constructor (i.e., the `dataConUnivTyVars`). These had different use cases, as `GenericKind_` was used for generating `Rep(1)` instances, while `GenericKind_DC` was used for generating `from(1)` and `to(1)` implementations. This was already a bit confusing, but things went from confusing to outright wrong after !6976. This is because after !6976, the `deriving` machinery stopped using `tyConTyVars` in favor of `dataConUnivTyVars`. Well, everywhere with the sole exception of `GenericKind_`, which still continued to use `tyConTyVars`. This lead to disaster when deriving a `Generic1` instance for a GADT family instance, as the `tyConTyVars` do not match the `dataConUnivTyVars`. (See #21185.) The fix is to stop using `GenericKind_` and replace it with `GenericKind_DC`. For the most part, this proves relatively straightforward. Some highlights: * The `forgetArgVar` function was deleted entirely, as it no longer proved necessary after `GenericKind_`'s demise. * The substitution that maps from the last type variable to `Any` (see `Note [Generating a correctly typed Rep instance]`) had to be moved from `tc_mkRepTy` to `tc_mkRepFamInsts`, as `tc_mkRepTy` no longer has access to the last type variable. Fixes #21185. - - - - - a60ddffd by Matthew Pickering at 2022-03-08T22:51:37+00:00 Move bootstrap and cabal-reinstall test jobs to nightly CI is creaking under the pressure of too many jobs so attempt to reduce the strain by removing a couple of jobs. - - - - - 7abe3288 by Matthew Pickering at 2022-03-09T10:24:15+00:00 Add 10 minute timeout to linters job - - - - - 3cf75ede by Matthew Pickering at 2022-03-09T10:24:16+00:00 Revert "hadrian: Correctly set whether we have a debug compiler when running tests" Needing the arguments for "GHC/Utils/Constant.hs" implies a dependency on the previous stage compiler. Whilst we work out how to get around this I will just revert this commit (as it only affects running the testsuite in debug way). This reverts commit ce65d0cceda4a028f30deafa3c39d40a250acc6a. - - - - - 18b9ba56 by Matthew Pickering at 2022-03-09T11:07:23+00:00 ci: Fix save_cache function Each interation of saving the cache would copy the whole `cabal` store into a subfolder in the CACHE_DIR rather than copying the contents of the cabal store into the cache dir. This resulted in a cache which looked like: ``` /builds/ghc/ghc/cabal-cache/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/cabal/ ``` So it would get one layer deeper every CI run and take longer and longer to compress. - - - - - bc684dfb by Ben Gamari at 2022-03-10T03:20:07-05:00 mr-template: Mention timeframe for review - - - - - 7f5f4ede by Vladislav Zavialov at 2022-03-10T03:20:43-05:00 Bump submodules: containers, exceptions GHC Proposal #371 requires TypeOperators to use type equality a~b. This submodule update pulls in the appropriate forward-compatibility changes in 'libraries/containers' and 'libraries/exceptions' - - - - - 8532b8a9 by Matthew Pickering at 2022-03-10T03:20:43-05:00 Add an inline pragma to lookupVarEnv The containers bump reduced the size of the Data.IntMap.Internal.lookup function so that it no longer experienced W/W. This means that the size of lookupVarEnv increased over the inlining threshold and it wasn't inlined into the hot code path in substTyVar. See containers#821, #21159 and !7638 for some more explanation. ------------------------- Metric Decrease: LargeRecord T12227 T13386 T15703 T18223 T5030 T8095 T9872a T9872b T9872c TcPlugin_RewritePerf ------------------------- - - - - - 844cf1e1 by Matthew Pickering at 2022-03-10T03:20:43-05:00 Normalise output of T10970 test The output of this test changes each time the containers submodule version updates. It's easier to apply the version normaliser so that the test checks that there is a version number, but not which one it is. - - - - - 24b6af26 by Ryan Scott at 2022-03-11T19:56:28-05:00 Refactor tcDeriving to generate tyfam insts before any bindings Previously, there was an awful hack in `genInst` (now called `genInstBinds` after this patch) where we had to return a continutation rather than directly returning the bindings for a derived instance. This was done for staging purposes, as we had to first infer the instance contexts for derived instances and then feed these contexts into the continuations to ensure the generated instance bindings had accurate instance contexts. `Note [Staging of tcDeriving]` in `GHC.Tc.Deriving` described this confusing state of affairs. The root cause of this confusing design was the fact that `genInst` was trying to generate instance bindings and associated type family instances for derived instances simultaneously. This really isn't possible, however: as `Note [Staging of tcDeriving]` explains, one needs to have access to the associated type family instances before one can properly infer the instance contexts for derived instances. The use of continuation-returning style was an attempt to circumvent this dependency, but it did so in an awkward way. This patch detangles this awkwardness by splitting up `genInst` into two functions: `genFamInsts` (for associated type family instances) and `genInstBinds` (for instance bindings). Now, the `tcDeriving` function calls `genFamInsts` and brings all the family instances into scope before calling `genInstBinds`. This removes the need for the awkward continuation-returning style seen in the previous version of `genInst`, making the code easier to understand. There are some knock-on changes as well: 1. `hasStockDeriving` now needs to return two separate functions: one that describes how to generate family instances for a stock-derived instance, and another that describes how to generate the instance bindings. I factored out this pattern into a new `StockGenFns` data type. 2. While documenting `StockGenFns`, I realized that there was some inconsistency regarding which `StockGenFns` functions needed which arguments. In particular, the function in `GHC.Tc.Deriv.Generics` which generates `Rep(1)` instances did not take a `SrcSpan` like other `gen_*` functions did, and it included an extra `[Type]` argument that was entirely redundant. As a consequence, I refactored the code in `GHC.Tc.Deriv.Generics` to more closely resemble other `gen_*` functions. A happy result of all this is that all `StockGenFns` functions now take exactly the same arguments, which makes everything more uniform. This is purely a refactoring that should not have any effect on user-observable behavior. The new design paves the way for an eventual fix for #20719. - - - - - 62caaa9b by Ben Gamari at 2022-03-11T19:57:03-05:00 gitlab-ci: Use the linters image in hlint job As the `hlint` executable is only available in the linters image. Fixes #21146. - - - - - 4abd7eb0 by Matthew Pickering at 2022-03-11T19:57:38-05:00 Remove partOfGhci check in the loader This special logic has been part of GHC ever since template haskell was introduced in 9af77fa423926fbda946b31e174173d0ec5ebac8. It's hard to believe in any case that this special logic pays its way at all. Given * The list is out-of-date, which has potential to lead to miscompilation when using "editline", which was removed in 2010 (46aed8a4). * The performance benefit seems negligable as each load only happens once anyway and packages specified by package flags are preloaded into the linker state at the start of compilation. Therefore we just remove this logic. Fixes #19791 - - - - - c40cbaa2 by Andreas Klebinger at 2022-03-11T19:58:14-05:00 Improve -dtag-inference-checks checks. FUN closures don't get tagged when evaluated. So no point in checking their tags. - - - - - ab00d23b by Simon Jakobi at 2022-03-11T19:58:49-05:00 Improve clearBit and complementBit for Natural Also optimize bigNatComplementBit#. Fixes #21175, #21181, #21194. - - - - - a6d8facb by Sebastian Graf at 2022-03-11T19:59:24-05:00 gitignore all (build) directories headed by _ - - - - - 524795fe by Sebastian Graf at 2022-03-11T19:59:24-05:00 Demand: Document why we need three additional equations of multSubDmd - - - - - 6bdcd557 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: make 64-bit word splitting for 32-bit targets respect target endianness This used to been broken for little-endian targets. - - - - - 9e67c69e by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: fix Double# literal payload for 32-bit targets Contrary to the legacy comment, the splitting didn't happen and we ended up with a single StgWord64 literal in the output code! Let's just do the splitting here. - - - - - 1eee2e28 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: use __builtin versions of memcpyish functions to fix type mismatch Our memcpyish primop's type signatures doesn't match the C type signatures. It's not a problem for typical archs, since their C ABI permits dropping the result, but it doesn't work for wasm. The previous logic would cast the memcpyish function pointer to an incorrect type and perform an indirect call, which results in a runtime trap on wasm. The most straightforward fix is: don't emit EFF_ for memcpyish functions. Since we don't want to include extra headers in .hc to bring in their prototypes, we can just use the __builtin versions. - - - - - 9d8d4837 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: emit __builtin_unreachable() when CmmSwitch doesn't contain fallback case Otherwise the C compiler may complain "warning: non-void function does not return a value in all control paths [-Wreturn-type]". - - - - - 27da5540 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: make floatToWord32/doubleToWord64 faster Use castFloatToWord32/castDoubleToWord64 in base to perform the reinterpret cast. - - - - - c98e8332 by Cheng Shao at 2022-03-11T20:00:01-05:00 CmmToC: fix -Wunused-value warning in ASSIGN_BaseReg When ASSIGN_BaseReg is a no-op, we shouldn't generate any C code, otherwise C compiler complains a bunch of -Wunused-value warnings when doing unregisterised codegen. - - - - - 5932247c by Ben Gamari at 2022-03-11T20:00:36-05:00 users guide: Eliminate spurious \spxentry mentions We were failing to pass the style file to `makeindex`, as is done by the mklatex configuration generated by Sphinx. Fixes #20913. - - - - - e40cf4ef by Simon Jakobi at 2022-03-11T20:01:11-05:00 ghc-bignum: Tweak integerOr The result of ORing two BigNats is always greater or equal to the larger of the two. Therefore it is safe to skip the magnitude checks of integerFromBigNat#. - - - - - cf081476 by Vladislav Zavialov at 2022-03-12T07:02:40-05:00 checkUnboxedLitPat: use non-fatal addError This enables GHC to report more parse errors in a single pass. - - - - - 7fe07143 by Andreas Klebinger at 2022-03-12T07:03:16-05:00 Rename -fprof-late-ccs to -fprof-late - - - - - 88a94541 by Sylvain Henry at 2022-03-12T07:03:56-05:00 Hadrian: avoid useless allocations in trackArgument Cf ticky report before the change: Entries Alloc Alloc'd Non-void Arguments STG Name -------------------------------------------------------------------------------- 696987 29044128 0 1 L main:Target.trackArgument_go5{v r24kY} (fun) - - - - - 2509d676 by Sylvain Henry at 2022-03-12T07:04:36-05:00 Hadrian: avoid allocating in stageString (#19209) - - - - - c062fac0 by Sylvain Henry at 2022-03-12T07:04:36-05:00 Hadrian: remove useless imports Added for no reason in 7ce1b694f7be7fbf6e2d7b7eb0639e61fbe358c6 - - - - - c82fb934 by Sylvain Henry at 2022-03-12T07:05:16-05:00 Hadrian: avoid allocations in WayUnit's Read instance (#19209) - - - - - ed04aed2 by Sylvain Henry at 2022-03-12T07:05:16-05:00 Hadrian: use IntSet Binary instance for Way (#19209) - - - - - ad835531 by Simon Peyton Jones at 2022-03-13T18:12:12-04:00 Fix bug in weak loop-breakers in OccurAnal Note [Weak loop breakers] explains why we need to track variables free in RHS of rules. But we need to do this for /inactive/ rules as well as active ones, unlike the rhs_fv_env stuff. So we now have two fields in node Details, one for free vars of active rules, and one for free vars of all rules. This was shown up by #20820, which is now fixed. - - - - - 76b94b72 by Sebastian Graf at 2022-03-13T18:12:48-04:00 Worker/wrapper: Preserve float barriers (#21150) Issue #21150 shows that worker/wrapper allocated a worker function for a function with multiple calls that said "called at most once" when the first argument was absent. That's bad! This patch makes it so that WW preserves at least one non-one-shot value lambda (see `Note [Preserving float barriers]`) by passing around `void#` in place of absent arguments. Fixes #21150. Since the fix is pretty similar to `Note [Protecting the last value argument]`, I put the logic in `mkWorkerArgs`. There I realised (#21204) that `-ffun-to-thunk` is basically useless with `-ffull-laziness`, so I deprecated the flag, simplified and split into `needsVoidWorkerArg`/`addVoidWorkerArg`. SpecConstr is another client of that API. Fixes #21204. Metric Decrease: T14683 - - - - - 97db789e by romes at 2022-03-14T11:36:39-04:00 Fix up Note [Bind free vars] Move GHC-specific comments from Language.Haskell.Syntax.Binds to GHC.Hs.Binds It looks like the Note was deleted but there were actually two copies of it. L.H.S.B no longer references it, and GHC.Hs.Binds keeps an updated copy. (See #19252) There are other duplicated notes -- they will be fixed in the next commit - - - - - 135888dd by romes at 2022-03-14T11:36:39-04:00 TTG Pull AbsBinds and ABExport out of the main AST AbsBinds and ABExport both depended on the typechecker, and were thus removed from the main AST Expr. CollectPass now has a new function `collectXXHsBindsLR` used for the new HsBinds extension point Bumped haddock submodule to work with AST changes. The removed Notes from Language.Haskell.Syntax.Binds were duplicated (and not referenced) and the copies in GHC.Hs.Binds are kept (and referenced there). (See #19252) - - - - - 106413f0 by sheaf at 2022-03-14T11:37:21-04:00 Add two coercion optimisation perf tests - - - - - 8eadea67 by sheaf at 2022-03-14T15:08:24-04:00 Fix isLiftedType_maybe and handle fallout As #20837 pointed out, `isLiftedType_maybe` returned `Just False` in many situations where it should return `Nothing`, because it didn't take into account type families or type variables. In this patch, we fix this issue. We rename `isLiftedType_maybe` to `typeLevity_maybe`, which now returns a `Levity` instead of a boolean. We now return `Nothing` for types with kinds of the form `TYPE (F a1 ... an)` for a type family `F`, as well as `TYPE (BoxedRep l)` where `l` is a type variable. This fix caused several other problems, as other parts of the compiler were relying on `isLiftedType_maybe` returning a `Just` value, and were now panicking after the above fix. There were two main situations in which panics occurred: 1. Issues involving the let/app invariant. To uphold that invariant, we need to know whether something is lifted or not. If we get an answer of `Nothing` from `isLiftedType_maybe`, then we don't know what to do. As this invariant isn't particularly invariant, we can change the affected functions to not panic, e.g. by behaving the same in the `Just False` case and in the `Nothing` case (meaning: no observable change in behaviour compared to before). 2. Typechecking of data (/newtype) constructor patterns. Some programs involving patterns with unknown representations were accepted, such as T20363. Now that we are stricter, this caused further issues, culminating in Core Lint errors. However, the behaviour was incorrect the whole time; the incorrectness only being revealed by this change, not triggered by it. This patch fixes this by overhauling where the representation polymorphism involving pattern matching are done. Instead of doing it in `tcMatches`, we instead ensure that the `matchExpected` functions such as `matchExpectedFunTys`, `matchActualFunTySigma`, `matchActualFunTysRho` allow return argument pattern types which have a fixed RuntimeRep (as defined in Note [Fixed RuntimeRep]). This ensures that the pattern matching code only ever handles types with a known runtime representation. One exception was that patterns with an unknown representation type could sneak in via `tcConPat`, which points to a missing representation-polymorphism check, which this patch now adds. This means that we now reject the program in #20363, at least until we implement PHASE 2 of FixedRuntimeRep (allowing type families in RuntimeRep positions). The aforementioned refactoring, in which checks have been moved to `matchExpected` functions, is a first step in implementing PHASE 2 for patterns. Fixes #20837 - - - - - 8ff32124 by Sebastian Graf at 2022-03-14T15:09:01-04:00 DmdAnal: Don't unbox recursive data types (#11545) As `Note [Demand analysis for recursive data constructors]` describes, we now refrain from unboxing recursive data type arguments, for two reasons: 1. Relating to run/alloc perf: Similar to `Note [CPR for recursive data constructors]`, it seldomly improves run/alloc performance if we just unbox a finite number of layers of a potentially huge data structure. 2. Relating to ghc/alloc perf: Inductive definitions on single-product recursive data types like the one in T11545 will (diverge, and) have very deep demand signatures before any other abortion mechanism in Demand analysis is triggered. That leads to great and unnecessary churn on Demand analysis when ultimately we will never make use of any nested strictness information anyway. Conclusion: Discard nested demand and boxity information on such recursive types with the help of `Note [Detecting recursive data constructors]`. I also implemented `GHC.Types.Unique.MemoFun.memoiseUniqueFun` in order to avoid the overhead of repeated calls to `GHC.Core.Opt.WorkWrap.Utils.isRecDataCon`. It's nice and simple and guards against some smaller regressions in T9233 and T16577. ghc/alloc performance-wise, this patch is a very clear win: Test Metric value New value Change --------------------------------------------------------------------------------------- LargeRecord(normal) ghc/alloc 6,141,071,720 6,099,871,216 -0.7% MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,740,973,040 2,705,146,640 -1.3% T11545(normal) ghc/alloc 945,475,492 85,768,928 -90.9% GOOD T13056(optasm) ghc/alloc 370,245,880 326,980,632 -11.7% GOOD T18304(normal) ghc/alloc 90,933,944 76,998,064 -15.3% GOOD T9872a(normal) ghc/alloc 1,800,576,840 1,792,348,760 -0.5% T9872b(normal) ghc/alloc 2,086,492,432 2,073,991,848 -0.6% T9872c(normal) ghc/alloc 1,750,491,240 1,737,797,832 -0.7% TcPlugin_RewritePerf(normal) ghc/alloc 2,286,813,400 2,270,957,896 -0.7% geo. mean -2.9% No noteworthy change in run/alloc either. NoFib results show slight wins, too: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- constraints -1.9% -1.4% fasta -3.6% -2.7% reverse-complem -0.3% -0.9% treejoin -0.0% -0.3% -------------------------------------------------------------------------------- Min -3.6% -2.7% Max +0.1% +0.1% Geometric Mean -0.1% -0.1% Metric Decrease: T11545 T13056 T18304 - - - - - ab618309 by Vladislav Zavialov at 2022-03-15T18:34:38+03:00 Export (~) from Data.Type.Equality (#18862) * Users can define their own (~) type operator * Haddock can display documentation for the built-in (~) * New transitional warnings implemented: -Wtype-equality-out-of-scope -Wtype-equality-requires-operators Updates the haddock submodule. - - - - - 577135bf by Aaron Allen at 2022-03-16T02:27:48-04:00 Convert Diagnostics in GHC.Tc.Gen.Foreign Converts all uses of 'TcRnUnknownMessage' to proper diagnostics. - - - - - c1fed9da by Aaron Allen at 2022-03-16T02:27:48-04:00 Suggest FFI extensions as hints (#20116) - Use extension suggestion hints instead of suggesting extensions in the error message body for several FFI errors. - Adds a test case for `TcRnForeignImportPrimExtNotSet` - - - - - a33d1045 by Zubin Duggal at 2022-03-16T02:28:24-04:00 TH: allow negative patterns in quotes (#20711) We still don't allow negative overloaded patterns. Earler all negative patterns were treated as negative overloaded patterns. Now, we expliclty check the extension field to see if the pattern is actually a negative overloaded pattern - - - - - 1575c4a5 by Sebastian Graf at 2022-03-16T02:29:03-04:00 Demand: Let `Boxed` win in `lubBoxity` (#21119) Previously, we let `Unboxed` win in `lubBoxity`, which is unsoundly optimistic in terms ob Boxity analysis. "Unsoundly" in the sense that we sometimes unbox parameters that we better shouldn't unbox. Examples are #18907 and T19871.absent. Until now, we thought that this hack pulled its weight becuase it worked around some shortcomings of the phase separation between Boxity analysis and CPR analysis. But it is a gross hack which caused regressions itself that needed all kinds of fixes and workarounds. See for example #20767. It became impossible to work with in !7599, so I want to remove it. For example, at the moment, `lubDmd B dmd` will not unbox `dmd`, but `lubDmd A dmd` will. Given that `B` is supposed to be the bottom element of the lattice, it's hardly justifiable to get a better demand when `lub`bing with `A`. The consequence of letting `Boxed` win in `lubBoxity` is that we *would* regress #2387, #16040 and parts of #5075 and T19871.sumIO, until Boxity and CPR are able to communicate better. Fortunately, that is not the case since I could tweak the other source of optimism in Boxity analysis that is described in `Note [Unboxed demand on function bodies returning small products]` so that we *recursively* assume unboxed demands on function bodies returning small products. See the updated Note. `Note [Boxity for bottoming functions]` describes why we need bottoming functions to have signatures that say that they deeply unbox their arguments. In so doing, I had to tweak `finaliseArgBoxities` so that it will never unbox recursive data constructors. This is in line with our handling of them in CPR. I updated `Note [Which types are unboxed?]` to reflect that. In turn we fix #21119, #20767, #18907, T19871.absent and get a much simpler implementation (at least to think about). We can also drop the very ad-hoc definition of `deferAfterPreciseException` and its Note in favor of the simple, intuitive definition we used to have. Metric Decrease: T16875 T18223 T18698a T18698b hard_hole_fits Metric Increase: LargeRecord MultiComponentModulesRecomp T15703 T8095 T9872d Out of all the regresions, only the one in T9872d doesn't vanish in a perf build, where the compiler is bootstrapped with -O2 and thus SpecConstr. Reason for regressions: * T9872d is due to `ty_co_subst` taking its `LiftingContext` boxed. That is because the context is passed to a function argument, for example in `liftCoSubstTyVarBndrUsing`. * In T15703, LargeRecord and T8095, we get a bit more allocations in `expand_syn` and `piResultTys`, because a `TCvSubst` isn't unboxed. In both cases that guards against reboxing in some code paths. * The same is true for MultiComponentModulesRecomp, where we get less unboxing in `GHC.Unit.Finder.$wfindInstalledHomeModule`. In a perf build, allocations actually *improve* by over 4%! Results on NoFib: -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- awards -0.4% +0.3% cacheprof -0.3% +2.4% fft -1.5% -5.1% fibheaps +1.2% +0.8% fluid -0.3% -0.1% ida +0.4% +0.9% k-nucleotide +0.4% -0.1% last-piece +10.5% +13.9% lift -4.4% +3.5% mandel2 -99.7% -99.8% mate -0.4% +3.6% parser -1.0% +0.1% puzzle -11.6% +6.5% reverse-complem -3.0% +2.0% scs -0.5% +0.1% sphere -0.4% -0.2% wave4main -8.2% -0.3% -------------------------------------------------------------------------------- Summary excludes mandel2 because of excessive bias Min -11.6% -5.1% Max +10.5% +13.9% Geometric Mean -0.2% +0.3% -------------------------------------------------------------------------------- Not bad for a bug fix. The regression in `last-piece` could become a win if SpecConstr would work on non-recursive functions. The regression in `fibheaps` is due to `Note [Reboxed crud for bottoming calls]`, e.g., #21128. - - - - - bb779b90 by sheaf at 2022-03-16T02:29:42-04:00 Add a regression test for #21130 This problem was due to a bug in cloneWanted, which was incorrectly creating a coercion hole to hold an evidence variable. This bug was introduced by 8bb52d91 and fixed in 81740ce8. Fixes #21130 - - - - - 0f0e2394 by Tamar Christina at 2022-03-17T10:16:37-04:00 linker: Initial Windows C++ exception unwinding support - - - - - 36d20d4d by Tamar Christina at 2022-03-17T10:16:37-04:00 linker: Fix ADDR32NB relocations on Windows - - - - - 8a516527 by Tamar Christina at 2022-03-17T10:16:37-04:00 testsuite: properly escape string paths - - - - - 1a0dd008 by sheaf at 2022-03-17T10:17:13-04:00 Hadrian: account for change in late-ccs flag The late cost centre flag was renamed from -fprof-late-ccs to -fprof-late in 7fe07143, but this change hadn't been propagated to Hadrian. - - - - - 8561c1af by romes at 2022-03-18T05:10:58-04:00 TTG: Refactor HsBracket - - - - - 19163397 by romes at 2022-03-18T05:10:58-04:00 Type-checking untyped brackets When HsExpr GhcTc, the HsBracket constructor should hold a HsBracket GhcRn, rather than an HsBracket GhcTc. We make use of the HsBracket p extension constructor (XBracket (XXBracket p)) to hold an HsBracket GhcRn when the pass is GhcTc See !4782 https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - 310890a5 by romes at 2022-03-18T05:10:58-04:00 Separate constructors for typed and untyped brackets Split HsBracket into HsTypedBracket and HsUntypedBracket. Unfortunately, we still cannot get rid of instance XXTypedBracket GhcTc = HsTypedBracket GhcRn despite no longer requiring it for typechecking, but rather because the TH desugarer works on GhcRn rather than GhcTc (See GHC.HsToCore.Quote) - - - - - 4a2567f5 by romes at 2022-03-18T05:10:58-04:00 TTG: Refactor bracket for desugaring during tc When desugaring a bracket we want to desugar /renamed/ rather than /typechecked/ code; So in (HsExpr GhcTc) tree, we must have a (HsExpr GhcRn) for the quotation itself. This commit reworks the TTG refactor on typed and untyped brackets by storing the /renamed/ code in the bracket field extension rather than in the constructor extension in `HsQuote` (previously called `HsUntypedBracket`) See Note [The life cycle of a TH quotation] and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - b056adc8 by romes at 2022-03-18T05:10:58-04:00 TTG: Make HsQuote GhcTc isomorphic to NoExtField An untyped bracket `HsQuote p` can never be constructed with `p ~ GhcTc`. This is because we don't typecheck `HsQuote` at all. That's OK, because we also never use `HsQuote GhcTc`. To enforce this at the type level we make `HsQuote GhcTc` isomorphic to `NoExtField` and impossible to construct otherwise, by using TTG field extensions to make all constructors, except for `XQuote` (which takes `NoExtField`), unconstructable, with `DataConCantHappen` This is explained more in detail in Note [The life cycle of a TH quotation] Related discussion: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782 - - - - - ac3b2e7d by romes at 2022-03-18T05:10:58-04:00 TTG: TH brackets finishing touches Rewrite the critical notes and fix outdated ones, use `HsQuote GhcRn` (in `HsBracketTc`) for desugaring regardless of the bracket being typed or untyped, remove unused `EpAnn` from `Hs*Bracket GhcRn`, zonkExpr factor out common brackets code, ppr_expr factor out common brackets code, and fix tests, to finish MR https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4782. ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - d147428a by Ben Gamari at 2022-03-18T05:11:35-04:00 codeGen: Fix signedness of jump table indexing Previously while constructing the jump table index we would zero-extend the discriminant before subtracting the start of the jump-table. This goes subtly wrong in the case of a sub-word, signed discriminant, as described in the included Note. Fix this in both the PPC and X86 NCGs. Fixes #21186. - - - - - 435a3d5d by Ben Gamari at 2022-03-18T05:11:35-04:00 testsuite: Add test for #21186 - - - - - e9d8de93 by Zubin Duggal at 2022-03-19T07:35:49-04:00 TH: Fix pretty printing of newtypes with operators and GADT syntax (#20868) The pretty printer for regular data types already accounted for these, and had some duplication with the newtype pretty printer. Factoring the logic out into a common function and using it for both newtypes and data declarations is enough to fix the bug. - - - - - 244da9eb by sheaf at 2022-03-19T07:36:24-04:00 List GHC.Event.Internal in base.cabal on Windows GHC.Event.Internal was not listed in base.cabal on Windows. This caused undefined reference errors. This patch adds it back, by moving it out of the OS-specific logic in base.cabal. Fixes #21245. - - - - - d1c03719 by Andreas Klebinger at 2022-03-19T07:37:00-04:00 Compact regions: Maintain tags properly Fixes #21251 - - - - - d45bb701 by romes at 2022-03-19T07:37:36-04:00 Remove dead code HsDoRn - - - - - c842611f by nineonine at 2022-03-20T21:16:06-04:00 Revamp derived Eq instance code generation (#17240) This patch improves code generation for derived Eq instances. The idea is to use 'dataToTag' to evaluate both arguments. This allows to 'short-circuit' when tags do not match. Unfortunately, inner evals are still present when we branch on tags. This is due to the way 'dataToTag#' primop evaluates its argument in the code generator. #21207 was created to explore further optimizations. Metric Decrease: LargeRecord - - - - - 52ffd38c by Sylvain Henry at 2022-03-20T21:16:46-04:00 Avoid some SOURCE imports - - - - - b91798be by Zubin Duggal at 2022-03-23T13:39:39-04:00 hi haddock: Lex and store haddock docs in interface files Names appearing in Haddock docstrings are lexed and renamed like any other names appearing in the AST. We currently rename names irrespective of the namespace, so both type and constructor names corresponding to an identifier will appear in the docstring. Haddock will select a given name as the link destination based on its own heuristics. This patch also restricts the limitation of `-haddock` being incompatible with `Opt_KeepRawTokenStream`. The export and documenation structure is now computed in GHC and serialised in .hi files. This can be used by haddock to directly generate doc pages without reparsing or renaming the source. At the moment the operation of haddock is not modified, that's left to a future patch. Updates the haddock submodule with the minimum changes needed. - - - - - 78db231f by Cheng Shao at 2022-03-23T13:40:17-04:00 configure: bump LlvmMaxVersion to 14 LLVM 13.0.0 is released in Oct 2021, and latest head validates against LLVM 13 just fine if LlvmMaxVersion is bumped. - - - - - b06e5dd8 by Adam Sandberg Ericsson at 2022-03-23T13:40:54-04:00 docs: clarify the eventlog format documentation a little bit - - - - - 4dc62498 by Matthew Pickering at 2022-03-23T13:41:31-04:00 Fix behaviour of -Wunused-packages in ghci Ticket #21110 points out that -Wunused-packages behaves a bit unusually in GHCi. Now we define the semantics for -Wunused-packages in interactive mode as follows: * If you use -Wunused-packages on an initial load then the warning is reported. * If you explicitly set -Wunused-packages on the command line then the warning is displayed (until it is disabled) * If you then subsequently modify the set of available targets by using :load or :cd (:cd unloads everything) then the warning is (silently) turned off. This means that every :r the warning is printed if it's turned on (but you did ask for it). Fixes #21110 - - - - - fed05347 by Ben Gamari at 2022-03-23T13:42:07-04:00 rts/adjustor: Place adjustor templates in data section on all OSs In !7604 we started placing adjustor templates in the data section on Linux as some toolchains there reject relocations in the text section. However, it turns out that OpenBSD also exhibits this restriction. Fix this by *always* placing adjustor templates in the data section. Fixes #21155. - - - - - db32bb8c by Zubin Duggal at 2022-03-23T13:42:44-04:00 Improve error message when warning about unsupported LLVM version (#20958) Change the wording to make it clear that the upper bound is non-inclusive. - - - - - f214349a by Ben Gamari at 2022-03-23T13:43:20-04:00 rts: Untag function field in scavenge_PAP_payload Previously we failed to untag the function closure when scavenging the payload of a PAP, resulting in an invalid closure pointer being passed to scavenge_large_bitmap and consequently #21254. Fix this. Fixes #21254 - - - - - e6d0e287 by Ben Gamari at 2022-03-23T13:43:20-04:00 rts: Don't mark object code in markCAFs unless necessary Previously `markCAFs` would call `markObjectCode` even in non-major GCs. This is problematic since `prepareUnloadCheck` is not called in such GCs, meaning that the section index has not been updated. Fixes #21254 - - - - - 1a7cf096 by Sylvain Henry at 2022-03-23T13:44:05-04:00 Avoid redundant imports of GHC.Driver.Session Remove GHC.Driver.Session imports that weren't considered as redundant because of the reexport of PlatformConstants. Also remove this reexport as modules using this datatype should import GHC.Platform instead. - - - - - e3f60577 by Sylvain Henry at 2022-03-23T13:44:05-04:00 Reverse dependency between StgToCmm and Runtime.Heap.Layout - - - - - e6585ca1 by Sylvain Henry at 2022-03-23T13:44:46-04:00 Define filterOut with filter filter has fusion rules that filterOut lacks - - - - - c58d008c by Ryan Scott at 2022-03-24T06:10:43-04:00 Fix and simplify DeriveAnyClass's context inference using SubTypePredSpec As explained in `Note [Gathering and simplifying constraints for DeriveAnyClass]` in `GHC.Tc.Deriv.Infer`, `DeriveAnyClass` infers instance contexts by emitting implication constraints. Previously, these implication constraints were constructed by hand. This is a terribly trick thing to get right, as it involves a delicate interplay of skolemisation, metavariable instantiation, and `TcLevel` bumping. Despite much effort, we discovered in #20719 that the implementation was subtly incorrect, leading to valid programs being rejected. While we could scrutinize the code that manually constructs implication constraints and repair it, there is a better, less error-prone way to do things. After all, the heart of `DeriveAnyClass` is generating code which fills in each class method with defaults, e.g., `foo = $gdm_foo`. Typechecking this sort of code is tantamount to calling `tcSubTypeSigma`, as we much ensure that the type of `$gdm_foo` is a subtype of (i.e., more polymorphic than) the type of `foo`. As an added bonus, `tcSubTypeSigma` is a battle-tested function that handles skolemisation, metvariable instantiation, `TcLevel` bumping, and all other means of tricky bookkeeping correctly. With this insight, the solution to the problems uncovered in #20719 is simple: use `tcSubTypeSigma` to check if `$gdm_foo`'s type is a subtype of `foo`'s type. As a side effect, `tcSubTypeSigma` will emit exactly the implication constraint that we were attempting to construct by hand previously. Moreover, it does so correctly, fixing #20719 as a consequence. This patch implements the solution thusly: * The `PredSpec` data type (previously named `PredOrigin`) is now split into `SimplePredSpec`, which directly stores a `PredType`, and `SubTypePredSpec`, which stores the actual and expected types in a subtype check. `SubTypePredSpec` is only used for `DeriveAnyClass`; all other deriving strategies use `SimplePredSpec`. * Because `tcSubTypeSigma` manages the finer details of type variable instantiation and constraint solving under the hood, there is no longer any need to delicately split apart the method type signatures in `inferConstraintsAnyclass`. This greatly simplifies the implementation of `inferConstraintsAnyclass` and obviates the need to store skolems, metavariables, or given constraints in a `ThetaSpec` (previously named `ThetaOrigin`). As a bonus, this means that `ThetaSpec` now simply becomes a synonym for a list of `PredSpec`s, which is conceptually much simpler than it was before. * In `simplifyDeriv`, each `SubTypePredSpec` results in a call to `tcSubTypeSigma`. This is only performed for its side effect of emitting an implication constraint, which is fed to the rest of the constraint solving machinery in `simplifyDeriv`. I have updated `Note [Gathering and simplifying constraints for DeriveAnyClass]` to explain this in more detail. To make the changes in `simplifyDeriv` more manageable, I also performed some auxiliary refactoring: * Previously, every iteration of `simplifyDeriv` was skolemising the type variables at the start, simplifying, and then performing a reverse substitution at the end to un-skolemise the type variables. This is not necessary, however, since we can just as well skolemise once at the beginning of the `deriving` pipeline and zonk the `TcTyVar`s after `simplifyDeriv` is finished. This patch does just that, having been made possible by prior work in !7613. I have updated `Note [Overlap and deriving]` in `GHC.Tc.Deriv.Infer` to explain this, and I have also left comments on the relevant data structures (e.g., `DerivEnv` and `DerivSpec`) to explain when things might be `TcTyVar`s or `TyVar`s. * All of the aforementioned cleanup allowed me to remove an ad hoc deriving-related in `checkImplicationInvariants`, as all of the skolems in a `tcSubTypeSigma`–produced implication constraint should now be `TcTyVar` at the time the implication is created. * Since `simplifyDeriv` now needs a `SkolemInfo` and `UserTypeCtxt`, I have added `ds_skol_info` and `ds_user_ctxt` fields to `DerivSpec` to store these. Similarly, I have also added a `denv_skol_info` field to `DerivEnv`, which ultimately gets used to initialize the `ds_skol_info` in a `DerivSpec`. Fixes #20719. - - - - - 21680fb0 by Sebastian Graf at 2022-03-24T06:11:19-04:00 WorkWrap: Handle partial FUN apps in `isRecDataCon` (#21265) Partial FUN apps like `(->) Bool` aren't detected by `splitFunTy_maybe`. A silly oversight that is easily fixed by replacing `splitFunTy_maybe` with a guard in the `splitTyConApp_maybe` case. But fortunately, Simon nudged me into rewriting the whole `isRecDataCon` function in a way that makes it much shorter and hence clearer which DataCons are actually considered as recursive. Fixes #21265. - - - - - a2937e2b by Matthew Pickering at 2022-03-24T17:13:22-04:00 Add test for T21035 This test checks that you are allowed to explicitly supply object files for dependencies even if you haven't got the shared object for that library yet. Fixes #21035 - - - - - 1756d547 by Matthew Pickering at 2022-03-24T17:13:58-04:00 Add check to ensure we are not building validate jobs for releases - - - - - 99623358 by Matthew Pickering at 2022-03-24T17:13:58-04:00 hadrian: Correct generation of hsc2hs wrapper If you inspect the inside of a wrapper script for hsc2hs you will see that the cflag and lflag values are concatenated incorrectly. ``` HSC2HS_EXTRA="--cflag=-U__i686--lflag=-fuse-ld=gold" ``` It should instead be ``` HSC2HS_EXTRA="--cflag=-U__i686 --lflag=-fuse-ld=gold" ``` Fixes #21221 - - - - - fefd4e31 by Matthew Pickering at 2022-03-24T17:13:59-04:00 testsuite: Remove library dependenices from T21119 These dependencies would affect the demand signature depending on various rules and so on. Fixes #21271 - - - - - 5ff690b8 by Matthew Pickering at 2022-03-24T17:13:59-04:00 ci: Generate jobs for all normal builds and use hadrian for all builds This commit introduces a new script (.gitlab/gen_ci.hs) which generates a yaml file (.gitlab/jobs.yaml) which contains explicit descriptions for all the jobs we want to run. The jobs are separated into three categories: * validate - jobs run on every MR * nightly - jobs run once per day on the master branch * release - jobs for producing release artifacts The generation script is a Haskell program which includes a DSL for specifying the different jobs. The hope is that it's easier to reason about the different jobs and how the variables are merged together rather than the unclear and opaque yaml syntax. The goal is to fix issues like #21190 once and for all.. The `.gitlab/jobs.yaml` can be generated by running the `.gitlab/generate_jobs` script. You have to do this manually. Another consequence of this patch is that we use hadrian for all the validate, nightly and release builds on all platforms. - - - - - 1d673aa2 by Christiaan Baaij at 2022-03-25T11:35:49-04:00 Add the OPAQUE pragma A new pragma, `OPAQUE`, that ensures that every call of a named function annotated with an `OPAQUE` pragma remains a call of that named function, not some name-mangled variant. Implements GHC proposal 0415: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0415-opaque-pragma.rst This commit also updates the haddock submodule to handle the newly introduced lexer tokens corresponding to the OPAQUE pragma. - - - - - 83f5841b by Bodigrim at 2022-03-25T11:36:31-04:00 Add instance Lift ByteArray - - - - - 7cc1184a by Matthew Pickering at 2022-03-25T11:37:07-04:00 Make -ddump-rn-ast and -ddump-tc-ast work in GHCi Fixes #17830 - - - - - 940feaf3 by Sylvain Henry at 2022-03-25T11:37:47-04:00 Modularize Tidy (#17957) - Factorize Tidy options into TidyOpts datatype. Initialize it in GHC.Driver.Config.Tidy - Same thing for StaticPtrOpts - Perform lookups of unpackCString[Utf8]# once in initStaticPtrOpts instead of for every use of mkStringExprWithFS - - - - - 25101813 by Takenobu Tani at 2022-03-28T01:16:02-04:00 users-guide: Correct markdown for profiling This patch corrects some markdown. [skip ci] - - - - - c832ae93 by Matthew Pickering at 2022-03-28T01:16:38-04:00 hadrian: Flag cabal flag handling This patch basically deletes some ad-hoc handling of Cabal Flags and replaces it with a correct query of the LocalBuildInfo. The flags in the local build info can be modified by users by passing hadrian options For example (!4331) ``` *.genapply.cabal.configure.opts += --flags=unregisterised ``` And all the flags specified by the `Cabal Flags` builder were already passed to configure properly using `--flags`. - - - - - a9f3a5c6 by Ben Gamari at 2022-03-28T01:16:38-04:00 Disable text's dependency on simdutf by default Unfortunately we are simply not currently in a good position to robustly ship binary distributions which link against C++ code like simdutf. Fixes #20724. - - - - - eff86e8a by Richard Eisenberg at 2022-03-28T01:17:14-04:00 Add Red Herring to Note [What might equal later?] Close #21208. - - - - - 12653be9 by jberryman at 2022-03-28T01:17:55-04:00 Document typed splices inhibiting unused bind detection (#16524) - - - - - 4aeade15 by Adam Sandberg Ericsson at 2022-03-28T01:18:31-04:00 users-guide: group ticky-ticky profiling under one heading - - - - - cc59648a by Sylvain Henry at 2022-03-28T01:19:12-04:00 Hadrian: allow testsuite to run with cross-compilers (#21292) - - - - - 89cb1315 by Matthew Pickering at 2022-03-28T01:19:48-04:00 hadrian: Add show target to bindist makefile Some build systems use "make show" to query facts about the bindist, for example: ``` make show VALUE=ProjectVersion > version ``` to determine the ProjectVersion - - - - - 8229885c by Alan Zimmerman at 2022-03-28T19:23:28-04:00 EPA: let stmt with semicolon has wrong anchor The code let ;x =1 Captures the semicolon annotation, but did not widen the anchor in the ValBinds. Fix that. Closes #20247 - - - - - 2c12627c by Ryan Scott at 2022-03-28T19:24:04-04:00 Consistently attach SrcSpans to sub-expressions in TH splices Before, `GHC.ThToHs` was very inconsistent about where various sub-expressions would get the same `SrcSpan` from the original TH splice location or just a generic `noLoc` `SrcSpan`. I have ripped out all uses of `noLoc` in favor of the former instead, and I have added a `Note [Source locations within TH splices]` to officially enshrine this design choice. Fixes #21299. - - - - - 789add55 by Zubin Duggal at 2022-03-29T13:07:22-04:00 Fix all invalid haddock comments in the compiler Fixes #20935 and #20924 - - - - - 967dad03 by Zubin Duggal at 2022-03-29T13:07:22-04:00 hadrian: Build lib:GHC with -haddock and -Winvalid-haddock (#21273) - - - - - ad09a5f7 by sheaf at 2022-03-29T13:08:05-04:00 Hadrian: make DDEBUG separate from debugged RTS This patchs separates whether -DDEBUG is enabled (i.e. whether debug assertions are enabled) from whether we are using the debugged RTS (i.e. GhcDebugged = YES). This means that we properly skip tests which have been marked with `when(compiler_debugged(), skip)`. Fixes #21113, #21153 and #21234 - - - - - 840a6811 by Matthew Pickering at 2022-03-29T13:08:42-04:00 RTS: Zero gc_cpu_start and gc_cpu_end after accounting When passed a combination of `-N` and `-qn` options the cpu time for garbage collection was being vastly overcounted because the counters were not being zeroed appropiately. When -qn1 is passed, only 1 of the N avaiable GC threads is chosen to perform work, the rest are idle. At the end of the GC period, stat_endGC traverses all the GC threads and adds up the elapsed time from each of them. For threads which didn't participate in this GC, the value of the cpu time should be zero, but before this patch, the counters were not zeroed and hence we would count the same elapsed time on many subsequent iterations (until the thread participated in a GC again). The most direct way to zero these fields is to do so immediately after the value is added into the global counter, after which point they are never used again. We also tried another approach where we would zero the counter in yieldCapability but there are some (undiagnosed) siations where a capbility would not pass through yieldCapability before the GC ended and the same double counting problem would occur. Fixes #21082 - - - - - dda46e2d by Matthew Pickering at 2022-03-29T13:09:18-04:00 Add test for T21306 Fixes #21306 - - - - - f07c7766 by Jakob Brünker at 2022-03-30T03:10:33-04:00 Give parsing plugins access to errors Previously, when the parser produced non-fatal errors (i.e. it produced errors but the 'PState' is 'POk'), compilation would be aborted before the 'parsedResultAction' of any plugin was invoked. This commit changes that, so that such that 'parsedResultAction' gets collections of warnings and errors as argument, and must return them after potentially modifying them. Closes #20803 - - - - - e5dfde75 by Ben Gamari at 2022-03-30T03:11:10-04:00 Fix reference to Note [FunBind vs PatBind] This Note was renamed in 2535a6716202253df74d8190b028f85cc6d21b72 yet this occurrence was not updated. - - - - - 21894a63 by Krzysztof Gogolewski at 2022-03-30T03:11:45-04:00 Refactor: make primtypes independent of PrimReps Previously, 'pcPrimTyCon', the function used to define a primitive type, was taking a PrimRep, only to convert it to a RuntimeRep. Now it takes a RuntimeRep directly. Moved primRepToRuntimeRep to GHC.Types.RepType. It is now located next to its inverse function runtimeRepPrimRep. Now GHC.Builtin.Types.Prim no longer mentions PrimRep, and GHC.Types.RepType no longer imports GHC.Builtin.Types.Prim. Removed unused functions `primRepsToRuntimeRep` and `mkTupleRep`. Removed Note [PrimRep and kindPrimRep] - it was never referenced, didn't belong to Types.Prim, and Note [Getting from RuntimeRep to PrimRep] is more comprehensive. - - - - - 43da2963 by Matthew Pickering at 2022-03-30T09:55:49+01:00 Fix mention of non-existent "rehydrateIface" function [skip ci] Fixes #21303 - - - - - 6793a20f by gershomb at 2022-04-01T10:33:46+01:00 Remove wrong claim about naturality law. This docs change removes a longstanding confusion in the Traversable docs. The docs say "(The naturality law is implied by parametricity and thus so is the purity law [1, p15].)". However if one reads the reference a different "natural" law is implied by parametricity. The naturality law given as a law here is imposed. Further, the reference gives examples which violate both laws -- so they cannot be implied by parametricity. This PR just removes the wrong claim. - - - - - 5beeff46 by Ben Gamari at 2022-04-01T10:34:39+01:00 Refactor handling of global initializers GHC uses global initializers for a number of things including cost-center registration, info-table provenance registration, and setup of foreign exports. Previously, the global initializer arrays which referenced these initializers would live in the object file of the C stub, which would then be merged into the main object file of the module. Unfortunately, this approach is no longer tenable with the move to Clang/LLVM on Windows (see #21019). Specifically, lld's PE backend does not support object merging (that is, the -r flag). Instead we are now rather packaging a module's object files into a static library. However, this is problematic in the case of initializers as there are no references to the C stub object in the archive, meaning that the linker may drop the object from the final link. This patch refactors our handling of global initializers to instead place initializer arrays within the object file of the module to which they belong. We do this by introducing a Cmm data declaration containing the initializer array in the module's Cmm stream. While the initializer functions themselves remain in separate C stub objects, the reference from the module's object ensures that they are not dropped from the final link. In service of #21068. - - - - - 3e6fe71b by Matthew Pickering at 2022-04-01T10:35:41+01:00 Fix remaining issues in eventlog types (gen_event_types.py) * The size of End concurrent mark phase looks wrong and, it used to be 4 and now it's 0. * The size of Task create is wrong, used to be 18 and now 14. * The event ticky-ticky entry counter begin sample has the wrong name * The event ticky-ticky entry counter being sample has the wrong size, was 0 now 32. Closes #21070 - - - - - 7847f47a by Ben Gamari at 2022-04-01T10:35:41+01:00 users-guide: Fix a few small issues in eventlog format descriptions The CONC_MARK_END event description didn't mention its payload. Clarify the meaning of the CREATE_TASK's payload. - - - - - acfd5a4c by Matthew Pickering at 2022-04-01T10:35:53+01:00 ci: Regenerate jobs.yaml It seems I forgot to update this to reflect the current state of gen_ci.hs - - - - - a952dd80 by Matthew Pickering at 2022-04-01T10:35:59+01:00 ci: Attempt to fix windows cache issues It appears that running the script directly does nothing (no info is printed about saving the cache). - - - - - fb65e6e3 by Adrian Ratiu at 2022-04-01T10:49:52+01:00 fp_prog_ar.m4: take AR var into consideration In ChromeOS and Gentoo we want the ability to use LLVM ar instead of GNU ar even though both are installed, thus we pass (for eg) AR=llvm-ar to configure. Unfortunately GNU ar always gets picked regardless of the AR setting because the check does not consider the AR var when setting fp_prog_ar, hence this fix. - - - - - 1daaefdf by Greg Steuck at 2022-04-01T10:50:16+01:00 T13366 requires c++ & c++abi libraries on OpenBSD Fixes this failure: =====> 1 of 1 [0, 0, 0] T13366(normal) 1 of 1 [0, 0, 0] Compile failed (exit code 1) errors were: <no location info>: error: user specified .o/.so/.DLL could not be loaded (File not found) Whilst trying to load: (dynamic) stdc++ Additional directories searched: (none) *** unexpected failure for T13366(normal) - - - - - 18e6c85b by Jakob Bruenker at 2022-04-01T10:54:28+01:00 new datatypes for parsedResultAction Previously, the warnings and errors were given and returned as a tuple (Messages PsWarnings, Messages PsErrors). Now, it's just PsMessages. This, together with the HsParsedModule the parser plugin gets and returns, has been wrapped up as ParsedResult. - - - - - 9727e592 by Morrow at 2022-04-01T10:55:12+01:00 Clarify that runghc interprets the input program - - - - - f589dea3 by sheaf at 2022-04-01T10:59:58+01:00 Unify RuntimeRep arguments in ty_co_match The `ty_co_match` function ignored the implicit RuntimeRep coercions that occur in a `FunCo`. Even though a comment explained that this should be fine, #21205 showed that it could result in discarding a RuntimeRep coercion, and thus discarding an important cast entirely. With this patch, we first match the kinds in `ty_co_match`. Fixes #21205 ------------------------- Metric Increase: T12227 T18223 ------------------------- - - - - - 6f4dc372 by Andreas Klebinger at 2022-04-01T11:01:35+01:00 Export MutableByteArray from Data.Array.Byte This implements CLC proposal #49 - - - - - 5df9f5e7 by ARATA Mizuki at 2022-04-01T11:02:35+01:00 Add test cases for #20640 Closes #20640 - - - - - 8334ff9e by Krzysztof Gogolewski at 2022-04-01T11:03:16+01:00 Minor cleanup - Remove unused functions exprToCoercion_maybe, applyTypeToArg, typeMonoPrimRep_maybe, runtimeRepMonoPrimRep_maybe. - Replace orValid with a simpler check - Use splitAtList in applyTysX - Remove calls to extra_clean in the testsuite; it does not do anything. Metric Decrease: T18223 - - - - - b2785cfc by Eric Lindblad at 2022-04-01T11:04:07+01:00 hadrian typos - - - - - 418e6fab by Eric Lindblad at 2022-04-01T11:04:12+01:00 two typos - - - - - dd7c7c99 by Phil de Joux at 2022-04-01T11:04:56+01:00 Add tests and docs on plugin args and order. - - - - - 3e209a62 by MaxHearnden at 2022-04-01T11:05:19+01:00 Change may not to might not - - - - - b84380d3 by Matthew Pickering at 2022-04-01T11:07:27+01:00 hadrian: Remove linters-common from bindist Zubin observed that the bindists contains the utility library linters-common. There are two options: 1. Make sure only the right files are added into the bindist.. a bit tricky due to the non-trivial structure of the lib directory. 2. Remove the bad files once they get copied in.. a bit easier So I went for option 2 but we perhaps should go for option 1 in the future. Fixes #21203 - - - - - ba9904c1 by Zubin Duggal at 2022-04-01T11:07:31+01:00 hadrian: allow testing linters with out of tree compilers - - - - - 26547759 by Matthew Pickering at 2022-04-01T11:07:35+01:00 hadrian: Introduce CheckProgram datatype to replace a 7-tuple - - - - - df65d732 by Jakob Bruenker at 2022-04-01T11:08:28+01:00 Fix panic when pretty printing HsCmdLam When pretty printing a HsCmdLam with more than one argument, GHC panicked because of a missing case. This fixes that. Closes #21300 - - - - - ad6cd165 by John Ericson at 2022-04-01T11:10:06+01:00 hadrian: Remove vestigial -this-unit-id support check This has been dead code since 400ead81e80f66ad7b1260b11b2a92f25ccc3e5a. - - - - - 8ca7ab81 by Matthew Pickering at 2022-04-01T11:10:23+01:00 hadrian: Fix race involving empty package databases There was a small chance of a race occuring between the small window of 1. The first package (.conf) file get written into the database 2. hadrian calling "ghc-pkg recache" to refresh the package.conf file In this window the package database would contain rts.conf but not a package.cache file, and therefore if ghc was invoked it would error because it was missing. To solve this we call "ghc-pkg recache" at when the database is created by shake by writing the stamp file into the database folder. This also creates the package.cache file and so avoids the possibility of this race. - - - - - cc4ec64b by Matthew Pickering at 2022-04-01T11:11:05+01:00 hadrian: Add assertion that in/out tree args are the same There have been a few instances where this calculation was incorrect, so we add a non-terminal assertion when now checks they the two computations indeed compute the same thing. Fixes #21285 - - - - - 691508d8 by Matthew Pickering at 2022-04-01T11:13:10+01:00 hlint: Ignore suggestions in generated HaddockLex file With the make build system this file ends up in the compiler/ subdirectory so is linted. With hadrian, the file ends up in _build so it's not linted. Fixes #21313 - - - - - f8f152e7 by Krzysztof Gogolewski at 2022-04-01T11:14:08+01:00 Change GHC.Prim to GHC.Exts in docs and tests Users are supposed to import GHC.Exts rather than GHC.Prim. Part of #18749. - - - - - f8fc6d2e by Matthew Pickering at 2022-04-01T11:15:24+01:00 driver: Improve -Wunused-packages error message (and simplify implementation) In the past I improved the part of -Wunused-packages which found which packages were used. Now I improve the part which detects which ones were specified. The key innovation is to use the explicitUnits field from UnitState which has the result of resolving the package flags, so we don't need to mess about with the flag arguments from DynFlags anymore. The output now always includes the package name and version (and the flag which exposed it). ``` The following packages were specified via -package or -package-id flags, but were not needed for compilation: - bytestring-0.11.2.0 (exposed by flag -package bytestring) - ghc-9.3 (exposed by flag -package ghc) - process-1.6.13.2 (exposed by flag -package process) ``` Fixes #21307 - - - - - 5e5a12d9 by Matthew Pickering at 2022-04-01T11:15:32+01:00 driver: In oneshot mode, look for interface files in hidir How things should work: * -i is the search path for source files * -hidir explicitly sets the search path for interface files and the output location for interface files. * -odir sets the search path and output location for object files. Before in one shot mode we would look for the interface file in the search locations given by `-i`, but then set the path to be in the `hidir`, so in unusual situations the finder could find an interface file in the `-i` dir but later fail because it tried to read the interface file from the `-hidir`. A bug identified by #20569 - - - - - 950f58e7 by Matthew Pickering at 2022-04-01T11:15:36+01:00 docs: Update documentation interaction of search path, -hidir and -c mode. As noted in #20569 the documentation for search path was wrong because it seemed to indicate that `-i` dirs were important when looking for interface files in `-c` mode, but they are not important if `-hidir` is set. Fixes #20569 - - - - - d85c7dcb by sheaf at 2022-04-01T11:17:56+01:00 Keep track of promotion ticks in HsOpTy This patch adds a PromotionFlag field to HsOpTy, which is used in pretty-printing and when determining whether to emit warnings with -fwarn-unticked-promoted-constructors. This allows us to correctly report tick-related warnings for things like: type A = Int : '[] type B = [Int, Bool] Updates haddock submodule Fixes #19984 - - - - - 32070e6c by Jakob Bruenker at 2022-04-01T20:31:08+02:00 Implement \cases (Proposal 302) This commit implements proposal 302: \cases - Multi-way lambda expressions. This adds a new expression heralded by \cases, which works exactly like \case, but can match multiple apats instead of a single pat. Updates submodule haddock to support the ITlcases token. Closes #20768 - - - - - c6f77f39 by sheaf at 2022-04-01T20:33:05+02:00 Add a regression test for #21323 This bug was fixed at some point between GHC 9.0 and GHC 9.2; this patch simply adds a regression test. - - - - - 3596684e by Jakob Bruenker at 2022-04-01T20:33:05+02:00 Fix error when using empty case in arrow notation It was previously not possible to use -XEmptyCase in Arrow notation, since GHC would print "Exception: foldb of empty list". This is now fixed. Closes #21301 - - - - - 9a325b59 by Ben Gamari at 2022-04-01T20:33:05+02:00 users-guide: Fix various markup issues - - - - - aefb1e6d by sheaf at 2022-04-01T20:36:01+02:00 Ensure implicit parameters are lifted `tcExpr` typechecked implicit parameters by introducing a metavariable of kind `TYPE kappa`, without enforcing that `kappa ~ LiftedRep`. This patch instead creates a metavariable of kind `Type`. Fixes #21327 - - - - - ed62dc66 by Ben Gamari at 2022-04-05T11:44:51-04:00 gitlab-ci: Disable cabal-install store caching on Windows For reasons that remain a mystery, cabal-install seems to consistently corrupt its cache on Windows. Disable caching for now. Works around #21347. - - - - - 5ece5c5a by Ryan Scott at 2022-04-06T13:00:51-04:00 Add /linters/*/dist-install/ to .gitignore Fixes #21335. [ci skip] - - - - - 410c76ee by Ben Gamari at 2022-04-06T13:01:28-04:00 Use static archives as an alternative to object merging Unfortunately, `lld`'s COFF backend does not currently support object merging. With ld.bfd having broken support for high image-load base addresses, it's necessary to find an alternative. Here I introduce support in the driver for generating static archives, which we use on Windows instead of object merging. Closes #21068. - - - - - 400666c8 by Ben Gamari at 2022-04-06T13:01:28-04:00 rts/linker: Catch archives masquerading as object files Check the file's header to catch static archive bearing the `.o` extension, as may happen on Windows after the Clang refactoring. See #21068 - - - - - 694d39f0 by Ben Gamari at 2022-04-06T13:01:28-04:00 driver: Make object merging optional On Windows we don't have a linker which supports object joining (i.e. the `-r` flag). Consequently, `-pgmlm` is now a `Maybe`. See #21068. - - - - - 41fcb5cd by Ben Gamari at 2022-04-06T13:01:28-04:00 hadrian: Refactor handling of ar flags Previously the setup was quite fragile as it had to assume which arguments were file arguments and which were flags. - - - - - 3ac80a86 by Ben Gamari at 2022-04-06T13:01:28-04:00 hadrian: Produce ar archives with L modifier on Windows Since object files may in fact be archive files, we must ensure that their contents are merged rather than constructing an archive-of-an-archive. See #21068. - - - - - 295c35c5 by Ben Gamari at 2022-04-06T13:01:28-04:00 Add a Note describing lack of object merging on Windows See #21068. - - - - - d2ae0a3a by Ben Gamari at 2022-04-06T13:01:28-04:00 Build ar archives with -L when "joining" objects Since there may be .o files which are in fact archives. - - - - - babb47d2 by Zubin Duggal at 2022-04-06T13:02:04-04:00 Add warnings for file header pragmas that appear in the body of a module (#20385) Once we are done parsing the header of a module to obtain the options, we look through the rest of the tokens in order to determine if they contain any misplaced file header pragmas that would usually be ignored, potentially resulting in bad error messages. The warnings are reported immediately so that later errors don't shadow over potentially helpful warnings. Metric Increase: T13719 - - - - - 3f31825b by Ben Gamari at 2022-04-06T13:02:40-04:00 rts/AdjustorPool: Generalize to allow arbitrary contexts Unfortunately the i386 adjustor logic needs this. - - - - - 9b645ee1 by Ben Gamari at 2022-04-06T13:02:40-04:00 adjustors/i386: Use AdjustorPool In !7511 (closed) I introduced a new allocator for adjustors, AdjustorPool, which eliminates the address space fragmentation issues which adjustors can introduce. In that work I focused on amd64 since that was the platform where I observed issues. However, in #21132 we noted that the size of adjustors is also a cause of CI fragility on i386. In this MR I port i386 to use AdjustorPool. Sadly the complexity of the i386 adjustor code does cause require a bit of generalization which makes the code a bit more opaque but such is the world. Closes #21132. - - - - - c657a616 by Ben Gamari at 2022-04-06T13:03:16-04:00 hadrian: Clean up flavour transformer definitions Previously the `ipe` and `omit_pragmas` transformers were hackily defined using the textual key-value syntax. Fix this. - - - - - 9ce273b9 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab-ci: Drop dead HACKAGE_INDEX_STATE variable - - - - - 01845375 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab/darwin: Factor out bindists This makes it a bit easier to bump them. - - - - - c41c478e by Ben Gamari at 2022-04-06T13:03:16-04:00 Fix a few new warnings when booting with GHC 9.2.2 -Wuni-incomplete-patterns and apparent improvements in the pattern match checker surfaced these. - - - - - 6563cd24 by Ben Gamari at 2022-04-06T13:03:16-04:00 gitlab-ci: Bump bootstrap compiler to 9.2.2 This is necessary to build recent `text` commits. Bumps Hackage index state for a hashable which builds with GHC 9.2. - - - - - a62e983e by Ben Gamari at 2022-04-06T13:03:16-04:00 Bump text submodule to current `master` Addresses #21295. - - - - - 88d61031 by Vladislav Zavialov at 2022-04-06T13:03:53-04:00 Refactor OutputableBndrFlag instances The matching on GhcPass introduced by 95275a5f25a is not necessary. This patch reverts it to make the code simpler. - - - - - f601f002 by GHC GitLab CI at 2022-04-06T15:18:26-04:00 rts: Eliminate use of nested functions This is a gcc-specific extension. - - - - - d4c5f29c by Ben Gamari at 2022-04-06T15:18:26-04:00 driver: Drop hacks surrounding windres invocation Drop hack for #1828, among others as they appear to be unnecessary when using `llvm-windres`. - - - - - 6be2c5a7 by Ben Gamari at 2022-04-06T15:18:26-04:00 Windows/Clang: Build system adaptation * Bump win32-tarballs to 0.7 * Move Windows toolchain autoconf logic into separate file * Use clang and LLVM utilities as described in #21019 * Disable object merging as lld doesn't support -r * Drop --oformat=pe-bigobj-x86-64 arguments from ld flags as LLD detects that the output is large on its own. * Drop gcc wrapper since Clang finds its root fine on its own. - - - - - c6fb7aff by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Test that we can build bigobj PE objects - - - - - 79851c07 by Ben Gamari at 2022-04-06T15:18:26-04:00 Drop -static-libgcc This flag is not applicable when Clang is used. - - - - - 1f8a8264 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Port T16514 to C Previously this test was C++ which made it a bit of a portability problem. - - - - - d7e650d1 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark Windows as a libc++ platform - - - - - d7886c46 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark T9405 as fixed on Windows I have not seen it fail since moving to clang. Closes #12714. - - - - - 4c3fbb4e by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark FloatFnInverses as fixed The new toolchain has fixed it. Closes #15670. - - - - - 402c36ba by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Rework T13606 to avoid gcc dependence Previously we used libgcc_s's import library in T13606. However, now that we ship with clang we no longer have this library. Instead we now use gdi32. - - - - - 9934ad54 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Clean up tests depending on C++ std lib - - - - - 12fcdef2 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Split T13366 into two tests Split up the C and C++ uses since the latter is significantly more platform-dependent. - - - - - 3c08a198 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Fix mk-big-obj I'm a bit unclear on how this previously worked as it attempted to build an executable without defining `main`. - - - - - 7e97cc23 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Provide module definitions in T10955dyn Otherwise the linker will export all symbols, including those provided by the RTS, from the produced shared object. Consequently, attempting to link against multiple objects simultaneously will cause the linker to complain that RTS symbols are multiply defined. Avoid this by limiting the DLL exports with a module definition file. - - - - - 9a248afa by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite: Mark test-defaulting-plugin as fragile on Windows Currently llvm-ar does not handle long file paths, resulting in occassional failures of these tests and #21293. - - - - - 39371aa4 by Ben Gamari at 2022-04-06T15:18:26-04:00 testsuite/driver: Treat framework failures of fragile tests as non-fatal Previously we would report framework failures of tests marked as fragile as failures. Now we rather treat them as fragile test failures, which are not fatal to the testsuite run. Noticed while investigating #21293. - - - - - a1e6661d by Ben Gamari at 2022-04-06T15:18:32-04:00 Bump Cabal submodule - Disable support for library-for-ghci on Windows as described in #21068. - Teach Cabal to use `ar -L` when available - - - - - f7b0f63c by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump process submodule Fixes missing TEST_CC_OPTS in testsuite tests. - - - - - 109cee19 by Ben Gamari at 2022-04-06T15:18:37-04:00 hadrian: Disable ghci libraries when object merging is not available - - - - - c22fba5c by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump bytestring submodule - - - - - 6e2744cc by Ben Gamari at 2022-04-06T15:18:37-04:00 Bump text submodule - - - - - 32333747 by Ben Gamari at 2022-04-06T15:18:37-04:00 hadrian: Build wrappers using ghc rather than cc - - - - - 59787ba5 by Ben Gamari at 2022-04-06T15:18:37-04:00 linker/PEi386: More descriptive error message - - - - - 5e3c3c4f by Ben Gamari at 2022-04-06T15:18:37-04:00 testsuite: Mark TH_spliceE5_prof as unbroken on Windows It was previously failing due to #18721 and now passes with the new toolchain. Closes #18721. - - - - - 9eb0a9d9 by GHC GitLab CI at 2022-04-06T15:23:48-04:00 rts/PEi386: Move some debugging output to -DL - - - - - ce874595 by Ben Gamari at 2022-04-06T15:24:01-04:00 nativeGen/x86: Use %rip-relative addressing On Windows with high-entropy ASLR we must use %rip-relative addressing to avoid overflowing the signed 32-bit immediate size of x86-64. Since %rip-relative addressing comes essentially for free and can make linking significantly easier, we use it on all platforms. - - - - - 52deee64 by Ben Gamari at 2022-04-06T15:24:01-04:00 Generate LEA for label expressions - - - - - 105a0056 by Ben Gamari at 2022-04-06T15:24:01-04:00 Refactor is32BitLit to take Platform rather than Bool - - - - - ec4526b5 by Ben Gamari at 2022-04-06T15:24:01-04:00 Don't assume that labels are 32-bit on Windows - - - - - ffdbe457 by Ben Gamari at 2022-04-06T15:24:01-04:00 nativeGen: Note signed-extended nature of MOV - - - - - bfb79697 by Ben Gamari at 2022-04-06T15:30:56-04:00 rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h It's easier to ensure that this is included first than Rts.h - - - - - 5ad143fd by Ben Gamari at 2022-04-06T15:30:56-04:00 rts: Fix various #include issues This fixes various violations of the newly-added RTS includes linter. - - - - - a59a66a8 by Ben Gamari at 2022-04-06T15:30:56-04:00 testsuite: Lint RTS #includes Verifies two important properties of #includes in the RTS: * That system headers don't appear inside of a `<BeginPrivate.h>` block as this can hide system library symbols, resulting in very hard-to-diagnose linker errors * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO is set correctly before system headers are included. - - - - - 42bf7528 by GHC GitLab CI at 2022-04-06T16:25:04-04:00 rts/PEi386: Fix memory leak Previously we would leak the section information of the `.bss` section. - - - - - d286a55c by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Preserve information about symbol types As noted in #20978, the linker would previously handle overflowed relocations by creating a jump island. While this is fine in the case of code symbols, it's very much not okay in the case of data symbols. To fix this we must keep track of whether each symbol is code or data and relocate them appropriately. This patch takes the first step in this direction, adding a symbol type field to the linker's symbol table. It doesn't yet change relocation behavior to take advantage of this knowledge. Fixes #20978. - - - - - e689e9d5 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Fix relocation overflow behavior This fixes handling of overflowed relocations on PEi386 targets: * Refuse to create jump islands for relocations of data symbols * Correctly handle the `__imp___acrt_iob_func` symbol, which is an new type of symbol: `SYM_TYPE_INDIRECT_DATA` - - - - - 655e7d8f by GHC GitLab CI at 2022-04-06T16:25:25-04:00 rts: Mark anything that might have an info table as data Tables-next-to-code mandates that we treat symbols with info tables like data since we cannot relocate them using a jump island. See #20983. - - - - - 7e8cc293 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Rework linker This is a significant rework of the PEi386 linker, making the linker compatible with high image base addresses. Specifically, we now use the m32 allocator instead of `HeapAllocate`. In addition I found a number of latent bugs in our handling of import libraries and relocations. I've added quite a few comments describing what I've learned about Windows import libraries while fixing these. Thanks to Tamar Christina (@Phyx) for providing the address space search logic, countless hours of help while debugging, and his boundless Windows knowledge. Co-Authored-By: Tamar Christina <tamar at zhox.com> - - - - - ff625218 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Move allocateBytes to MMap.c - - - - - f562b5ca by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PEi386: Avoid accidentally-quadratic allocation cost We now preserve the address that we last mapped, allowing us to resume our search and avoiding quadratic allocation costs. This fixes the runtime of T10296a, which allocates many adjustors. - - - - - 3247b7db by Ben Gamari at 2022-04-06T16:25:25-04:00 Move msvcrt dep out of base - - - - - fa404335 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: More descriptive debug output - - - - - 140f338f by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/PathUtils: Define pathprintf in terms of snwprintf on Windows swprintf deviates from usual `snprintf` semantics in that it does not guarantee reasonable behavior when the buffer is NULL (that is, returning the number of bytes that would have been emitted). - - - - - eb60565b by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Report archive member index - - - - - 209fd61b by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker: Split up object resolution and initialization Previously the RTS linker would call initializers during the "resolve" phase of linking. However, this is problematic in the case of cyclic dependencies between objects. In particular, consider the case where we have a situation where a static library contains a set of recursive objects: * object A has depends upon symbols in object B * object B has an initializer that depends upon object A * we try to load object A The linker would previously: 1. start resolving object A 2. encounter the reference to object B, loading it resolve object B 3. run object B's initializer 4. the initializer will attempt to call into object A, which hasn't been fully resolved (and therefore protected) Fix this by moving constructor execution to a new linking phase, which follows resolution. Fix #21253. - - - - - 8e8a1021 by Ben Gamari at 2022-04-06T16:25:25-04:00 rts/linker/LoadArchive: Fix leaking file handle Previously `isArchive` could leak a `FILE` handle if the `fread` returned a short read. - - - - - 429ea5d9 by sheaf at 2022-04-07T07:55:52-04:00 Remove Fun pattern from Typeable COMPLETE set GHC merge request !963 improved warnings in the presence of COMPLETE annotations. This allows the removal of the Fun pattern from the complete set. Doing so expectedly causes some redundant pattern match warnings, in particular in GHC.Utils.Binary.Typeable and Data.Binary.Class from the binary library; this commit addresses that. Updates binary submodule Fixes #20230 - - - - - 54b18824 by Alan Zimmerman at 2022-04-07T07:56:28-04:00 EPA: handling of con_bndrs in mkGadtDecl Get rid of unnnecessary case clause that always matched. Closes #20558 - - - - - 9c838429 by Ben Gamari at 2022-04-07T09:38:53-04:00 testsuite: Mark T10420 as broken on Windows Due to #21322. - - - - - 50739d2b by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Refactor and fix printf attributes on clang Clang on Windows does not understand the `gnu_printf` attribute; use `printf` instead. - - - - - 9eeaeca4 by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Add missing newline in error message - - - - - fcef9a17 by Ben Gamari at 2022-04-07T09:42:42-04:00 configure: Make environ decl check more robust Some platforms (e.g. Windows/clang64) declare `environ` in `<stdlib.h>`, not `<unistd.h>` - - - - - 8162b4f3 by Ben Gamari at 2022-04-07T09:42:42-04:00 rts: Adjust RTS symbol table on Windows for ucrt - - - - - 633280d7 by Ben Gamari at 2022-04-07T09:43:21-04:00 testsuite: Fix exit code of bounds checking tests on Windows `abort` exits with 255, not 134, on Windows. - - - - - cab4dc01 by Ben Gamari at 2022-04-07T09:43:31-04:00 testsuite: Update expected output from T5435 tests on Windows I'll admit, I don't currently see *why* this output is reordered but it is a fairly benign difference and I'm out of time to investigate. - - - - - edf5134e by Ben Gamari at 2022-04-07T09:43:35-04:00 testsuite: Mark T20918 as broken on Windows Our toolchain on Windows doesn't currently have Windows support. - - - - - d0ddeff3 by Ben Gamari at 2022-04-07T09:43:39-04:00 testsuite: Mark linker unloading tests as broken on Windows Due to #20354. We will need to investigate this prior the release. - - - - - 5a86da2b by Ben Gamari at 2022-04-07T09:43:43-04:00 testsuite: Mark T9405 as broken on Windows Due to #21361. - - - - - 4aa86dcf by Ben Gamari at 2022-04-07T09:44:18-04:00 Merge branches 'wip/windows-high-codegen', 'wip/windows-high-linker', 'wip/windows-clang-2' and 'wip/lint-rts-includes' into wip/windows-clang-join - - - - - 7206f055 by Ben Gamari at 2022-04-07T09:45:07-04:00 rts/CloneStack: Ensure that Rts.h is #included first As is necessary on Windows. - - - - - 9cfcb27b by Ben Gamari at 2022-04-07T09:45:07-04:00 rts: Fallback to ucrtbase not msvcrt Since we have switched to Clang the toolchain now links against ucrt rather than msvcrt. - - - - - d6665d85 by Ben Gamari at 2022-04-07T09:46:25-04:00 Accept spurious perf test shifts on Windows Metric Decrease: T16875 Metric Increase: T12707 T13379 T3294 T4801 T5321FD T5321Fun T783 - - - - - 83363c8b by Simon Peyton Jones at 2022-04-07T12:57:21-04:00 Use prepareBinding in tryCastWorkerWrapper As #21144 showed, tryCastWorkerWrapper was calling prepareRhs, and then unconditionally floating the bindings, without the checks of doFloatFromRhs. That led to floating an unlifted binding into a Rec group. This patch refactors prepareBinding to make these checks, and do them uniformly across all calls. A nice improvement. Other changes * Instead of passing around a RecFlag and a TopLevelFlag; and sometimes a (Maybe SimplCont) for join points, define a new Simplifier-specific data type BindContext: data BindContext = BC_Let TopLevelFlag RecFlag | BC_Join SimplCont and use it consistently. * Kill off completeNonRecX by inlining it. It was only called in one place. * Add a wrapper simplImpRules for simplRules. Compile time on T9630 drops by 4.7%; little else changes. Metric Decrease: T9630 - - - - - 02279a9c by Vladislav Zavialov at 2022-04-07T12:57:59-04:00 Rename [] to List (#21294) This patch implements a small part of GHC Proposal #475. The key change is in GHC.Types: - data [] a = [] | a : [a] + data List a = [] | a : List a And the rest of the patch makes sure that List is pretty-printed as [] in various contexts. Updates the haddock submodule. - - - - - 08480d2a by Simon Peyton Jones at 2022-04-07T12:58:36-04:00 Fix the free-var test in validDerivPred The free-var test (now documented as (VD3)) was too narrow, affecting only class predicates. #21302 demonstrated that this wasn't enough! Fixes #21302. Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com> - - - - - b3d6d23d by Andreas Klebinger at 2022-04-07T12:59:12-04:00 Properly explain where INLINE pragmas can appear. Fixes #20676 - - - - - 23ef62b3 by Ben Gamari at 2022-04-07T14:28:28-04:00 rts: Fix off-by-one in snwprintf usage - - - - - b2dbcc7d by Simon Jakobi at 2022-04-08T03:00:38-04:00 Improve seq[D]VarSet Previously, the use of size[D]VarSet would involve a traversal of the entire underlying IntMap. Since IntMaps are already spine-strict, this is unnecessary. - - - - - 64ac20a7 by sheaf at 2022-04-08T03:01:16-04:00 Add test for #21338 This no-skolem-info bug was fixed by the no-skolem-info patch that will be part of GHC 9.4. This patch adds a regression test for the issue reported in issue #21338. Fixes #21338. - - - - - c32c4db6 by Ben Gamari at 2022-04-08T03:01:53-04:00 rts: Move __USE_MINGW_ANSI_STDIO definition to PosixSource.h It's easier to ensure that this is included first than Rts.h - - - - - 56f85d62 by Ben Gamari at 2022-04-08T03:01:53-04:00 rts: Fix various #include issues This fixes various violations of the newly-added RTS includes linter. - - - - - cb1f31f5 by Ben Gamari at 2022-04-08T03:01:53-04:00 testsuite: Lint RTS #includes Verifies two important properties of #includes in the RTS: * That system headers don't appear inside of a `<BeginPrivate.h>` block as this can hide system library symbols, resulting in very hard-to-diagnose linker errors * That no headers precede `Rts.h`, ensuring that __USE_MINGW_ANSI_STDIO is set correctly before system headers are included. - - - - - c44432db by Krzysztof Gogolewski at 2022-04-08T03:02:29-04:00 Fixes to 9.4 release notes - Mention -Wforall-identifier - Improve description of withDict - Fix formatting - - - - - 777365f1 by sheaf at 2022-04-08T09:43:35-04:00 Correctly report SrcLoc of redundant constraints We were accidentally dropping the source location information in certain circumstances when reporting redundant constraints. This patch makes sure that we set the TcLclEnv correctly before reporting the warning. Fixes #21315 - - - - - af300a43 by Vladislav Zavialov at 2022-04-08T09:44:11-04:00 Reject illegal quote mark in data con declarations (#17865) * Non-fatal (i.e. recoverable) parse error * Checking infix constructors * Extended the regression test - - - - - 56254e6b by Ben Gamari at 2022-04-08T09:59:46-04:00 Merge remote-tracking branch 'origin/master' - - - - - 6e2c3b7c by Matthew Pickering at 2022-04-08T13:55:15-04:00 driver: Introduce HomeModInfoCache abstraction The HomeModInfoCache is a mutable cache which is updated incrementally as the driver completes, this makes it robust to exceptions including (SIGINT) The interface for the cache is described by the `HomeMOdInfoCache` data type: ``` data HomeModInfoCache = HomeModInfoCache { hmi_clearCache :: IO [HomeModInfo] , hmi_addToCache :: HomeModInfo -> IO () } ``` The first operation clears the cache and returns its contents. This is designed so it's harder to end up in situations where the cache is retained throughout the execution of upsweep. The second operation allows a module to be added to the cache. The one slightly nasty part is in `interpretBuildPlan` where we have to be careful to ensure that the cache writes happen: 1. In parralel 2. Before the executation continues after upsweep. This requires some simple, localised MVar wrangling. Fixes #20780 - - - - - 85f4a3c9 by Andreas Klebinger at 2022-04-08T13:55:50-04:00 Add flag -fprof-manual which controls if GHC should honour manual cost centres. This allows disabling of manual control centres in code a user doesn't control like libraries. Fixes #18867 - - - - - 3415981c by Vladislav Zavialov at 2022-04-08T13:56:27-04:00 HsUniToken for :: in GADT constructors (#19623) One more step towards the new design of EPA. Updates the haddock submodule. - - - - - 23f95735 by sheaf at 2022-04-08T13:57:07-04:00 Docs: datacon eta-expansion, rep-poly checks The existing notes weren't very clear on how the eta-expansion of data constructors that occurs in tcInferDataCon/dsConLike interacts with the representation polymorphism invariants. So we explain with a few more details how we ensure that the representation-polymorphic lambdas introduced by tcInferDataCon/dsConLike don't end up causing problems, by checking they are properly instantiated and then relying on the simple optimiser to perform beta reduction. A few additional changes: - ConLikeTc just take type variables instead of binders, as we never actually used the binders. - Removed the FRRApp constructor of FRROrigin; it was no longer used now that we use ExpectedFunTyOrigin. - Adds a bit of documentation to the constructors of ExpectedFunTyOrigin. - - - - - d4480490 by Matthew Pickering at 2022-04-08T13:57:43-04:00 ci: Replace "always" with "on_success" to stop build jobs running before hadrian-ghci has finished See https://docs.gitlab.com/ee/ci/yaml/#when * always means, always run not matter what * on_success means, run if the dependencies have built successfully - - - - - 0736e949 by Vladislav Zavialov at 2022-04-08T13:58:19-04:00 Disallow (->) as a data constructor name (#16999) The code was misusing isLexCon, which was never meant for validation. In fact, its documentation states the following: Use these functions to figure what kind of name a 'FastString' represents; these functions do /not/ check that the identifier is valid. Ha! This sign can't stop me because I can't read. The fix is to use okConOcc instead. The other checks (isTcOcc or isDataOcc) seem superfluous, so I also removed those. - - - - - e58d5eeb by Simon Peyton Jones at 2022-04-08T13:58:55-04:00 Tiny documentation wibble This commit commit 83363c8b04837ee871a304cf85207cf79b299fb0 Author: Simon Peyton Jones <simon.peytonjones at gmail.com> Date: Fri Mar 11 16:55:38 2022 +0000 Use prepareBinding in tryCastWorkerWrapper refactored completeNonRecX away, but left a Note referring to it. This MR fixes that Note. - - - - - 4bb00839 by Matthew Pickering at 2022-04-09T07:40:28-04:00 ci: Fix nightly head.hackage pipelines This also needs a corresponding commit to head.hackage, I also made the job explicitly depend on the fedora33 job so that it isn't blocked by a failing windows job, which causes docs-tarball to fail. - - - - - 3c48e12a by Matthew Pickering at 2022-04-09T07:40:28-04:00 ci: Remove doc-tarball dependency from perf and perf-nofib jobs These don't depend on the contents of the tarball so we can run them straight after the fedora33 job finishes. - - - - - 27362265 by Matthew Pickering at 2022-04-09T07:41:04-04:00 Bump deepseq to 1.4.7.0 Updates deepseq submodule Fixes #20653 - - - - - dcf30da8 by Joachim Breitner at 2022-04-09T13:02:19-04:00 Drop the app invariant previously, GHC had the "let/app-invariant" which said that the RHS of a let or the argument of an application must be of lifted type or ok for speculation. We want this on let to freely float them around, and we wanted that on app to freely convert between the two (e.g. in beta-reduction or inlining). However, the app invariant meant that simple code didn't stay simple and this got in the way of rules matching. By removing the app invariant, this thus fixes #20554. The new invariant is now called "let-can-float invariant", which is hopefully easier to guess its meaning correctly. Dropping the app invariant means that everywhere where we effectively do beta-reduction (in the two simplifiers, but also in `exprIsConApp_maybe` and other innocent looking places) we now have to check if the argument must be evaluated (unlifted and side-effecting), and analyses have to be adjusted to the new semantics of `App`. Also, `LetFloats` in the simplifier can now also carry such non-floating bindings. The fix for DmdAnal, refine by Sebastian, makes functions with unlifted arguments strict in these arguments, which changes some signatures. This causes some extra calls to `exprType` and `exprOkForSpeculation`, so some perf benchmarks regress a bit (while others improve). Metric Decrease: T9020 Metric Increase: LargeRecord T12545 T15164 T16577 T18223 T5642 T9961 Co-authored-by: Sebastian Graf <sebastian.graf at kit.edu> - - - - - 6c6c5379 by Philip Hazelden at 2022-04-09T13:02:59-04:00 Add functions traceWith, traceShowWith, traceEventWith. As discussed at https://github.com/haskell/core-libraries-committee/issues/36 - - - - - 8fafacf7 by Philip Hazelden at 2022-04-09T13:02:59-04:00 Add tests for several trace functions. - - - - - 20bbf3ac by Philip Hazelden at 2022-04-09T13:02:59-04:00 Update changelog. - - - - - 47d18b0b by Andreas Klebinger at 2022-04-09T13:03:35-04:00 Add regression test for #19569 - - - - - 5f8d6e65 by sheaf at 2022-04-09T13:04:14-04:00 Fix missing SymCo in pushCoercionIntoLambda There was a missing SymCo in pushCoercionIntoLambda. Currently this codepath is only used with rewrite rules, so this bug managed to slip by, but trying to use pushCoercionIntoLambda in other contexts revealed the bug. - - - - - 20eca489 by Vladislav Zavialov at 2022-04-09T13:04:50-04:00 Refactor: simplify lexing of the dot Before this patch, the lexer did a truly roundabout thing with the dot: 1. look up the varsym in reservedSymsFM and turn it into ITdot 2. under OverloadedRecordDot, turn it into ITvarsym 3. in varsym_(prefix|suffix|...) turn it into ITvarsym, ITdot, or ITproj, depending on extensions and whitespace Turns out, the last step is sufficient to handle the dot correctly. This patch removes the first two steps. - - - - - 5440f63e by Hécate Moonlight at 2022-04-12T11:11:06-04:00 Document that DuplicateRecordFields doesn't tolerates ambiguous fields Fix #19891 - - - - - 0090ad7b by Sebastian Graf at 2022-04-12T11:11:42-04:00 Eta reduction based on evaluation context (#21261) I completely rewrote our Notes surrounding eta-reduction. The new entry point is `Note [Eta reduction makes sense]`. Then I went on to extend the Simplifier to maintain an evaluation context in the form of a `SubDemand` inside a `SimplCont`. That `SubDemand` is useful for doing eta reduction according to `Note [Eta reduction based on evaluation context]`, which describes how Demand analysis, Simplifier and `tryEtaReduce` interact to facilitate eta reduction in more scenarios. Thus we fix #21261. ghc/alloc perf marginally improves (-0.0%). A medium-sized win is when compiling T3064 (-3%). It seems that haddock improves by 0.6% to 1.0%, too. Metric Decrease: T3064 - - - - - 4d2ee313 by Sebastian Graf at 2022-04-12T17:54:57+02:00 Specialising through specialised method calls (#19644) In #19644, we discovered that the ClassOp/DFun rules from Note [ClassOp/DFun selection] inhibit transitive specialisation in a scenario like ``` class C a where m :: Show b => a -> b -> ...; n :: ... instance C Int where m = ... -- $cm :: Show b => Int -> b -> ... f :: forall a b. (C a, Show b) => ... f $dC $dShow = ... m @a $dC @b $dShow ... main = ... f @Int @Bool ... ``` After we specialise `f` for `Int`, we'll see `m @a $dC @b $dShow` in the body of `$sf`. But before this patch, Specialise doesn't apply the ClassOp/DFun rule to rewrite to a call of the instance method for `C Int`, e.g., `$cm @Bool $dShow`. As a result, Specialise couldn't further specialise `$cm` for `Bool`. There's a better example in `Note [Specialisation modulo dictionary selectors]`. This patch enables proper Specialisation, as follows: 1. In the App case of `specExpr`, try to apply the CalssOp/DictSel rule on the head of the application 2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and `$dShow` in `bindAuxiliaryDict` NB: Without (2), (1) would be pointless, because `lookupRule` wouldn't be able to look into the RHS of `$dC` to see the DFun. (2) triggered #21332, because the Specialiser floats around dictionaries without accounting for them in the `SpecEnv`'s `InScopeSet`, triggering a panic when rewriting dictionary unfoldings. Fixes #19644 and #21332. - - - - - b06f4f47 by Sebastian Graf at 2022-04-12T17:54:58+02:00 Specialise: Check `typeDeterminesValue` before specialising on an interesting dictionary I extracted the checks from `Note [Type determines value]` into its own function, so that we share the logic properly. Then I made sure that we actually call `typeDeterminesValue` everywhere we check for `interestingDict`. - - - - - a42dbc55 by Matthew Pickering at 2022-04-13T06:24:52-04:00 Refine warning about defining rules in SAFE modules This change makes it clear that it's the definition rather than any usage which is a problem, and that rules defined in other modules will still be used to do rewrites. Fixes #20923 - - - - - df893f66 by Andreas Klebinger at 2022-04-14T08:18:37-04:00 StgLint: Lint constructor applications and strict workers for arity. This will mean T9208 when run with lint will return a lint error instead of resulting in a panic. Fixes #21117 - - - - - 426ec446 by sheaf at 2022-04-14T08:19:16-04:00 Hadrian: use a set to keep track of ways The order in which ways are provided doesn't matter, so we use a data structure with the appropriate semantics to represent ways. Fixes #21378 - - - - - 7c639b9a by Dylan Yudaken at 2022-04-15T13:55:59-04:00 Only enable PROF_SPIN in DEBUG - - - - - 96b9e5ea by Ben Gamari at 2022-04-15T13:56:34-04:00 testsuite: Add test for #21390 - - - - - d8392f6a by Ben Gamari at 2022-04-15T13:56:34-04:00 rts: Ensure that the interpreter doesn't disregard tags Previously the interpreter's handling of `RET_BCO` stack frames would throw away the tag of the returned closure. This resulted in #21390. - - - - - 83c67f76 by Alan Zimmerman at 2022-04-20T11:49:28-04:00 Add -dkeep-comments flag to keep comments in the parser This provides a way to set the Opt_KeepRawTokenStream from the command line, allowing exact print annotation users to see exactly what is produced for a given parsed file, when used in conjunction with -ddump-parsed-ast Discussed in #19706, but this commit does not close the issue. - - - - - a5ea65c9 by Krzysztof Gogolewski at 2022-04-20T11:50:04-04:00 Remove LevityInfo Every Id was storing a boolean whether it could be levity-polymorphic. This information is no longer needed since representation-checking has been moved to the typechecker. - - - - - 49bd7584 by Andreas Klebinger at 2022-04-20T11:50:39-04:00 Fix a shadowing issue in StgUnarise. For I assume performance reasons we don't record no-op replacements during unarise. This lead to problems with code like this: f = \(Eta_B0 :: VoidType) x1 x2 -> ... let foo = \(Eta_B0 :: LiftedType) -> g x y Eta_B0 in ... Here we would record the outer Eta_B0 as void rep, but would not shadow Eta_B0 inside `foo` because this arg is single-rep and so doesn't need to replaced. But this means when looking at occurence sites we would check the env and assume it's void rep based on the entry we made for the (no longer in scope) outer `Eta_B0`. Fixes #21396 and the ticket has a few more details. - - - - - 0c02c919 by Simon Peyton Jones at 2022-04-20T11:51:15-04:00 Fix substitution in bindAuxiliaryDict In GHC.Core.Opt.Specialise.bindAuxiliaryDict we were unnecessarily calling `extendInScope` to bring into scope variables that were /already/ in scope. Worse, GHC.Core.Subst.extendInScope strangely deleted the newly-in-scope variables from the substitution -- and that was fatal in #21391. I removed the redundant calls to extendInScope. More ambitiously, I changed GHC.Core.Subst.extendInScope (and cousins) to stop deleting variables from the substitution. I even changed the names of the function to extendSubstInScope (and cousins) and audited all the calls to check that deleting from the substitution was wrong. In fact there are very few such calls, and they are all about introducing a fresh non-in-scope variable. These are "OutIds"; it is utterly wrong to mess with the "InId" substitution. I have not added a Note, because I'm deleting wrong code, and it'd be distracting to document a bug. - - - - - 0481a6af by Cheng Shao at 2022-04-21T11:06:06+00:00 [ci skip] Drop outdated TODO in RtsAPI.c - - - - - 1e062a8a by Ben Gamari at 2022-04-22T02:12:59-04:00 rts: Introduce ip_STACK_FRAME While debugging it is very useful to be able to determine whether a given info table is a stack frame or not. We have spare bits in the closure flags array anyways, use one for this information. - - - - - 08a6a2ee by Ben Gamari at 2022-04-22T02:12:59-04:00 rts: Mark closureFlags array as const - - - - - 8f9b8282 by Krzysztof Gogolewski at 2022-04-22T02:13:35-04:00 Check for zero-bit types in sizeExpr Fixes #20940 Metric Decrease: T18698a - - - - - fcf22883 by Andreas Klebinger at 2022-04-22T02:14:10-04:00 Include the way string in the file name for dump files. This can be disabled by `-fno-dump-with-ways` if not desired. Finally we will be able to look at both profiled and non-profiled dumps when compiling with dump flags and we compile in both ways. - - - - - 252394ce by Bodigrim at 2022-04-22T02:14:48-04:00 Improve error messages from GHC.IO.Encoding.Failure - - - - - 250f57c1 by Bodigrim at 2022-04-22T02:14:48-04:00 Update test baselines to match new error messages from GHC.IO.Encoding.Failure - - - - - 5ac9b321 by Ben Gamari at 2022-04-22T02:15:25-04:00 get-win32-tarballs: Drop i686 architecture As of #18487 we no longer support 32-bit Windows. Fixes #21372. - - - - - dd5fecb0 by Ben Gamari at 2022-04-22T02:16:00-04:00 hadrian: Don't rely on xxx not being present in installation path Previously Hadrian's installation makefile would assume that the string `xxx` did not appear in the installation path. This would of course break for some users. Fixes #21402. - - - - - 09e98859 by Ben Gamari at 2022-04-22T02:16:35-04:00 testsuite: Ensure that GHC doesn't pick up environment files Here we set GHC_ENVIRONMENT="-" to ensure that GHC invocations of tests don't pick up a user's local package environment. Fixes #21365. Metric Decrease: T10421 T12234 T12425 T13035 T16875 T9198 - - - - - 76bb8cb3 by Ben Gamari at 2022-04-22T02:17:11-04:00 hadrian: Enable -dlint in devel2 flavour Previously only -dcore-lint was enabled. - - - - - f435d55f by Krzysztof Gogolewski at 2022-04-22T08:00:18-04:00 Fixes to rubbish literals * In CoreToStg, the application 'RUBBISH[rep] x' was simplified to 'RUBBISH[rep]'. But it is possible that the result of the function is represented differently than the function. * In Unarise, 'LitRubbish (primRepToType prep)' is incorrect: LitRubbish takes a RuntimeRep such as IntRep, while primRepToType returns a type such as Any @(TYPE IntRep). Use primRepToRuntimeRep instead. This code is never run in the testsuite. * In StgToByteCode, all rubbish literals were assumed to be boxed. This code predates representation-polymorphic RubbishLit and I think it was not updated. I don't have a testcase for any of those issues, but the code looks wrong. - - - - - 93c16b94 by sheaf at 2022-04-22T08:00:57-04:00 Relax "suppressing errors" assert in reportWanteds The assertion in reportWanteds that we aren't suppressing all the Wanted constraints was too strong: it might be the case that we are inside an implication, and have already reported an unsolved Wanted from outside the implication. It is possible that all Wanteds inside the implication have been rewritten by the outer Wanted, so we shouldn't throw an assertion failure in that case. Fixes #21405 - - - - - 78ec692d by Andreas Klebinger at 2022-04-22T08:01:33-04:00 Mention new MutableByteArray# wrapper in base changelog. - - - - - 56d7cb53 by Eric Lindblad at 2022-04-22T14:13:32-04:00 unlist announce - - - - - 1e4dcf23 by sheaf at 2022-04-22T14:14:12-04:00 decideMonoTyVars: account for CoVars in candidates The "candidates" passed to decideMonoTyVars can contain coercion holes. This is because we might well decide to quantify over some unsolved equality constraints, as long as they are not definitely insoluble. In that situation, decideMonoTyVars was passing a set of type variables that was not closed over kinds to closeWrtFunDeps, which was tripping up an assertion failure. Fixes #21404 - - - - - 2c541f99 by Simon Peyton Jones at 2022-04-22T14:14:47-04:00 Improve floated dicts in Specialise Second fix to #21391. It turned out that we missed calling bringFloatedDictsIntoScope when specialising imports, which led to the same bug as before. I refactored to move that call to a single place, in specCalls, so we can't forget it. This meant making `FloatedDictBinds` into its own type, pairing the dictionary bindings themselves with the set of their binders. Nicer this way. - - - - - 0950e2c4 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Ensure that --extra-lib-dirs are used Previously we only took `extraLibDirs` and friends from the package description, ignoring any contribution from the `LocalBuildInfo`. Fix this. Fixes #20566. - - - - - 53cc93ae by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Drop redundant include directories The package-specific include directories in Settings.Builders.Common.cIncludeDirs are now redundant since they now come from Cabal. Closes #20566. - - - - - b2721819 by Ben Gamari at 2022-04-25T10:18:17-04:00 hadrian: Clean up handling of libffi dependencies - - - - - 18e5103f by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: More robust library way detection Previously `test.mk` would try to determine whether the dynamic, profiling, and vanilla library ways are available by searching for `PrimOpWrappers.{,dyn_,p_}hi` in directory reported by `ghc-pkg field ghc-prim library-dirs`. However, this is extremely fragile as there is no guarantee that there is only one library directory. To handle the case of multiple `library-dirs` correct we would have to carry out the delicate task of tokenising the directory list (in shell, no less). Since this isn't a task that I am eager to solve, I have rather moved the detection logic into the testsuite driver and instead perform a test compilation in each of the ways. This should be more robust than the previous approach. I stumbled upon this while fixing #20579. - - - - - 6c7a4913 by Ben Gamari at 2022-04-25T10:18:17-04:00 testsuite: Cabalify ghc-config To ensure that the build benefits from Hadrian's usual logic for building packages, avoiding #21409. Closes #21409. - - - - - 9af091f7 by Ben Gamari at 2022-04-25T10:18:53-04:00 rts: Factor out built-in GC roots - - - - - e7c4719d by Ben Gamari at 2022-04-25T10:18:54-04:00 Ensure that wired-in exception closures aren't GC'd As described in Note [Wired-in exceptions are not CAFfy], a small set of built-in exception closures get special treatment in the code generator, being declared as non-CAFfy despite potentially containing CAF references. The original intent of this treatment for the RTS to then add StablePtrs for each of the closures, ensuring that they are not GC'd. However, this logic was not applied consistently and eventually removed entirely in 951c1fb0. This lead to #21141. Here we fix this bug by reintroducing the StablePtrs and document the status quo. Closes #21141. - - - - - 9587726f by Ben Gamari at 2022-04-25T10:18:54-04:00 testsuite: Add testcase for #21141 - - - - - cb71226f by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop dead code in GHC.Linker.Static.linkBinary' Previously we supported building statically-linked executables using libtool. However, this was dropped in 91262e75dd1d80f8f28a3922934ec7e59290e28c in favor of using ar/ranlib directly. Consequently we can drop this logic. Fixes #18826. - - - - - 9420d26b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop libtool path from settings file GHC no longers uses libtool for linking and therefore this is no longer necessary. - - - - - 41cf758b by Ben Gamari at 2022-04-25T10:19:29-04:00 Drop remaining vestiges of libtool Drop libtool logic from gen-dll, allowing us to drop the remaining logic from the `configure` script. Strangely, this appears to reliably reduce compiler allocations of T16875 on Windows. Closes #18826. Metric Decrease: T16875 - - - - - e09afbf2 by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - e76705cf by Ben Gamari at 2022-04-25T10:20:05-04:00 rts: Improve documentation of closure types Also drops the unused TREC_COMMITTED transaction state. - - - - - f2c08124 by Bodigrim at 2022-04-25T10:20:44-04:00 Document behaviour of RULES with KnownNat - - - - - 360dc2bc by Li-yao Xia at 2022-04-25T19:13:06+00:00 Fix rendering of liftA haddock - - - - - 16df6058 by Ben Gamari at 2022-04-27T10:02:25-04:00 testsuite: Report minimum and maximum stat changes As suggested in #20733. - - - - - e39cab62 by Fabian Thorand at 2022-04-27T10:03:03-04:00 Defer freeing of mega block groups Solves the quadratic worst case performance of freeing megablocks that was described in issue #19897. During GC runs, we now keep a secondary free list for megablocks that is neither sorted, nor coalesced. That way, free becomes an O(1) operation at the expense of not being able to reuse memory for larger allocations. At the end of a GC run, the secondary free list is sorted and then merged into the actual free list in a single pass. That way, our worst case performance is O(n log(n)) rather than O(n^2). We postulate that temporarily losing coalescense during a single GC run won't have any adverse effects in practice because: - We would need to release enough memory during the GC, and then after that (but within the same GC run) allocate a megablock group of more than one megablock. This seems unlikely, as large objects are not copied during GC, and so we shouldn't need such large allocations during a GC run. - Allocations of megablock groups of more than one megablock are rare. They only happen when a single heap object is large enough to require that amount of space. Any allocation areas that are supposed to hold more than one heap object cannot use megablock groups, because only the first megablock of a megablock group has valid `bdescr`s. Thus, heap object can only start in the first megablock of a group, not in later ones. - - - - - 5de6be0c by Fabian Thorand at 2022-04-27T10:03:03-04:00 Add note about inefficiency in returnMemoryToOS - - - - - 8bef471a by sheaf at 2022-04-27T10:03:43-04:00 Ensure that Any is Boxed in FFI imports/exports We should only accept the type `Any` in foreign import/export declarations when it has type `Type` or `UnliftedType`. This patch adds a kind check, and a special error message triggered by occurrences of `Any` in foreign import/export declarations at other kinds. Fixes #21305 - - - - - ba3d4e1c by Ben Gamari at 2022-04-27T10:04:19-04:00 Basic response file support Here we introduce support into our command-line parsing infrastructure and driver for handling gnu-style response file arguments, typically used to work around platform command-line length limitations. Fixes #16476. - - - - - 3b6061be by Ben Gamari at 2022-04-27T10:04:19-04:00 testsuite: Add test for #16476 - - - - - 75bf1337 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix cabal-reinstall job It's quite nice we can do this by mostly deleting code Fixes #21373 - - - - - 2c00d904 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add test to check that release jobs have profiled libs - - - - - 50d78d3b by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Explicitly handle failures in test_hadrian We also disable the stage1 testing which is broken. Related to #21072 - - - - - 2dcdf091 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Fix shell command - - - - - 55c84123 by Matthew Pickering at 2022-04-27T10:04:55-04:00 bootstrap: Add bootstrapping files for ghc-9_2_2 Fixes #21373 - - - - - c7ee0be6 by Matthew Pickering at 2022-04-27T10:04:55-04:00 ci: Add linting job which checks authors are not GHC CI - - - - - 23aad124 by Adam Sandberg Ericsson at 2022-04-27T10:05:31-04:00 rts: state explicitly what evacuate and scavange mean in the copying gc - - - - - 318e0005 by Ben Gamari at 2022-04-27T10:06:07-04:00 rts/eventlog: Don't attempt to flush if there is no writer If the user has not configured a writer then there is nothing to flush. - - - - - ee11d043 by Ben Gamari at 2022-04-27T10:06:07-04:00 Enable eventlog support in all ways by default Here we deprecate the eventlogging RTS ways and instead enable eventlog support in the remaining ways. This simplifies packaging and reduces GHC compilation times (as we can eliminate two whole compilations of the RTS) while simplifying the end-user story. The trade-off is a small increase in binary sizes in the case that the user does not want eventlogging support, but we think that this is a fine trade-off. This also revealed a latent RTS bug: some files which included `Cmm.h` also assumed that it defined various macros which were in fact defined by `Config.h`, which `Cmm.h` did not include. Fixing this in turn revealed that `StgMiscClosures.cmm` failed to import various spinlock statistics counters, as evidenced by the failed unregisterised build. Closes #18948. - - - - - a2e5ab70 by Andreas Klebinger at 2022-04-27T10:06:43-04:00 Change `-dsuppress-ticks` to only suppress non-code ticks. This means cost centres and coverage ticks will still be present in output. Makes using -dsuppress-all more convenient when looking at profiled builds. - - - - - ec9d7e04 by Ben Gamari at 2022-04-27T10:07:21-04:00 Bump text submodule. This should fix #21352 - - - - - c3105be4 by Bodigrim at 2022-04-27T10:08:01-04:00 Documentation for setLocaleEncoding - - - - - 7f618fd3 by sheaf at 2022-04-27T10:08:40-04:00 Update docs for change to type-checking plugins There was no mention of the changes to type-checking plugins in the 9.4.1 notes, and the extending_ghc documentation contained a reference to an outdated type. - - - - - 4419dd3a by Adam Sandberg Ericsson at 2022-04-27T10:09:18-04:00 rts: add some more documentation to StgWeak closure type - - - - - 5a7f0dee by Matthew Pickering at 2022-04-27T10:09:54-04:00 Give Cmm files fake ModuleNames which include full filepath This fixes the initialisation functions when using -prof or -finfo-table-map. Fixes #21370 - - - - - 81cf52bb by sheaf at 2022-04-27T10:10:33-04:00 Mark GHC.Prim.PtrEq as Unsafe This module exports unsafe pointer equality operations, so we accordingly mark it as Unsafe. Fixes #21433 - - - - - f6a8185d by Ben Gamari at 2022-04-28T09:10:31+00:00 testsuite: Add performance test for #14766 This distills the essence of the Sigs.hs program found in the ticket. - - - - - c7a3dc29 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Add Monoid instance to Way - - - - - 654bafea by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Enrich flavours to build profiled/debugged/threaded ghcs per stage - - - - - 4ad559c8 by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: add debug_ghc and debug_stage1_ghc flavour transformers - - - - - f9728fdb by Douglas Wilson at 2022-04-28T18:54:44-04:00 hadrian: Don't pass -rtsopts when building libraries - - - - - 769279e6 by Matthew Pickering at 2022-04-28T18:54:44-04:00 testsuite: Fix calculation about whether to pass -dynamic to compiler - - - - - da8ae7f2 by Ben Gamari at 2022-04-28T18:55:20-04:00 hadrian: Clean up flavour transformer definitions Previously the `ipe` and `omit_pragmas` transformers were hackily defined using the textual key-value syntax. Fix this. - - - - - 61305184 by Ben Gamari at 2022-04-28T18:55:56-04:00 Bump process submodule - - - - - a8c99391 by sheaf at 2022-04-28T18:56:37-04:00 Fix unification of ConcreteTvs, removing IsRefl# This patch fixes the unification of concrete type variables. The subtlety was that unifying concrete metavariables is more subtle than other metavariables, as decomposition is possible. See the Note [Unifying concrete metavariables], which explains how we unify a concrete type variable with a type 'ty' by concretising 'ty', using the function 'GHC.Tc.Utils.Concrete.concretise'. This can be used to perform an eager syntactic check for concreteness, allowing us to remove the IsRefl# special predicate. Instead of emitting two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we instead concretise 'rr'. If this succeeds we can fill 'concrete_tv', and otherwise we directly emit an error message to the typechecker environment instead of deferring. We still need the error message to be passed on (instead of directly thrown), as we might benefit from further unification in which case we will need to zonk the stored types. To achieve this, we change the 'wc_holes' field of 'WantedConstraints' to 'wc_errors', which stores general delayed errors. For the moement, a delayed error is either a hole, or a syntactic equality error. hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and hasFixedRuntimeRep has been refactored to directly return the most useful coercion for PHASE 2 of FixedRuntimeRep. This patch also adds a field ir_frr to the InferResult datatype, holding a value of type Maybe FRROrigin. When this value is not Nothing, this means that we must fill the ir_ref field with a type which has a fixed RuntimeRep. When it comes time to fill such an ExpType, we ensure that the type has a fixed RuntimeRep by performing a representation-polymorphism check with the given FRROrigin This is similar to what we already do to ensure we fill an Infer ExpType with a type of the correct TcLevel. This allows us to properly perform representation-polymorphism checks on 'Infer' 'ExpTypes'. The fillInferResult function had to be moved to GHC.Tc.Utils.Unify to avoid a cyclic import now that it calls hasFixedRuntimeRep. This patch also changes the code in matchExpectedFunTys to make use of the coercions, which is now possible thanks to the previous change. This implements PHASE 2 of FixedRuntimeRep in some situations. For example, the test cases T13105 and T17536b are now both accepted. Fixes #21239 and #21325 ------------------------- Metric Decrease: T18223 T5631 ------------------------- - - - - - 43bd897d by Simon Peyton Jones at 2022-04-28T18:57:13-04:00 Add INLINE pragmas for Enum helper methods As #21343 showed, we need to be super-certain that the "helper methods" for Enum instances are actually inlined or specialised. I also tripped over this when I discovered that numericEnumFromTo and friends had no pragmas at all, so their performance was very fragile. If they weren't inlined, all bets were off. So I've added INLINE pragmas for them too. See new Note [Inline Enum method helpers] in GHC.Enum. I also expanded Note [Checking for INLINE loop breakers] in GHC.Core.Lint to explain why an INLINE function might temporarily be a loop breaker -- this was the initial bug report in #21343. Strangely we get a 16% runtime allocation decrease in perf/should_run/T15185, but only on i386. Since it moves in the right direction I'm disinclined to investigate, so I'll accept it. Metric Decrease: T15185 - - - - - ca1434e3 by Ben Gamari at 2022-04-28T18:57:49-04:00 configure: Bump GHC version to 9.5 Bumps haddock submodule. - - - - - 292e3971 by Teo Camarasu at 2022-04-28T18:58:28-04:00 add since annotation for GHC.Stack.CCS.whereFrom - - - - - 905206d6 by Tamar Christina at 2022-04-28T22:19:34-04:00 winio: add support to iserv. - - - - - d182897e by Tamar Christina at 2022-04-28T22:19:34-04:00 Remove unused line - - - - - 22cf4698 by Matthew Pickering at 2022-04-28T22:20:10-04:00 Revert "rts: Refactor handling of dead threads' stacks" This reverts commit e09afbf2a998beea7783e3de5dce5dd3c6ff23db. - - - - - 8ed57135 by Matthew Pickering at 2022-04-29T04:11:29-04:00 Provide efficient unionMG function for combining two module graphs. This function is used by API clients (hls). This supercedes !6922 - - - - - 0235ff02 by Ben Gamari at 2022-04-29T04:12:05-04:00 Bump bytestring submodule Update to current `master`. - - - - - 01988418 by Matthew Pickering at 2022-04-29T04:12:05-04:00 testsuite: Normalise package versions in UnusedPackages test - - - - - 724d0dc0 by Matthew Pickering at 2022-04-29T08:59:42+00:00 testsuite: Deduplicate ways correctly This was leading to a bug where we would run a profasm test twice which led to invalid junit.xml which meant the test results database was not being populated for the fedora33-perf job. - - - - - 5630dde6 by Ben Gamari at 2022-04-29T13:06:20-04:00 rts: Refactor handling of dead threads' stacks This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks. - - - - - 0cdef807 by parsonsmatt at 2022-04-30T16:51:12-04:00 Add a note about instance visibility across component boundaries In principle, the *visible* instances are * all instances defined in a prior top-level declaration group (see docs on `newDeclarationGroup`), or * all instances defined in any module transitively imported by the module being compiled However, actually searching all modules transitively below the one being compiled is unreasonably expensive, so `reifyInstances` will report only the instance for modules that GHC has had some cause to visit during this compilation. This is a shortcoming: `reifyInstances` might fail to report instances for a type that is otherwise unusued, or instances defined in a different component. You can work around this shortcoming by explicitly importing the modules whose instances you want to be visible. GHC issue #20529 has some discussion around this. Fixes #20529 - - - - - e2dd884a by Ryan Scott at 2022-04-30T16:51:47-04:00 Make mkFunCo take AnonArgFlags into account Previously, whenever `mkFunCo` would produce reflexive coercions, it would use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is also used to produce coercions between types of the form `ty1 => ty2` in certain places. This has the unfortunate side effect of causing the type of the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted in #21328. This patch address this by changing replacing the use of `mkVisFunTy` with `mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`, so this should always produce the correct `AnonArgFlag`. As a result, this patch fixes part (2) of #21328. This is not the only possible way to fix #21328, as the discussion on that issue lists some possible alternatives. Ultimately, it was concluded that the alternatives would be difficult to maintain, and since we already use `mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType` in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType` does not regress the performance of any test case we have in GHC's test suite. - - - - - 170da54f by Ben Gamari at 2022-04-30T16:52:27-04:00 Convert More Diagnostics (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors. - - - - - 39edc7b4 by Marius Ghita at 2022-04-30T16:53:06-04:00 Update user guide example rewrite rules formatting Change the rewrite rule examples to include a space between the composition of `f` and `g` in the map rewrite rule examples. Without this change, if the user has locally enabled the extension OverloadedRecordDot the copied example will result in a compile time error that `g` is not a field of `f`. ``` • Could not deduce (GHC.Records.HasField "g" (a -> b) (a1 -> b)) arising from selecting the field ‘g’ ``` - - - - - 2e951e48 by Adam Sandberg Ericsson at 2022-04-30T16:53:42-04:00 ghc-boot: export typesynonyms from GHC.Utils.Encoding This makes the Haddocks easier to understand. - - - - - d8cbc77e by Adam Sandberg Ericsson at 2022-04-30T16:54:18-04:00 users guide: add categories to some flags - - - - - d0f14fad by Chris Martin at 2022-04-30T16:54:57-04:00 hacking guide: mention the core libraries committee - - - - - 34b28200 by Matthew Pickering at 2022-04-30T16:55:32-04:00 Revert "Make the specialiser handle polymorphic specialisation" This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8. See ticket #21229 ------------------------- Metric Decrease: T15164 Metric Increase: T13056 ------------------------- - - - - - ee891c1e by Matthew Pickering at 2022-04-30T16:55:32-04:00 Add test for T21229 - - - - - ab677cc8 by Matthew Pickering at 2022-04-30T16:56:08-04:00 Hadrian: Update README about the flavour/testsuite contract There have been a number of tickets about non-tested flavours not passing the testsuite.. this is expected and now noted in the documentation. You use other flavours to run the testsuite at your own risk. Fixes #21418 - - - - - b57b5b92 by Ben Gamari at 2022-04-30T16:56:44-04:00 rts/m32: Fix assertion failure This fixes an assertion failure in the m32 allocator due to the imprecisely specified preconditions of `m32_allocator_push_filled_list`. Specifically, the caller must ensure that the page type is set to filled prior to calling `m32_allocator_push_filled_list`. While this issue did result in an assertion failure in the debug RTS, the issue is in fact benign. - - - - - a7053a6c by sheaf at 2022-04-30T16:57:23-04:00 Testsuite driver: don't crash on empty metrics The testsuite driver crashed when trying to display minimum/maximum performance changes when there are no metrics (i.e. there is no baseline available). This patch fixes that. - - - - - 636f7c62 by Andreas Klebinger at 2022-05-01T22:21:17-04:00 StgLint: Check that functions are applied to compatible runtime reps We use compatibleRep to compare reps, and avoid checking functions with levity polymorphic types because of #21399. - - - - - 60071076 by Hécate Moonlight at 2022-05-01T22:21:55-04:00 Add documentation to the ByteArray# primetype. close #21417 - - - - - 2b2e3020 by Andreas Klebinger at 2022-05-01T22:22:31-04:00 exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is bottoming. We used to check the divergence and that the number of arguments > arity. But arity zero represents unknown arity so this was subtly broken for a long time! We would check if the saturated function diverges, and if we applied >=arity arguments. But for unknown arity functions any number of arguments is >=idArity. This fixes #21440. - - - - - 4eaf0f33 by Eric Lindblad at 2022-05-01T22:23:11-04:00 typos - - - - - fc58df90 by Niklas Hambüchen at 2022-05-02T08:59:27+00:00 libraries/base: docs: Explain relationshipt between `finalizeForeignPtr` and `*Conc*` creation Fixes https://gitlab.haskell.org/ghc/ghc/-/issues/21420 - - - - - 3e400f20 by Krzysztof Gogolewski at 2022-05-02T18:29:23-04:00 Remove obsolete code in CoreToStg Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4. This codepath is tested by T15696_3. - - - - - 4a780928 by Krzysztof Gogolewski at 2022-05-02T18:29:24-04:00 Fix several note references - - - - - 15ffe2b0 by Sebastian Graf at 2022-05-03T20:11:51+02:00 Assume at least one evaluation for nested SubDemands (#21081, #21133) See the new `Note [SubDemand denotes at least one evaluation]`. A demand `n :* sd` on a let binder `x=e` now means > "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is > evaluated deeply in sub-demand `sd`." The "any time it is evaluated" premise is what this patch adds. As a result, we get better nested strictness. For example (T21081) ```hs f :: (Bool, Bool) -> (Bool, Bool) f pr = (case pr of (a,b) -> a /= b, True) -- before: <MP(L,L)> -- after: <MP(SL,SL)> g :: Int -> (Bool, Bool) g x = let y = let z = odd x in (z,z) in f y ``` The change in demand signature "before" to "after" allows us to case-bind `z` here. Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`, albeit). We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand expansion. In an attempt to fix a regression caused by less inlining due to eta-reduction in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus fixing #21345 on the go. The main point of this patch is that it fixes #21081 and #21133. Annoyingly, I discovered that more precise demand signatures for join points can transform a program into a lazier program if that join point gets floated to the top-level, see #21392. There is no simple fix at the moment, but !5349 might. Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392 bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue. Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by 0.4% in the geometric mean and by 2% in T16875. Metric Increase: MultiLayerModulesTH_OneShot Metric Decrease: T16875 - - - - - 948c7e40 by Andreas Klebinger at 2022-05-04T09:57:34-04:00 CoreLint - When checking for levity polymorphism look through more ticks. For expressions like `(scc<cc_name> primOp#) arg1` we should also look at arg1 to determine if we call primOp# at a fixed runtime rep. This is what corePrep already does but CoreLint didn't yet. This patch will bring them in sync in this regard. It also uses tickishFloatable in CorePrep instead of CorePrep having it's own slightly differing definition of when a tick is floatable. - - - - - 85bc73bd by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Support Unicode properly - - - - - 063d485e by Alexis King at 2022-05-04T09:58:14-04:00 genprimopcode: Replace LaTeX documentation syntax with Haddock The LaTeX documentation generator does not seem to have been used for quite some time, so the LaTeX-to-Haddock preprocessing step has become a pointless complication that makes documenting the contents of GHC.Prim needlessly difficult. This commit replaces the LaTeX syntax with the Haddock it would have been converted into, anyway, though with an additional distinction: it uses single quotes in places to instruct Haddock to generate hyperlinks to bindings. This improves the quality of the generated output. - - - - - d61f7428 by Ben Gamari at 2022-05-04T09:58:50-04:00 rts/ghc.mk: Only build StgCRunAsm.S when it is needed Previously the make build system unconditionally included StgCRunAsm.S in the link, meaning that the RTS would require an execstack unnecessarily. Fixes #21478. - - - - - 934a90dd by Simon Peyton Jones at 2022-05-04T16:15:34-04:00 Improve error reporting in generated code Our error reporting in generated code (via desugaring before typechecking) only worked when the generated code was just a simple call. This commit makes it work in nested cases. - - - - - 445d3657 by sheaf at 2022-05-04T16:16:12-04:00 Ensure Any is not levity-polymorphic in FFI The previous patch forgot to account for a type such as Any @(TYPE (BoxedRep l)) for a quantified levity variable l. - - - - - ddd2591c by Ben Gamari at 2022-05-04T16:16:48-04:00 Update supported LLVM versions Pull forward minimum version to match 9.2. (cherry picked from commit c26faa54c5fbe902ccb74e79d87e3fa705e270d1) - - - - - f9698d79 by Ben Gamari at 2022-05-04T16:16:48-04:00 testsuite/T7275: Use sed -r Darwin requires the `-r` flag to be compatible with GNU sed. (cherry picked from commit 512338c8feec96c38ef0cf799f3a01b77c967c56) - - - - - 8635323b by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Use ld.lld on ARMv7/Linux Due to #16177. Also cleanup some code style issues. (cherry picked from commit cc1c3861e2372f464bf9e3c9c4d4bd83f275a1a6) - - - - - 4f6370c7 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Always preserve artifacts, even in failed jobs (cherry picked from commit fd08b0c91ea3cab39184f1b1b1aafcd63ce6973f) - - - - - 6f662754 by Ben Gamari at 2022-05-04T16:16:48-04:00 configure: Make sphinx version check more robust It appears that the version of sphinx shipped on CentOS 7 reports a version string of `Sphinx v1...`. Accept the `v`. (cherry picked from commit a9197a292fd4b13308dc6664c01351c7239357ed) - - - - - 0032dc38 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab-ci: Don't run make job in release pipelines (cherry picked from commit 16d6a8ff011f2194485387dcca1c00f8ddcdbdeb) - - - - - 27f9aab3 by Ben Gamari at 2022-05-04T16:16:48-04:00 gitlab/ci: Fix name of bootstrap compiler directory Windows binary distributions built with Hadrian have a target platform suffix in the name of their root directory. Teach `ci.sh` about this fact. (cherry picked from commit df5752f39671f6d04d8cd743003469ae5eb67235) - - - - - b528f0f6 by Krzysztof Gogolewski at 2022-05-05T09:05:43-04:00 Fix several note references, part 2 - - - - - 691aacf6 by Adam Sandberg Ericsson at 2022-05-05T09:06:19-04:00 adjustors: align comment about number of integer like arguments with implementation for Amd4+MinGW implementation - - - - - f050557e by Simon Jakobi at 2022-05-05T12:47:32-04:00 Remove two uses of IntMap.size IntMap.size is O(n). The new code should be slightly more efficient. The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be described formally as the transformation: (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n ==> (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk) - - - - - 7da90ae3 by Tom Ellis at 2022-05-05T12:48:09-04:00 Explain that 'fail s' should run in the monad itself - - - - - 610d0283 by Matthew Craven at 2022-05-05T12:48:47-04:00 Add a test for the bracketing in rules for (^) - - - - - 016f9ca6 by Matthew Craven at 2022-05-05T12:48:47-04:00 Fix broken rules for (^) with known small powers - - - - - 9372aaab by Matthew Craven at 2022-05-05T12:48:47-04:00 Give the two T19569 tests different names - - - - - 61901b32 by Andreas Klebinger at 2022-05-05T12:49:23-04:00 SpecConstr: Properly create rules for call patterns representing partial applications The main fix is that in addVoidWorkerArg we now add the argument to the front. This fixes #21448. ------------------------- Metric Decrease: T16875 ------------------------- - - - - - 71278dc7 by Teo Camarasu at 2022-05-05T12:50:03-04:00 add since annotations for instances of ByteArray - - - - - 962ff90b by sheaf at 2022-05-05T12:50:42-04:00 Start 9.6.1-notes Updates the documentation notes to start tracking changes for the 9.6.1 release (instead of 9.4). - - - - - aacb15a3 by Matthew Pickering at 2022-05-05T20:24:01-04:00 ci: Add job to check that jobs.yaml is up-to-date There have been quite a few situations where jobs.yaml has been out of date. It's better to add a CI job which checks that it's right. We don't want to use a staged pipeline because it obfuscates the structure of the pipeline. - - - - - be7102e5 by Ben Gamari at 2022-05-05T20:24:37-04:00 rts: Ensure that XMM registers are preserved on Win64 Previously we only preserved the bottom 64-bits of the callee-saved 128-bit XMM registers, in violation of the Win64 calling convention. Fix this. Fixes #21465. - - - - - 73b22ff1 by Ben Gamari at 2022-05-05T20:24:37-04:00 testsuite: Add test for #21465 - - - - - e2ae9518 by Ziyang Liu at 2022-05-06T19:22:22-04:00 Allow `let` just before pure/return in ApplicativeDo The following is currently rejected: ```haskell -- F is an Applicative but not a Monad x :: F (Int, Int) x = do a <- pure 0 let b = 1 pure (a, b) ``` This has bitten me multiple times. This MR contains a simple fix: only allow a "let only" segment to be merged with the next (and not the previous) segment. As a result, when the last one or more statements before pure/return are `LetStmt`s, there will be one more segment containing only those `LetStmt`s. Note that if the `let` statement mentions a name bound previously, then the program is still rejected, for example ```haskell x = do a <- pure 0 let b = a + 1 pure (a, b) ``` or the example in #18559. To support this would require a more complex approach, but this is IME much less common than the previous case. - - - - - 0415449a by Matthew Pickering at 2022-05-06T19:22:58-04:00 template-haskell: Fix representation of OPAQUE pragmas There is a mis-match between the TH representation of OPAQUE pragmas and GHC's internal representation due to how OPAQUE pragmas disallow phase annotations. It seemed most in keeping to just fix the wired in name issue by adding a special case to the desugaring of INLINE pragmas rather than making TH/GHC agree with how the representation should look. Fixes #21463 - - - - - 4de887e2 by Simon Peyton Jones at 2022-05-06T19:23:34-04:00 Comments only: Note [AppCtxt] - - - - - 6e69964d by Matthew Pickering at 2022-05-06T19:24:10-04:00 Fix name of windows release bindist in doc-tarball job - - - - - ced4689e by Matthew Pickering at 2022-05-06T19:24:46-04:00 ci: Generate source-tarball in release jobs We need to distribute the source tarball so we should generate it in the CI pipeline. - - - - - 3c91de21 by Rob at 2022-05-08T13:40:53+02:00 Change Specialise to use OrdList. Fixes #21362 Metric Decrease: T16875 - - - - - 67072c31 by Simon Jakobi at 2022-05-08T12:23:43-04:00 Tweak GHC.CmmToAsm.CFG.delEdge mapAdjust is more efficient than mapAlter. - - - - - 374554bb by Teo Camarasu at 2022-05-09T16:24:37-04:00 Respect -po when heap profiling (#21446) - - - - - 1ea414b6 by Teo Camarasu at 2022-05-09T16:24:37-04:00 add test case for #21446 - - - - - c7902078 by Jens Petersen at 2022-05-09T16:25:17-04:00 avoid hadrian/bindist/Makefile install_docs error when --docs=none When docs are disabled the bindist does not have docs/ and hence docs-utils/ is not generated. Here we just test that docs-utils exists before attempting to install prologue.txt and gen_contents_index to avoid the error: /usr/bin/install: cannot stat 'docs-utils/prologue.txt': No such file or directory make: *** [Makefile:195: install_docs] Error 1 - - - - - 158bd659 by Hécate Moonlight at 2022-05-09T16:25:56-04:00 Correct base's changelog for 4.16.1.0 This commit reaffects the new Ix instances of the foreign integral types from base 4.17 to 4.16.1.0 closes #21529 - - - - - a4fbb589 by Sylvain Henry at 2022-05-09T16:26:36-04:00 STG: only print cost-center if asked to - - - - - 50347ded by Gergo ERDI at 2022-05-10T11:43:33+00:00 Improve "Glomming" note Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order references, and thus needing to glom, is not a cause for concern when its root cause is rewrite rules. - - - - - df2e3373 by Eric Lindblad at 2022-05-10T20:45:41-04:00 update INSTALL - - - - - dcac3833 by Matthew Pickering at 2022-05-10T20:46:16-04:00 driver: Make -no-keep-o-files -no-keep-hi-files work in --make mode It seems like it was just an oversight to use the incorrect DynFlags (global rather than local) when implementing these two options. Using the local flags allows users to request these intermediate files get cleaned up, which works fine in --make mode because 1. Interface files are stored in memory 2. Object files are only cleaned at the end of session (after link) Fixes #21349 - - - - - 35da81f8 by Ben Gamari at 2022-05-10T20:46:52-04:00 configure: Check for ffi.h As noted in #21485, we checked for ffi.h yet then failed to throw an error if it is missing. Fixes #21485. - - - - - bdc99cc2 by Simon Peyton Jones at 2022-05-10T20:47:28-04:00 Check for uninferrable variables in tcInferPatSynDecl This fixes #21479 See Note [Unquantified tyvars in a pattern synonym] While doing this, I found that some error messages pointed at the pattern synonym /name/, rather than the /declaration/ so I widened the SrcSpan to encompass the declaration. - - - - - 142a73d9 by Matthew Pickering at 2022-05-10T20:48:04-04:00 hadrian: Fix split-sections transformer The splitSections transformer has been broken since -dynamic-too support was implemented in hadrian. This is because we actually build the dynamic way when building the dynamic way, so the predicate would always fail. The fix is to just always pass `split-sections` even if it doesn't do anything for a particular way. Fixes #21138 - - - - - 699f5935 by Matthew Pickering at 2022-05-10T20:48:04-04:00 packaging: Build perf builds with -split-sections In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. Closes #21135 - - - - - 21feece2 by Simon Peyton Jones at 2022-05-10T20:48:39-04:00 Use the wrapper for an unlifted binding We assumed the wrapper for an unlifted binding is the identity, but as #21516 showed, that is no always true. Solution is simple: use it. - - - - - 68d1ea5f by Matthew Pickering at 2022-05-10T20:49:15-04:00 docs: Fix path to GHC API docs in index.html In the make bindists we generate documentation in docs/ghc-<VER> but the hadrian bindists generate docs/ghc/ so the path to the GHC API docs was wrong in the index.html file. Rather than make the hadrian and make bindists the same it was easier to assume that if you're using the mkDocs script that you're using hadrian bindists. Fixes #21509 - - - - - 9d8f44a9 by Matthew Pickering at 2022-05-10T20:49:51-04:00 hadrian: Don't pass -j to haddock This has high potential for oversubcribing as many haddock jobs can be spawned in parralel which will each request the given number of capabilities. Once -jsem is implemented (#19416, !5176) we can expose that haddock via haddock and use that to pass a semaphore. Ticket #21136 - - - - - fec3e7aa by Matthew Pickering at 2022-05-10T20:50:27-04:00 hadrian: Only copy and install libffi headers when using in-tree libffi When passed `--use-system-libffi` then we shouldn't copy and install the headers from the system package. Instead the headers are expected to be available as a runtime dependency on the users system. Fixes #21485 #21487 - - - - - 5b791ed3 by mikael at 2022-05-11T08:22:13-04:00 FIND_LLVM_PROG: Recognize llvm suffix used by FreeBSD, ie llc10. - - - - - 8500206e by ARATA Mizuki at 2022-05-11T08:22:57-04:00 Make floating-point abs IEEE 754 compliant The old code used by via-C backend didn't handle the sign bit of NaN. See #21043. - - - - - 4a4c77ed by Alan Zimmerman at 2022-05-11T08:23:33-04:00 EPA: do statement with leading semicolon has wrong anchor The code do; a <- doAsync; b Generated an incorrect Anchor for the statement list that starts after the first semicolon. This commit fixes it. Closes #20256 - - - - - e3ca8dac by Simon Peyton Jones at 2022-05-11T08:24:08-04:00 Specialiser: saturate DFuns correctly Ticket #21489 showed that the saturation mechanism for DFuns (see Note Specialising DFuns) should use both UnspecType and UnspecArg. We weren't doing that; but this MR fixes that problem. No test case because it's hard to tickle, but it showed up in Gergo's work with GHC-as-a-library. - - - - - fcc7dc4c by Ben Gamari at 2022-05-11T20:05:41-04:00 gitlab-ci: Check for dynamic msys2 dependencies Both #20878 and #21196 were caused by unwanted dynamic dependencies being introduced by boot libraries. Ensure that we catch this in CI by attempting to run GHC in an environment with a minimal PATH. - - - - - 3c998f0d by Matthew Pickering at 2022-05-11T20:06:16-04:00 Add back Debian9 CI jobs We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19 not being at EOL until April 2023 and they still need tinfo5. Fixes #21469 - - - - - dea9a3d9 by Ben Gamari at 2022-05-11T20:06:51-04:00 rts: Drop setExecutable Since f6e366c058b136f0789a42222b8189510a3693d1 setExecutable has been dead code. Drop it. - - - - - 32cdf62d by Simon Peyton Jones at 2022-05-11T20:07:27-04:00 Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_pat This missing guard gave rise to #21519. - - - - - 2c00a8d0 by Matthew Pickering at 2022-05-11T20:08:02-04:00 Add mention of -hi to RTS --help Fixes #21546 - - - - - a2dcad4e by Andre Marianiello at 2022-05-12T02:15:48+00:00 Decouple dynflags in Cmm parser (related to #17957) - - - - - 3a022baa by Andre Marianiello at 2022-05-12T02:15:48+00:00 Remove Module argument from initCmmParserConfig - - - - - 2fc8d76b by Andre Marianiello at 2022-05-12T02:15:48+00:00 Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.Config - - - - - b8c5ffab by Andre Marianiello at 2022-05-12T18:13:55-04:00 Decouple dynflags in GHC.Core.Opt.Arity (related to #17957) Metric Decrease: T16875 - - - - - 3bf938b6 by sheaf at 2022-05-12T18:14:34-04:00 Update extending_ghc for TcPlugin changes The documentation still mentioned Derived constraints and an outdated datatype TcPluginResult. - - - - - 668a9ef4 by jackohughes at 2022-05-13T12:10:34-04:00 Fix printing of brackets in multiplicities (#20315) Change mulArrow to allow for printing of correct application precedence where necessary and update callers of mulArrow to reflect this. As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type. Fixes #20315 - - - - - 30b8b7f1 by Ben Gamari at 2022-05-13T12:11:09-04:00 rts: Add debug output on ocResolve failure This makes it easier to see how resolution failures nest. - - - - - 53b3fa1c by Ben Gamari at 2022-05-13T12:11:09-04:00 rts/PEi386: Fix handling of weak symbols Previously we would flag the symbol as weak but failed to set its address, which must be computed from an "auxiliary" symbol entry the follows the weak symbol. Fixes #21556. - - - - - 5678f017 by Ben Gamari at 2022-05-13T12:11:09-04:00 testsuite: Add tests for #21556 - - - - - 49af0e52 by Ben Gamari at 2022-05-13T22:23:26-04:00 Re-export augment and build from GHC.List Resolves https://gitlab.haskell.org/ghc/ghc/-/issues/19127 - - - - - aed356e1 by Simon Peyton Jones at 2022-05-13T22:24:02-04:00 Comments only around HsWrapper - - - - - 27b90409 by Ben Gamari at 2022-05-16T08:30:44-04:00 hadrian: Introduce linting flavour transformer (+lint) The linting flavour enables -dlint uniformly across anything build by the stage1 compiler. -dcmm-lint is not currently enabled because it fails on i386 (see #21563) - - - - - 3f316776 by Matthew Pickering at 2022-05-16T08:30:44-04:00 hadrian: Uniformly enable -dlint with enableLinting transformer This fixes some bugs where * -dcore-lint was being passed when building stage1 libraries with the boot compiler * -dcore-lint was not being passed when building executables. Fixes #20135 - - - - - 3d74cfca by Andreas Klebinger at 2022-05-16T08:31:20-04:00 Make closure macros EXTERN_INLINE to make debugging easier Implements #21424. The RTS macros get_itbl and friends are extremely helpful during debugging. However only a select few of those were available in the compiled RTS as actual symbols as the rest were INLINE macros. This commit marks all of them as EXTERN_INLINE. This will still inline them at use sites but allow us to use their compiled counterparts during debugging. This allows us to use things like `p get_fun_itbl(ptr)` in the gdb shell since `get_fun_itbl` will now be available as symbol! - - - - - 93153aab by Matthew Pickering at 2022-05-16T08:31:55-04:00 packaging: Introduce CI job for generating hackage documentation This adds a CI job (hackage-doc-tarball) which generates the necessary tarballs for uploading libraries and documentation to hackage. The release script knows to download this folder and the upload script will also upload the release to hackage as part of the release. The `ghc_upload_libs` script is moved from ghc-utils into .gitlab/ghc_upload_libs There are two modes, preparation and upload. * The `prepare` mode takes a link to a bindist and creates a folder containing the source and doc tarballs ready to upload to hackage. * The `upload` mode takes the folder created by prepare and performs the upload to hackage. Fixes #21493 Related to #21512 - - - - - 65d31d05 by Simon Peyton Jones at 2022-05-16T15:32:50-04:00 Add arity to the INLINE pragmas for pattern synonyms The lack of INLNE arity was exposed by #21531. The fix is simple enough, if a bit clumsy. - - - - - 43c018aa by Krzysztof Gogolewski at 2022-05-16T15:33:25-04:00 Misc cleanup - Remove groupWithName (unused) - Use the RuntimeRepType synonym where possible - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM No functional changes. - - - - - 8dfea078 by Pavol Vargovcik at 2022-05-16T15:34:04-04:00 TcPlugin: access to irreducible givens + fix passed ev_binds_var - - - - - fb579e15 by Ben Gamari at 2022-05-17T00:25:02-04:00 driver: Introduce pgmcxx Here we introduce proper support for compilation of C++ objects. This includes: * logic in `configure` to detect the C++ toolchain and propagating this information into the `settings` file * logic in the driver to use the C++ toolchain when compiling C++ sources - - - - - 43628ed4 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Build T20918 with HC, not CXX - - - - - 0ef249aa by Ben Gamari at 2022-05-17T00:25:02-04:00 Introduce package to capture dependency on C++ stdlib Here we introduce a new "virtual" package into the initial package database, `system-cxx-std-lib`. This gives users a convenient, platform agnostic way to link against C++ libraries, addressing #20010. Fixes #20010. - - - - - 03efe283 by Ben Gamari at 2022-05-17T00:25:02-04:00 testsuite: Add tests for system-cxx-std-lib package Test that we can successfully link against C++ code both in GHCi and batch compilation. See #20010 - - - - - 5f6527e0 by nineonine at 2022-05-17T00:25:38-04:00 OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error for better disambiguation (#17420) - - - - - eccdb208 by Simon Peyton Jones at 2022-05-17T07:16:39-04:00 Adjust flags for pprTrace We were using defaultSDocContext for pprTrace, which suppresses lots of useful infomation. This small MR adds GHC.Utils.Outputable.traceSDocContext and uses it for pprTrace and pprTraceUserWarning. traceSDocContext is a global, and hence not influenced by flags, but that seems unavoidable. But I made the sdocPprDebug bit controlled by unsafeHasPprDebug, since we have the latter for exactly this purpose. Fixes #21569 - - - - - d2284c4c by Simon Peyton Jones at 2022-05-17T07:17:15-04:00 Fix bad interaction between withDict and the Specialiser This MR fixes a bad bug, where the withDict was inlined too vigorously, which in turn made the type-class Specialiser generate a bogus specialisation, because it saw the same overloaded function applied to two /different/ dictionaries. Solution: inline `withDict` later. See (WD8) of Note [withDict] in GHC.HsToCore.Expr See #21575, which is fixed by this change. - - - - - 70f52443 by Matthew Pickering at 2022-05-17T07:17:50-04:00 Bump time submodule to 1.12.2 This bumps the time submodule to the 1.12.2 release. Fixes #21571 - - - - - 2343457d by Vladislav Zavialov at 2022-05-17T07:18:26-04:00 Remove unused test files (#21582) Those files were moved to the perf/ subtree in 11c9a469, and then accidentally reintroduced in 680ef2c8. - - - - - cb52b4ae by Ben Gamari at 2022-05-17T16:00:14-04:00 CafAnal: Improve code clarity Here we implement a few measures to improve the clarity of the CAF analysis implementation. Specifically: * Use CafInfo instead of Bool since the former is more descriptive * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact CAFs * Add numerous comments - - - - - b048a9f4 by Ben Gamari at 2022-05-17T16:00:14-04:00 codeGen: Ensure that static datacon apps are included in SRTs When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT filters out recursive references, as described in Note [recursive SRTs]. However, doing so for static functions would be unsound, for the reason described in Note [Invalid optimisation: shortcutting]. However, the same argument applies to static data constructor applications, as we discovered in #20959. Fix this by ensuring that static data constructor applications are included in recursive SRTs. The approach here is not entirely satisfactory, but it is a starting point. Fixes #20959. - - - - - 0e2d16eb by Matthew Pickering at 2022-05-17T16:00:50-04:00 Add test for #21558 This is now fixed on master and 9.2 branch. Closes #21558 - - - - - ef3c8d9e by Sylvain Henry at 2022-05-17T20:22:02-04:00 Don't store LlvmConfig into DynFlags LlvmConfig contains information read from llvm-passes and llvm-targets files in GHC's top directory. Reading these files is done only when needed (i.e. when the LLVM backend is used) and cached for the whole compiler session. This patch changes the way this is done: - Split LlvmConfig into LlvmConfig and LlvmConfigCache - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no good reason to store it in DynFlags. As it is fixed per session, we store it in the session state instead (HscEnv). - Initializing LlvmConfigCache required some changes to driver functions such as newHscEnv. I've used the opportunity to untangle initHscEnv from initGhcMonad (in top-level GHC module) and to move it to GHC.Driver.Main, close to newHscEnv. - I've also made `cmmPipeline` independent of HscEnv in order to remove the call to newHscEnv in regalloc_unit_tests. - - - - - 828fbd8a by Andreas Klebinger at 2022-05-17T20:22:38-04:00 Give all EXTERN_INLINE closure macros prototypes - - - - - cfc8e2e2 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Introduce [sg]etFinalizerExceptionHandler This introduces a global hook which is called when an exception is thrown during finalization. - - - - - 372cf730 by Ben Gamari at 2022-05-19T04:57:51-04:00 base: Throw exceptions raised while closing finalized Handles Fixes #21336. - - - - - 3dd2f944 by Ben Gamari at 2022-05-19T04:57:51-04:00 testsuite: Add tests for #21336 - - - - - 297156e0 by Matthew Pickering at 2022-05-19T04:58:27-04:00 Add release flavour and use it for the release jobs The release flavour is essentially the same as the perf flavour currently but also enables `-haddock`. I have hopefully updated all the relevant places where the `-perf` flavour was hardcoded. Fixes #21486 - - - - - a05b6293 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Don't build sphinx documentation on centos The centos docker image lacks the sphinx builder so we disable building sphinx docs for these jobs. Fixes #21580 - - - - - 209d7c69 by Matthew Pickering at 2022-05-19T04:58:27-04:00 ci: Use correct syntax when args list is empty This seems to fail on the ancient version of bash present on CentOS - - - - - 02d16334 by Matthew Pickering at 2022-05-19T04:59:03-04:00 hadrian: Don't attempt to build dynamic profiling libraries We only support building static profiling libraries, the transformer was requesting things like a dynamic, threaded, debug, profiling RTS, which we have never produced nor distributed. Fixes #21567 - - - - - 35bdab1c by Ben Gamari at 2022-05-19T04:59:39-04:00 configure: Check CC_STAGE0 for --target support We previously only checked the stage 1/2 compiler for --target support. We got away with this for quite a while but it eventually caught up with us in #21579, where `bytestring`'s new NEON implementation was unbuildable on Darwin due to Rosetta's seemingly random logic for determining which executable image to execute. This lead to a confusing failure to build `bytestring`'s cbits, when `clang` tried to compile NEON builtins while targetting x86-64. Fix this by checking CC_STAGE0 for --target support. Fixes #21579. - - - - - 0ccca94b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator analysis of `CmmGraph` This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper around two existing algorithms in GHC: the Lengauer-Tarjan dominator analysis from the X86 back end and the reverse postorder ordering from the Cmm Dataflow framework. Issue #20726 proposes that we evaluate some alternatives for dominator analysis, but for the time being, the best path forward is simply to use the existing analysis on `CmmGraph`s. This commit addresses a bullet in #21200. - - - - - 54f0b578 by Norman Ramsey at 2022-05-20T05:32:32-04:00 add dominator-tree function - - - - - 05ed917b by Norman Ramsey at 2022-05-20T05:32:32-04:00 add HasDebugCallStack; remove unneeded extensions - - - - - 0b848136 by Andreas Klebinger at 2022-05-20T05:32:32-04:00 document fields of `DominatorSet` - - - - - 8a26e8d6 by Ben Gamari at 2022-05-20T05:33:08-04:00 nonmoving: Fix documentation of GC statistics fields These were previously incorrect. Fixes #21553. - - - - - c1e24e61 by Matthew Pickering at 2022-05-20T05:33:44-04:00 Remove pprTrace from pushCoercionIntoLambda (#21555) This firstly caused spurious output to be emitted (as evidenced by #21555) but even worse caused a massive coercion to be attempted to be printed (> 200k terms) which would invariably eats up all the memory of your computer. The good news is that removing this trace allows the program to compile to completion, the bad news is that the program exhibits a core lint error (on 9.0.2) but not any other releases it seems. Fixes #21577 and #21555 - - - - - a36d12ee by Zubin Duggal at 2022-05-20T10:44:35-04:00 docs: Fix LlvmVersion in manpage (#21280) - - - - - 36b8a57c by Matthew Pickering at 2022-05-20T10:45:10-04:00 validate: Use $make rather than make In the validate script we are careful to use the $make variable as this stores whether we are using gmake, make, quiet mode etc. There was just this one place where we failed to use it. Fixes #21598 - - - - - 4aa3c5bd by Norman Ramsey at 2022-05-21T03:11:04+00:00 Change `Backend` type and remove direct dependencies With this change, `Backend` becomes an abstract type (there are no more exposed value constructors). Decisions that were formerly made by asking "is the current back end equal to (or different from) this named value constructor?" are now made by interrogating the back end about its properties, which are functions exported by `GHC.Driver.Backend`. There is a description of how to migrate code using `Backend` in the user guide. Clients using the GHC API can find a backdoor to access the Backend datatype in GHC.Driver.Backend.Internal. Bumps haddock submodule. Fixes #20927 - - - - - ecf5f363 by Julian Ospald at 2022-05-21T12:51:16-04:00 Respect DESTDIR in hadrian bindist Makefile, fixes #19646 - - - - - 7edd991e by Julian Ospald at 2022-05-21T12:51:16-04:00 Test DESTDIR in test_hadrian() - - - - - ea895b94 by Matthew Pickering at 2022-05-22T21:57:47-04:00 Consider the stage of typeable evidence when checking stage restriction We were considering all Typeable evidence to be "BuiltinInstance"s which meant the stage restriction was going unchecked. In-fact, typeable has evidence and so we need to apply the stage restriction. This is complicated by the fact we don't generate typeable evidence and the corresponding DFunIds until after typechecking is concluded so we introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which records whether the evidence is going to be local or not. Fixes #21547 - - - - - ffbe28e5 by Dominik Peteler at 2022-05-22T21:58:23-04:00 Modularize GHC.Core.Opt.LiberateCase Progress towards #17957 - - - - - bc723ac2 by Simon Peyton Jones at 2022-05-23T17:09:34+01:00 Improve FloatOut and SpecConstr This patch addresses a relatively obscure situation that arose when chasing perf regressions in !7847, which itself is fixing It does two things: * SpecConstr can specialise on ($df d1 d2) dictionary arguments * FloatOut no longer checks argument strictness See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr. A test case is difficult to construct, but it makes a big difference in nofib/real/eff/VSM, at least when we have the patch for #21286 installed. (The latter stops worker/wrapper for dictionary arguments). There is a spectacular, but slightly illusory, improvement in runtime perf on T15426. I have documented the specifics in T15426 itself. Metric Decrease: T15426 - - - - - 1a4195b0 by John Ericson at 2022-05-23T17:33:59-04:00 Make debug a `Bool` not an `Int` in `StgToCmmConfig` We don't need any more resolution than this. Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer conveying any "level" information. - - - - - e9fff12b by Alan Zimmerman at 2022-05-23T21:04:49-04:00 EPA : Remove duplicate comments in DataFamInstD The code data instance Method PGMigration = MigrationQuery Query -- ^ Run a query against the database | MigrationCode (Connection -> IO (Either String ())) -- ^ Run any arbitrary IO code Resulted in two instances of the "-- ^ Run a query against the database" comment appearing in the Exact Print Annotations when it was parsed. Ensure only one is kept. Closes #20239 - - - - - e2520df3 by Alan Zimmerman at 2022-05-23T21:05:27-04:00 EPA: Comment Order Reversed Make sure comments captured in the exact print annotations are in order of increasing location Closes #20718 - - - - - 4b45fd72 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Add test for T21455 - - - - - e2cd1d43 by Teo Camarasu at 2022-05-24T10:49:13-04:00 Allow passing -po outside profiling way Resolves #21455 - - - - - 3b8c413a by Greg Steuck at 2022-05-24T10:49:52-04:00 Fix haddock_*_perf tests on non-GNU-grep systems Using regexp pattern requires `egrep` and straight up `+`. The haddock_parser_perf and haddock_renamer_perf tests now pass on OpenBSD. They previously incorrectly parsed the files and awk complained about invalid syntax. - - - - - 1db877a3 by Ben Gamari at 2022-05-24T10:50:28-04:00 hadrian/bindist: Drop redundant include of install.mk `install.mk` is already included by `config.mk`. Moreover, `install.mk` depends upon `config.mk` to set `RelocatableBuild`, making this first include incorrect. - - - - - f485d267 by Greg Steuck at 2022-05-24T10:51:08-04:00 Remove -z wxneeded for OpenBSD With all the recent W^X fixes in the loader this workaround is not necessary any longer. I verified that the only tests failing for me on OpenBSD 7.1-current are the same (libc++ related) before and after this commit (with --fast). - - - - - 7c51177d by Andreas Klebinger at 2022-05-24T22:13:19-04:00 Use UnionListsOrd instead of UnionLists in most places. This should get rid of most, if not all "Overlong lists" errors and fix #20016 - - - - - 81b3741f by Andreas Klebinger at 2022-05-24T22:13:55-04:00 Fix #21563 by using Word64 for 64bit shift code. We use the 64bit shifts only on 64bit platforms. But we compile the code always so compiling it on 32bit caused a lint error. So use Word64 instead. - - - - - 2c25fff6 by Zubin Duggal at 2022-05-24T22:14:30-04:00 Fix compilation with -haddock on GHC <= 8.10 -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors when it encounters invalid haddock syntax. This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b enabled -haddock by default on many flavours. Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem managed to slip throught the cracks. - - - - - cfb9faff by sheaf at 2022-05-24T22:15:12-04:00 Hadrian: don't add "lib" for relocatable builds The conditional in hadrian/bindist/Makefile depended on the target OS, but it makes more sense to use whether we are using a relocatable build. (Currently this only gets set to true on Windows, but this ensures that the logic stays correctly coupled.) - - - - - 9973c016 by Andre Marianiello at 2022-05-25T01:36:09-04:00 Remove HscEnv from GHC.HsToCore.Usage (related to #17957) Metric Decrease: T16875 - - - - - 2ff18e39 by sheaf at 2022-05-25T01:36:48-04:00 SimpleOpt: beta-reduce through casts The simple optimiser would sometimes fail to beta-reduce a lambda when there were casts in between the lambda and its arguments. This can cause problems because we rely on representation-polymorphic lambdas getting beta-reduced away (for example, those that arise from newtype constructors with representation-polymorphic arguments, with UnliftedNewtypes). - - - - - e74fc066 by CarrieMY at 2022-05-25T16:43:03+02:00 Desugar RecordUpd in `tcExpr` This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule - - - - - 2b8bdab8 by Eric Lindblad at 2022-05-26T03:21:58-04:00 update README - - - - - 3d7e7e84 by BinderDavid at 2022-05-26T03:22:38-04:00 Replace dead link in Haddock documentation of Control.Monad.Fail (fixes #21602) - - - - - ee61c7f9 by John Ericson at 2022-05-26T03:23:13-04:00 Add Haddocks for `WwOpts` - - - - - da5ccf0e by Dominik Peteler at 2022-05-26T03:23:13-04:00 Avoid global compiler state for `GHC.Core.Opt.WorkWrap` Progress towards #17957 - - - - - 3bd975b4 by sheaf at 2022-05-26T03:23:52-04:00 Optimiser: avoid introducing bad rep-poly The functions `pushCoValArg` and `pushCoercionIntoLambda` could introduce bad representation-polymorphism. Example: type RR :: RuntimeRep type family RR where { RR = IntRep } type F :: TYPE RR type family F where { F = Int# } co = GRefl F (TYPE RR[0]) :: (F :: TYPE RR) ~# (F |> TYPE RR[0] :: TYPE IntRep) f :: F -> () `pushCoValArg` would transform the unproblematic application (f |> (co -> <()>)) (arg :: F |> TYPE RR[0]) into an application in which the argument does not have a fixed `RuntimeRep`: f ((arg |> sym co) :: (F :: TYPE RR)) - - - - - b22979fb by Fraser Tweedale at 2022-05-26T06:14:51-04:00 executablePath test: fix file extension treatment The executablePath test strips the file extension (if any) when comparing the query result with the expected value. This is to handle platforms where GHC adds a file extension to the output program file (e.g. .exe on Windows). After the initial check, the file gets deleted (if supported). However, it tries to delete the *stripped* filename, which is incorrect. The test currently passes only because Windows does not allow deleting the program while any process created from it is alive. Make the test program correct in general by deleting the *non-stripped* executable filename. - - - - - afde4276 by Fraser Tweedale at 2022-05-26T06:14:51-04:00 fix executablePath test for NetBSD executablePath support for NetBSD was added in a172be07e3dce758a2325104a3a37fc8b1d20c9c, but the test was not updated. Update the test so that it works for NetBSD. This requires handling some quirks: - The result of getExecutablePath could include "./" segments. Therefore use System.FilePath.equalFilePath to compare paths. - The sysctl(2) call returns the original executable name even after it was deleted. Add `canQueryAfterDelete :: [FilePath]` and adjust expectations for the post-delete query accordingly. Also add a note to the `executablePath` haddock to advise that NetBSD behaves differently from other OSes when the file has been deleted. Also accept a decrease in memory usage for T16875. On Windows, the metric is -2.2% of baseline, just outside the allowed ±2%. I don't see how this commit could have influenced this metric, so I suppose it's something in the CI environment. Metric Decrease: T16875 - - - - - d0e4355a by John Ericson at 2022-05-26T06:15:30-04:00 Factor out `initArityOps` to `GHC.Driver.Config.*` module We want `DynFlags` only mentioned in `GHC.Driver`. - - - - - 44bb7111 by romes at 2022-05-26T16:27:57+00:00 TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hs - - - - - 88e58600 by sheaf at 2022-05-26T17:38:43-04:00 Add tests for eta-expansion of data constructors This patch adds several tests relating to the eta-expansion of data constructors, including UnliftedNewtypes and DataTypeContexts. - - - - - d87530bb by Richard Eisenberg at 2022-05-26T23:20:14-04:00 Generalize breakTyVarCycle to work with TyFamLHS The function breakTyVarCycle_maybe has been installed in a dark corner of GHC to catch some gremlins (a.k.a. occurs-check failures) who lurk there. But it previously only caught gremlins of the form (a ~ ... F a ...), where some of our intrepid users have spawned gremlins of the form (G a ~ ... F (G a) ...). This commit improves breakTyVarCycle_maybe (and renames it to breakTyEqCycle_maybe) to catch the new gremlins. Happily, the change is remarkably small. The gory details are in Note [Type equality cycles]. Test cases: typecheck/should_compile/{T21515,T21473}. - - - - - ed37027f by Hécate Moonlight at 2022-05-26T23:20:52-04:00 [base] Fix the links in the Data.Data module fix #21658 fix #21657 fix #21657 - - - - - 3bd7d5d6 by Krzysztof Gogolewski at 2022-05-27T16:44:48+02:00 Use a class to check validity of withDict This moves handling of the magic 'withDict' function from the desugarer to the typechecker. Details in Note [withDict]. I've extracted a part of T16646Fail to a separate file T16646Fail2, because the new error in 'reify' hides the errors from 'f' and 'g'. WithDict now works with casts, this fixes #21328. Part of #19915 - - - - - b54f6c4f by sheaf at 2022-05-28T21:00:09-04:00 Fix FreeVars computation for mdo Commit acb188e0 introduced a regression in the computation of free variables in mdo statements, as the logic in GHC.Rename.Expr.segmentRecStmts was slightly different depending on whether the recursive do block corresponded to an mdo statement or a rec statment. This patch restores the previous computation for mdo blocks. Fixes #21654 - - - - - 0704295c by Matthew Pickering at 2022-05-28T21:00:45-04:00 T16875: Stabilise (temporarily) by increasing acceptance threshold The theory is that on windows there is some difference in the environment between pipelines on master and merge requests which affects all tests equally but because T16875 barely allocates anything it is the test which is affected the most. See #21557 - - - - - 6341c8ed by Matthew Pickering at 2022-05-28T21:01:20-04:00 make: Fix make maintainer-clean deleting a file tracked by source control Fixes #21659 - - - - - fbf2f254 by Bodigrim at 2022-05-28T21:01:58-04:00 Expand documentation of hIsTerminalDevice - - - - - 0092c67c by Teo Camarasu at 2022-05-29T12:25:39+00:00 export IsList from GHC.IsList it is still re-exported from GHC.Exts - - - - - 91396327 by Sylvain Henry at 2022-05-30T09:40:55-04:00 MachO linker: fix handling of ARM64_RELOC_SUBTRACTOR ARM64_RELOC_SUBTRACTOR relocations are paired with an AMR64_RELOC_UNSIGNED relocation to implement: addend + sym1 - sym2 The linker was doing it in two steps, basically: *addend <- *addend - sym2 *addend <- *addend + sym1 The first operation was likely to overflow. For example when the relocation target was 32-bit and both sym1/sym2 were 64-bit addresses. With the small memory model, (sym1-sym2) would fit in 32 bits but (*addend-sym2) may not. Now the linker does it in one step: *addend <- *addend + sym1 - sym2 - - - - - acc26806 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Some fixes to SRT documentation - reordered the 3 SRT implementation cases from the most general to the most specific one: USE_SRT_POINTER -> USE_SRT_OFFSET -> USE_INLINE_SRT_FIELD - added requirements for each - found and documented a confusion about "SRT inlining" not supported with MachO. (It is fixed in the following commit) - - - - - 5878f439 by Sylvain Henry at 2022-05-30T09:40:55-04:00 Enable USE_INLINE_SRT_FIELD on ARM64 It was previously disabled because of: - a confusion about "SRT inlining" (see removed comment in this commit) - a linker bug (overflow) in the handling of ARM64_RELOC_SUBTRACTOR relocation: fixed by a previous commit. - - - - - 59bd6159 by Matthew Pickering at 2022-05-30T09:41:39-04:00 ci: Make sure to exit promptly if `make install` fails. Due to the vageries of bash, you have to explicitly handle the failure and exit when in a function. This failed to exit promptly when !8247 was failing. See #21358 for the general issue - - - - - 5a5a28da by Sylvain Henry at 2022-05-30T09:42:23-04:00 Split GHC.HsToCore.Foreign.Decl This is preliminary work for JavaScript support. It's better to put the code handling the desugaring of Prim, C and JavaScript declarations into separate modules. - - - - - 6f5ff4fa by Sylvain Henry at 2022-05-30T09:43:05-04:00 Bump hadrian to LTS-19.8 (GHC 9.0.2) - - - - - f2e70707 by Sylvain Henry at 2022-05-30T09:43:05-04:00 Hadrian: remove unused code - - - - - 2f215b9f by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Eta reduction with casted function We want to be able to eta-reduce \x y. ((f x) |> co) y by pushing 'co' inwards. A very small change accommodates this See Note [Eta reduction with casted function] - - - - - f4f6a87a by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Do arity trimming at bindings, rather than in exprArity Sometimes there are very large casts, and coercionRKind can be slow. - - - - - 610a2b83 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make findRhsArity take RecFlag This avoids a fixpoint iteration for the common case of non-recursive bindings. - - - - - 80ba50c7 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Comments and white space - - - - - 0079171b by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 Make PrimOpId record levity This patch concerns #20155, part (1) The general idea is that since primops have curried bindings (currently in PrimOpWrappers.hs) we don't need to eta-expand them. But we /do/ need to eta-expand the levity-polymorphic ones, because they /don't/ have bindings. This patch makes a start in that direction, by identifying the levity-polymophic primops in the PrimOpId IdDetails constructor. For the moment, I'm still eta-expanding all primops (by saying that hasNoBinding returns True for all primops), because of the bug reported in #20155. But I hope that before long we can tidy that up too, and remove the TEMPORARILY stuff in hasNoBinding. - - - - - 6656f016 by Simon Peyton Jones at 2022-05-30T13:44:14-04:00 A bunch of changes related to eta reduction This is a large collection of changes all relating to eta reduction, originally triggered by #18993, but there followed a long saga. Specifics: * Move state-hack stuff from GHC.Types.Id (where it never belonged) to GHC.Core.Opt.Arity (which seems much more appropriate). * Add a crucial mkCast in the Cast case of GHC.Core.Opt.Arity.eta_expand; helps with T18223 * Add clarifying notes about eta-reducing to PAPs. See Note [Do not eta reduce PAPs] * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity, where it properly belongs. See Note [Eta reduce PAPs] * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for when eta-expansion is wanted, to make wantEtaExpansion, and all that same function in GHC.Core.Opt.Simplify.simplStableUnfolding. It was previously inconsistent, but it's doing the same thing. * I did a substantial refactor of ArityType; see Note [ArityType]. This allowed me to do away with the somewhat mysterious takeOneShots; more generally it allows arityType to describe the function, leaving its clients to decide how to use that information. I made ArityType abstract, so that clients have to use functions to access it. * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called mkLam before) aware of the floats that the simplifier builds up, so that it can still do eta-reduction even if there are some floats. (Previously that would not happen.) That means passing the floats to rebuildLam, and an extra check when eta-reducting (etaFloatOk). * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info in the idDemandInfo of the binder, as well as the CallArity info. The occurrence analyser did this but we were failing to take advantage here. In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity; see Note [Combining arityType with demand info], and functions idDemandOneShots and combineWithDemandOneShots. (These changes partly drove my refactoring of ArityType.) * In GHC.Core.Opt.Arity.findRhsArity * I'm now taking account of the demand on the binder to give extra one-shot info. E.g. if the fn is always called with two args, we can give better one-shot info on the binders than if we just look at the RHS. * Don't do any fixpointing in the non-recursive case -- simple short cut. * Trim arity inside the loop. See Note [Trim arity inside the loop] * Make SimpleOpt respect the eta-reduction flag (Some associated refactoring here.) * I made the CallCtxt which the Simplifier uses distinguish between recursive and non-recursive right-hand sides. data CallCtxt = ... | RhsCtxt RecFlag | ... It affects only one thing: - We call an RHS context interesting only if it is non-recursive see Note [RHS of lets] in GHC.Core.Unfold * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification. See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep. Other incidental changes * Fix a fairly long-standing outright bug in the ApplyToVal case of GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the tail of 'dmds' in the recursive call, which meant the demands were All Wrong. I have no idea why this has not caused problems before now. * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg Metrics: compile_time/bytes allocated Test Metric Baseline New value Change --------------------------------------------------------------------------------------- MultiLayerModulesTH_OneShot(normal) ghc/alloc 2,743,297,692 2,619,762,992 -4.5% GOOD T18223(normal) ghc/alloc 1,103,161,360 972,415,992 -11.9% GOOD T3064(normal) ghc/alloc 201,222,500 184,085,360 -8.5% GOOD T8095(normal) ghc/alloc 3,216,292,528 3,254,416,960 +1.2% T9630(normal) ghc/alloc 1,514,131,032 1,557,719,312 +2.9% BAD parsing001(normal) ghc/alloc 530,409,812 525,077,696 -1.0% geo. mean -0.1% Nofib: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- banner +0.0% +0.4% -8.9% -8.7% 0.0% exact-reals +0.0% -7.4% -36.3% -37.4% 0.0% fannkuch-redux +0.0% -0.1% -1.0% -1.0% 0.0% fft2 -0.1% -0.2% -17.8% -19.2% 0.0% fluid +0.0% -1.3% -2.1% -2.1% 0.0% gg -0.0% +2.2% -0.2% -0.1% 0.0% spectral-norm +0.1% -0.2% 0.0% 0.0% 0.0% tak +0.0% -0.3% -9.8% -9.8% 0.0% x2n1 +0.0% -0.2% -3.2% -3.2% 0.0% -------------------------------------------------------------------------------- Min -3.5% -7.4% -58.7% -59.9% 0.0% Max +0.1% +2.2% +32.9% +32.9% 0.0% Geometric Mean -0.0% -0.1% -14.2% -14.8% -0.0% Metric Decrease: MultiLayerModulesTH_OneShot T18223 T3064 T15185 T14766 Metric Increase: T9630 - - - - - cac8c7bb by Matthew Pickering at 2022-05-30T13:44:50-04:00 hadrian: Fix building from source-dist without alex/happy This fixes two bugs which were adding dependencies on alex/happy when building from a source dist. * When we try to pass `--with-alex` and `--with-happy` to cabal when configuring but the builders are not set. This is fixed by making them optional. * When we configure, cabal requires alex/happy because of the build-tool-depends fields. These are now made optional with a cabal flag (build-tool-depends) for compiler/hpc-bin/genprimopcode. Fixes #21627 - - - - - a96dccfe by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test the bootstrap without ALEX/HAPPY on path - - - - - 0e5bb3a8 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Test bootstrapping in release jobs - - - - - d8901469 by Matthew Pickering at 2022-05-30T13:44:50-04:00 ci: Allow testing bootstrapping on MRs using the "test-bootstrap" label - - - - - 18326ad2 by Matthew Pickering at 2022-05-30T13:45:25-04:00 rts: Remove explicit timescale for deprecating -h flag We originally planned to remove the flag in 9.4 but there's actually no great rush to do so and it's probably less confusing (forever) to keep the message around suggesting an explicit profiling option. Fixes #21545 - - - - - eaaa1389 by Matthew Pickering at 2022-05-30T13:46:01-04:00 Enable -dlint in hadrian lint transformer Now #21563 is fixed we can properly enable `-dlint` in CI rather than a subset of the flags. - - - - - 0544f114 by Ben Gamari at 2022-05-30T19:16:55-04:00 upload-ghc-libs: Allow candidate-only upload - - - - - 83467435 by Sylvain Henry at 2022-05-30T19:17:35-04:00 Avoid using DynFlags in GHC.Linker.Unit (#17957) - - - - - 5c4421b1 by Matthew Pickering at 2022-05-31T08:35:17-04:00 hadrian: Introduce new package database for executables needed to build stage0 These executables (such as hsc2hs) are built using the boot compiler and crucially, most libraries from the global package database. We also move other build-time executables to be built in this stage such as linters which also cleans up which libraries end up in the global package database. This allows us to remove hacks where linters-common is removed from the package database when a bindist is created. This fixes issues caused by infinite recursion due to bytestring adding a dependency on template-haskell. Fixes #21634 - - - - - 0dafd3e7 by Matthew Pickering at 2022-05-31T08:35:17-04:00 Build stage1 with -V as well This helps tracing errors which happen when building stage1 - - - - - 15d42a7a by Matthew Pickering at 2022-05-31T08:35:52-04:00 Revert "packaging: Build perf builds with -split-sections" This reverts commit 699f593532a3cd5ca1c2fab6e6e4ce9d53be2c1f. Split sections causes segfaults in profiling way with old toolchains (deb9) and on windows (#21670) Fixes #21670 - - - - - d4c71f09 by John Ericson at 2022-05-31T16:26:28+00:00 Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard Progress towards #17957 Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other modules as thoroughly as I usually do. This does mean that risk of `DynFlags` "creeping back in" is higher than it usually is. After we do the same process to the other Core passes, and then figure out what we want to do about `CoreM`, we can finish the job started here. That is a good deal more work, however, so it certainly makes sense to land this now. - - - - - a720322f by romes at 2022-06-01T07:44:44-04:00 Restore Note [Quasi-quote overview] - - - - - 392ce3fc by romes at 2022-06-01T07:44:44-04:00 Move UntypedSpliceFlavour from L.H.S to GHC.Hs UntypedSpliceFlavour was only used in the client-specific `GHC.Hs.Expr` but was defined in the client-independent L.H.S.Expr. - - - - - 7975202b by romes at 2022-06-01T07:44:44-04:00 TTG: Rework and improve splices This commit redefines the structure of Splices in the AST. We get rid of `HsSplice` which used to represent typed and untyped splices, quasi quotes, and the result of splicing either an expression, a type or a pattern. Instead we have `HsUntypedSplice` which models an untyped splice or a quasi quoter, which works in practice just like untyped splices. The `HsExpr` constructor `HsSpliceE` which used to be constructed with an `HsSplice` is split into `HsTypedSplice` and `HsUntypedSplice`. The former is directly constructed with an `HsExpr` and the latter now takes an `HsUntypedSplice`. Both `HsType` and `Pat` constructors `HsSpliceTy` and `SplicePat` now take an `HsUntypedSplice` instead of a `HsSplice` (remember only /untyped splices/ can be spliced as types or patterns). The result of splicing an expression, type, or pattern is now comfortably stored in the extension fields `XSpliceTy`, `XSplicePat`, `XUntypedSplice` as, respectively, `HsUntypedSpliceResult (HsType GhcRn)`, `HsUntypedSpliceResult (Pat GhcRn)`, and `HsUntypedSpliceResult (HsExpr GhcRn)` Overall the TTG extension points are now better used to make invalid states unrepresentable and model the progression between stages better. See Note [Lifecycle of an untyped splice, and PendingRnSplice] and Note [Lifecycle of an typed splice, and PendingTcSplice] for more details. Updates haddock submodule Fixes #21263 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - 320270c2 by Matthew Pickering at 2022-06-01T07:44:44-04:00 Add test for #21619 Fixes #21619 - - - - - ef7ddd73 by Pierre Le Marre at 2022-06-01T07:44:47-04:00 Pure Haskell implementation of GHC.Unicode Switch to a pure Haskell implementation of base:GHC.Unicode, based on the implementation of the package unicode-data (https://github.com/composewell/unicode-data/). Approved by CLC as per https://github.com/haskell/core-libraries-committee/issues/59#issuecomment-1132106691. - Remove current Unicode cbits. - Add generator for Unicode property files from Unicode Character Database. - Generate internal modules. - Update GHC.Unicode. - Add unicode003 test for general categories and case mappings. - Add Python scripts to check 'base' Unicode tests outputs and characters properties. Fixes #21375 ------------------------- Metric Decrease: T16875 Metric Increase: T4029 T18304 haddock.base ------------------------- - - - - - 514a6a28 by Eric Lindblad at 2022-06-01T07:44:51-04:00 typos - - - - - 9004be3c by Matthew Pickering at 2022-06-01T07:44:52-04:00 source-dist: Copy in files created by ./boot Since we started producing source dists with hadrian we stopped copying in the files created by ./boot which adds a dependency on python3 and autoreconf. This adds back in the files which were created by running configure. Fixes #21673 #21672 and #21626 - - - - - a12a3cab by Matthew Pickering at 2022-06-01T07:44:52-04:00 ci: Don't try to run ./boot when testing bootstrap of source dist - - - - - e07f9059 by Shlomo Shuck at 2022-06-01T07:44:55-04:00 Language.Haskell.Syntax: Fix docs for PromotedConsT etc. Fixes ghc/ghc#21675. - - - - - 87295e6d by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump bytestring, process, and text submodules Metric Decrease: T5631 Metric Increase: T18223 (cherry picked from commit 55fcee30cb3281a66f792e8673967d64619643af) - - - - - 24b5bb61 by Ben Gamari at 2022-06-01T07:44:56-04:00 Bump Cabal submodule To current `master`. (cherry picked from commit fbb59c212415188486aafd970eafef170516356a) - - - - - 5433a35e by Matthew Pickering at 2022-06-01T22:26:30-04:00 hadrian/tool-args: Write output to intermediate file rather than via stdout This allows us to see the output of hadrian while it is doing the setup. - - - - - 468f919b by Matthew Pickering at 2022-06-01T22:27:10-04:00 Make -fcompact-unwind the default This is a follow-up to !7247 (closed) making the inclusion of compact unwinding sections the default. Also a slight refactoring/simplification of the flag handling to add -fno-compact-unwind. - - - - - 819fdc61 by Zubin Duggal at 2022-06-01T22:27:47-04:00 hadrian bootstrap: add plans for 9.0.2 and 9.2.3 - - - - - 9fa790b4 by Zubin Duggal at 2022-06-01T22:27:47-04:00 ci: Add matrix for bootstrap sources - - - - - ce9f986b by John Ericson at 2022-06-02T15:42:59+00:00 HsToCore.Coverage: Improve haddocks - - - - - f065804e by John Ericson at 2022-06-02T15:42:59+00:00 Hoist auto `mkModBreaks` and `writeMixEntries` conditions to caller No need to inline traversing a maybe for `mkModBreaks`. And better to make each function do one thing and let the caller deside when than scatter the decision making and make the caller seem more imperative. - - - - - d550d907 by John Ericson at 2022-06-02T15:42:59+00:00 Rename `HsToCore.{Coverage -> Ticks}` The old name made it confusing why disabling HPC didn't disable the entire pass. The name makes it clear --- there are other reasons to add ticks in addition. - - - - - 6520da95 by John Ericson at 2022-06-02T15:42:59+00:00 Split out `GHC.HsToCore.{Breakpoints,Coverage}` and use `SizedSeq` As proposed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_432877 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7508#note_434676, `GHC.HsToCore.Ticks` is about ticks, breakpoints are separate and backend-specific (only for the bytecode interpreter), and mix entry writing is just for HPC. With this split we separate out those interpreter- and HPC-specific its, and keep the main `GHC.HsToCore.Ticks` agnostic. Also, instead of passing the reversed list and count around, we use `SizedSeq` which abstracts over the algorithm. This is much nicer to avoid noise and prevents bugs. (The bugs are not just hypothetical! I missed up the reverses on an earlier draft of this commit.) - - - - - 1838c3d8 by Sylvain Henry at 2022-06-02T15:43:14+00:00 GHC.HsToCore.Breakpoints: Slightly improve perf We have the length already, so we might as well use that rather than O(n) recomputing it. - - - - - 5a3fdcfd by John Ericson at 2022-06-02T15:43:59+00:00 HsToCore.Coverage: Purge DynFlags Finishes what !7467 (closed) started. Progress towards #17957 - - - - - 9ce9ea50 by HaskellMouse at 2022-06-06T09:50:00-04:00 Deprecate TypeInType extension This commit fixes #20312 It deprecates "TypeInType" extension according to the following proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0083-no-type-in-type.rst It has been already implemented. The migration strategy: 1. Disable TypeInType 2. Enable both DataKinds and PolyKinds extensions Metric Decrease: T16875 - - - - - f2e037fd by Aaron Allen at 2022-06-06T09:50:39-04:00 Diagnostics conversions, part 6 (#20116) Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors in `GHC.Tc.Gen.Match`, `GHC.Tc.Gen.Pat`, and `GHC.Tc.Gen.Sig`. - - - - - 04209f2a by Simon Peyton Jones at 2022-06-06T09:51:15-04:00 Ensure floated dictionaries are in scope (again) In the Specialiser, we missed one more call to bringFloatedDictsIntoScope (see #21391). This omission led to #21689. The problem is that the call to `rewriteClassOps` needs to have in scope any dictionaries floated out of the arguments we have just specialised. Easy fix. - - - - - a7fece19 by John Ericson at 2022-06-07T05:04:22+00:00 Don't print the number of deps in count-deps tests It is redundant information and a source of needless version control conflicts when multiple MRs are changing the deps list. Just printing the list and not also its length is fine. - - - - - a1651a3a by John Ericson at 2022-06-07T05:06:38+00:00 Core.Lint: Reduce `DynFlags` and `HscEnv` Co-Authored-By: Andre Marianiello <andremarianiello at users.noreply.github.com> - - - - - 56ebf9a5 by Andreas Klebinger at 2022-06-09T09:11:43-04:00 Fix a CSE shadowing bug. We used to process the rhs of non-recursive bindings and their body using the same env. If we had something like let x = ... x ... this caused trouble because the two xs refer to different binders but we would substitute both for a new binder x2 causing out of scope errors. We now simply use two different envs for the rhs and body in cse_bind. It's all explained in the Note [Separate envs for let rhs and body] Fixes #21685 - - - - - 28880828 by sheaf at 2022-06-09T09:12:19-04:00 Typecheck remaining ValArgs in rebuildHsApps This patch refactors hasFixedRuntimeRep_remainingValArgs, renaming it to tcRemainingValArgs. The logic is moved to rebuildHsApps, which ensures consistent behaviour across tcApp and quickLookArg1/tcEValArg. This patch also refactors the treatment of stupid theta for data constructors, changing the place we drop stupid theta arguments from dsConLike to mkDataConRep (now the datacon wrapper drops these arguments). We decided not to implement PHASE 2 of the FixedRuntimeRep plan for these remaining ValArgs. Future directions are outlined on the wiki: https://gitlab.haskell.org/ghc/ghc/-/wikis/Remaining-ValArgs Fixes #21544 and #21650 - - - - - 1fbba97b by Matthew Pickering at 2022-06-09T09:12:54-04:00 Add test for T21682 Fixes #21682 - - - - - 8727be73 by Andreas Klebinger at 2022-06-09T09:13:29-04:00 Document dataToTag# primop - - - - - 7eab75bb by uhbif19 at 2022-06-09T20:22:47+03:00 Remove TcRnUnknownMessage usage from GHC.Rename.Env #20115 - - - - - 46d2fc65 by uhbif19 at 2022-06-09T20:24:40+03:00 Fix TcRnPragmaWarning meaning - - - - - 69e72ecd by Matthew Pickering at 2022-06-09T19:07:01-04:00 getProcessCPUTime: Fix the getrusage fallback to account for system CPU time clock_gettime reports the combined total or user AND system time so in order to replicate it with getrusage we need to add both system and user time together. See https://stackoverflow.com/questions/7622371/getrusage-vs-clock-gettime Some sample measurements when building Cabal with this patch t1: rusage t2: clock_gettime t1: 62347518000; t2: 62347520873 t1: 62395687000; t2: 62395690171 t1: 62432435000; t2: 62432437313 t1: 62478489000; t2: 62478492465 t1: 62514990000; t2: 62514992534 t1: 62515479000; t2: 62515480327 t1: 62515485000; t2: 62515486344 Fixes #21656 - - - - - 722814ba by Yiyun Liu at 2022-06-10T21:23:03-04:00 Use <br> instead of newline character - - - - - dc202080 by Matthew Craven at 2022-06-13T14:07:12-04:00 Use (fixed_lev = True) in mkDataTyConRhs - - - - - ad70c621 by Matthew Pickering at 2022-06-14T08:40:53-04:00 hadrian: Fix testing stage1 compiler There were various issues with testing the stage1 compiler.. 1. The wrapper was not being built 2. The wrapper was picking up the stage0 package database and trying to load prelude from that. 3. The wrappers never worked on windows so just don't support that for now. Fixes #21072 - - - - - ac83899d by Ben Gamari at 2022-06-14T08:41:30-04:00 validate: Ensure that $make variable is set Currently the `$make` variable is used without being set in `validate`'s Hadrian path, which uses make to install the binary distribution. Fix this. Fixes #21687. - - - - - 59bc6008 by John Ericson at 2022-06-15T18:05:35+00:00 CoreToStg.Prep: Get rid of `DynFlags` and `HscEnv` The call sites in `Driver.Main` are duplicative, but this is good, because the next step is to remove `InteractiveContext` from `Core.Lint` into `Core.Lint.Interactive`. Also further clean up `Core.Lint` to use a better configuration record than the one we initially added. - - - - - aa9d9381 by Ben Gamari at 2022-06-15T20:33:04-04:00 hadrian: Run xattr -rc . on bindist tarball Fixes #21506. - - - - - cdc75a1f by Ben Gamari at 2022-06-15T20:33:04-04:00 configure: Hide spurious warning from ld Previously the check_for_gold_t22266 configure check could result in spurious warnings coming from the linker being blurted to stderr. Suppress these by piping stderr to /dev/null. - - - - - e128b7b8 by Ben Gamari at 2022-06-15T20:33:40-04:00 cmm: Add surface syntax for MO_MulMayOflo - - - - - bde65ea9 by Ben Gamari at 2022-06-15T20:34:16-04:00 configure: Don't attempt to override linker on Darwin Configure's --enable-ld-override functionality is intended to ensure that we don't rely on ld.bfd, which tends to be slow and buggy, on Linux and Windows. However, on Darwin the lack of sensible package management makes it extremely easy for users to have awkward mixtures of toolchain components from, e.g., XCode, the Apple Command-Line Tools package, and homebrew. This leads to extremely confusing problems like #21712. Here we avoid this by simply giving up on linker selection on Darwin altogether. This isn't so bad since the Apple ld64 linker has decent performance and AFAICT fairly reliable. Closes #21712. - - - - - 25b510c3 by Torsten Schmits at 2022-06-16T12:37:45-04:00 replace quadratic nub to fight byte code gen perf explosion Despite this code having been present in the core-to-bytecode implementation, I have observed it in the wild starting with 9.2, causing enormous slowdown in certain situations. My test case produces the following profiles: Before: ``` total time = 559.77 secs (559766 ticks @ 1000 us, 1 processor) total alloc = 513,985,665,640 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes elem_by Data.OldList libraries/base/Data/OldList.hs:429:1-7 67.6 92.9 378282 477447404296 eqInt GHC.Classes libraries/ghc-prim/GHC/Classes.hs:275:8-14 12.4 0.0 69333 32 $c>>= GHC.Data.IOEnv <no location info> 6.9 0.6 38475 3020371232 ``` After: ``` total time = 89.83 secs (89833 ticks @ 1000 us, 1 processor) total alloc = 39,365,306,360 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc ticks bytes $c>>= GHC.Data.IOEnv <no location info> 43.6 7.7 39156 3020403424 doCase GHC.StgToByteCode compiler/GHC/StgToByteCode.hs:(805,1)-(1054,53) 2.5 7.4 2246 2920777088 ``` - - - - - aa7e1f20 by Matthew Pickering at 2022-06-16T12:38:21-04:00 hadrian: Don't install `include/` directory in bindist. The install_includes for the RTS package used to be put in the top-level ./include folder but this would lead to confusing things happening if you installed multiple GHC versions side-by-side. We don't need this folder anymore because install-includes is honoured properly by cabal and the relevant header files already copied in by the cabal installation process. If you want to depend on the header files for the RTS in a Haskell project then you just have to depend on the `rts` package and the correct include directories will be provided for you. If you want to depend on the header files in a standard C project then you should query ghc-pkg to get the right paths. ``` ghc-pkg field rts include-dirs --simple-output ``` Fixes #21609 - - - - - 03172116 by Bryan Richter at 2022-06-16T12:38:57-04:00 Enable eventlogs on nightly perf job - - - - - ecbf8685 by Hécate Moonlight at 2022-06-16T16:30:00-04:00 Repair dead link in TH haddocks Closes #21724 - - - - - 99ff3818 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian: allow configuring Hsc2Hs This patch adds the ability to pass options to Hsc2Hs as Hadrian key/value settings, in the same way as cabal configure options, using the syntax: *.*.hsc2hs.run.opts += ... - - - - - 9c575f24 by sheaf at 2022-06-16T16:30:39-04:00 Hadrian bootstrap: look up hsc2hs Hadrian bootstrapping looks up where to find ghc_pkg, but the same logic was not in place for hsc2hs which meant we could fail to find the appropriate hsc2hs executabe when bootstrapping Hadrian. This patch adds that missing logic. - - - - - 229d741f by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Add (broken) test for #21622 - - - - - cadd7753 by Ben Gamari at 2022-06-18T10:42:54-04:00 ghc-heap: Don't Box NULL pointers Previously we could construct a `Box` of a NULL pointer from the `link` field of `StgWeak`. Now we take care to avoid ever introducing such pointers in `collect_pointers` and ensure that the `link` field is represented as a `Maybe` in the `Closure` type. Fixes #21622 - - - - - 31c214cc by Tamar Christina at 2022-06-18T10:43:34-04:00 winio: Add support to console handles to handleToHANDLE - - - - - 711cb417 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Add SMUL[LH] instructions These will be needed to fix #21624. - - - - - d05d90d2 by Ben Gamari at 2022-06-18T10:44:11-04:00 CmmToAsm/AArch64: Fix syntax of OpRegShift operands Previously this produced invalid assembly containing a redundant comma. - - - - - a1e1d8ee by Ben Gamari at 2022-06-18T10:44:11-04:00 ncg/aarch64: Fix implementation of IntMulMayOflo The code generated for IntMulMayOflo was previously wrong as it depended upon the overflow flag, which the AArch64 MUL instruction does not set. Fix this. Fixes #21624. - - - - - 26745006 by Ben Gamari at 2022-06-18T10:44:11-04:00 testsuite: Add test for #21624 Ensuring that mulIntMayOflo# behaves as expected. - - - - - 94f2e92a by Sebastian Graf at 2022-06-20T09:40:58+02:00 CprAnal: Set signatures of DFuns to top The recursive DFun in the reproducer for #20836 also triggered a bug in CprAnal that is observable in a debug build. The CPR signature of a recursive DFunId was never updated and hence the optimistic arity 0 bottom signature triggered a mismatch with the arity 1 of the binding in WorkWrap. We never miscompiled any code because WW doesn't exploit bottom CPR signatures. - - - - - b570da84 by Sebastian Graf at 2022-06-20T09:43:29+02:00 CorePrep: Don't speculatively evaluate recursive calls (#20836) In #20836 we have optimised a terminating program into an endless loop, because we speculated the self-recursive call of a recursive DFun. Now we track the set of enclosing recursive binders in CorePrep to prevent speculation of such self-recursive calls. See the updates to Note [Speculative evaluation] for details. Fixes #20836. - - - - - 49fb2f9b by Sebastian Graf at 2022-06-20T09:43:32+02:00 Simplify: Take care with eta reduction in recursive RHSs (#21652) Similar to the fix to #20836 in CorePrep, we now track the set of enclosing recursive binders in the SimplEnv and SimpleOptEnv. See Note [Eta reduction in recursive RHSs] for details. I also updated Note [Arity robustness] with the insights Simon and I had in a call discussing the issue. Fixes #21652. Unfortunately, we get a 5% ghc/alloc regression in T16577. That is due to additional eta reduction in GHC.Read.choose1 and the resulting ANF-isation of a large list literal at the top-level that didn't happen before (presumably because it was too interesting to float to the top-level). There's not much we can do about that. Metric Increase: T16577 - - - - - 2563b95c by Sebastian Graf at 2022-06-20T09:45:09+02:00 Ignore .hie-bios - - - - - e4e44d8d by Simon Peyton Jones at 2022-06-20T12:31:45-04:00 Instantiate top level foralls in partial type signatures The main fix for #21667 is the new call to tcInstTypeBnders in tcHsPartialSigType. It was really a simple omission before. I also moved the decision about whether we need to apply the Monomorphism Restriction, from `decideGeneralisationPlan` to `tcPolyInfer`. That removes a flag from the InferGen constructor, which is good. But more importantly, it allows the new function, checkMonomorphismRestriction called from `tcPolyInfer`, to "see" the `Types` involved rather than the `HsTypes`. And that in turn matters because we invoke the MR for partial signatures if none of the partial signatures in the group have any overloading context; and we can't answer that question for HsTypes. See Note [Partial type signatures and the monomorphism restriction] in GHC.Tc.Gen.Bind. This latter is really a pre-existing bug. - - - - - 262a9f93 by Winston Hartnett at 2022-06-20T12:32:23-04:00 Make Outputable instance for InlineSig print the InlineSpec Fix ghc/ghc#21739 Squash fix ghc/ghc#21739 - - - - - b5590fff by Matthew Pickering at 2022-06-20T12:32:59-04:00 Add NO_BOOT to hackage_doc_tarball job We were attempting to boot a src-tarball which doesn't work as ./boot is not included in the source tarball. This slipped through as the job is only run on nightly. - - - - - d24afd9d by Vladislav Zavialov at 2022-06-20T17:34:44-04:00 HsToken for @-patterns and TypeApplications (#19623) One more step towards the new design of EPA. - - - - - 159b7628 by Tamar Christina at 2022-06-20T17:35:23-04:00 linker: only keep rtl exception tables if they have been relocated - - - - - da5ff105 by Andreas Klebinger at 2022-06-21T17:04:12+02:00 Ticky:Make json info a separate field. - - - - - 1a4ce4b2 by Matthew Pickering at 2022-06-22T09:49:22+01:00 Revert "Ticky:Make json info a separate field." This reverts commit da5ff10503e683e2148c62e36f8fe2f819328862. This was pushed directly without review. - - - - - f89bf85f by Vanessa McHale at 2022-06-22T08:21:32-04:00 Flags to disable local let-floating; -flocal-float-out, -flocal-float-out-top-level CLI flags These flags affect the behaviour of local let floating. If `-flocal-float-out` is disabled (the default) then we disable all local floating. ``` …(let x = let y = e in (a,b) in body)... ===> …(let y = e; x = (a,b) in body)... ``` Further to this, top-level local floating can be disabled on it's own by passing -fno-local-float-out-top-level. ``` x = let y = e in (a,b) ===> y = e; x = (a,b) ``` Note that this is only about local floating, ie, floating two adjacent lets past each other and doesn't say anything about the global floating pass which is controlled by `-fno-float`. Fixes #13663 - - - - - 4ccefc6e by Matthew Craven at 2022-06-22T08:22:12-04:00 Check for Int overflows in Data.Array.Byte - - - - - 2004e3c8 by Matthew Craven at 2022-06-22T08:22:12-04:00 Add a basic test for ByteArray's Monoid instance - - - - - fb36770c by Matthew Craven at 2022-06-22T08:22:12-04:00 Rename `copyByteArray` to `unsafeCopyByteArray` - - - - - ecc9aedc by Ben Gamari at 2022-06-22T08:22:48-04:00 testsuite: Add test for #21719 Happily, this has been fixed since 9.2. - - - - - 19606c42 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Use lookupNameCache instead of lookupOrigIO - - - - - 4c9dfd69 by Brandon Chinn at 2022-06-22T08:23:28-04:00 Break out thNameToGhcNameIO (ref. #21730) - - - - - eb4fb849 by Michael Peyton Jones at 2022-06-22T08:24:07-04:00 Add laws for 'toInteger' and 'toRational' CLC discussion here: https://github.com/haskell/core-libraries-committee/issues/58 - - - - - c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00 Correct documentation of defaults of the `-V` RTS option - - - - - b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00 Transcribe discussion from #21483 into a Note In #21483 I had a discussion with Simon Marlow about the memory retention behaviour of -Fd. I have just transcribed that conversation here as it elucidates the potentially subtle assumptions which led to the design of the memory retention behaviours of -Fd. Fixes #21483 - - - - - 980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00 eventlog: Don't leave dangling pointers hanging around Previously we failed to reset pointers to various eventlog buffers to NULL after freeing them. In principle we shouldn't look at them after they are freed but nevertheless it is good practice to set them to a well-defined value. - - - - - 575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00 runhaskell - - - - - e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00 re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45 - - - - - 5d45aa97 by Gergo ERDI at 2022-06-22T22:00:46-04:00 When specialising, look through floatable ticks. Fixes #21697. - - - - - 531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00 TagCheck.hs: Properly check if arguments are boxed types. For one by mistake I had been checking against the kind of runtime rep instead of the boxity. This uncovered another bug, namely that we tried to generate the checking code before we had associated the function arguments with a register, so this could never have worked to begin with. This fixes #21729 and both of the above issues. - - - - - c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00 Use correct arch for the FreeBSD triple in gen-data-layout.sh Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798 Relevant upstream issue: #15718 - - - - - 75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00 Bump nofib submodule. Allows the shake runner to build with 9.2.3 among other things. Fixes #21772 - - - - - 0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00 Bump ghc-prim and base versions To 0.9.0 and 4.17.0 respectively. Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm, terminfo, text, unix, haddock, and hsc2hs submodules. (cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095) - - - - - 4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00 testsuite: Use normalise_version more consistently Previously several tests' output were unnecessarily dependent on version numbers, particularly of `base`. Fix this. - - - - - d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00 linters: Fix lint-submodule-refs when crashing trying to find plausible branches - - - - - 38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 hadrian: Improve haddocks for ghcDebugAssertions - - - - - ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00 Don't mark lambda binders as OtherCon We used to put OtherCon unfoldings on lambda binders of workers and sometimes also join points/specializations with with the assumption that since the wrapper would force these arguments once we execute the RHS they would indeed be in WHNF. This was wrong for reasons detailed in #21472. So now we purge evaluated unfoldings from *all* lambda binders. This fixes #21472, but at the cost of sometimes not using as efficient a calling convention. It can also change inlining behaviour as some occurances will no longer look like value arguments when they did before. As consequence we also change how we compute CBV information for arguments slightly. We now *always* determine the CBV convention for arguments during tidy. Earlier in the pipeline we merely mark functions as candidates for having their arguments treated as CBV. As before the process is described in the relevant notes: Note [CBV Function Ids] Note [Attaching CBV Marks to ids] Note [Never put `OtherCon` unfoldigns on lambda binders] ------------------------- Metric Decrease: T12425 T13035 T18223 T18223 T18923 MultiLayerModulesTH_OneShot Metric Increase: WWRec ------------------------- - - - - - 06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00 Add suggestions for unrecognised pragmas (#21589) In case of a misspelled pragma, offer possible corrections as to what the user could have meant. Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589 - - - - - 3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00 Remove the traces of i386-*-openbsd, long live amd64 OpenBSD will not ship any ghc packages on i386 starting with 7.2 release. This means there will not be a bootstrap compiler easily available. The last available binaries are ghc-8.10.6 which is already not supported as bootstrap for HEAD. See here for more information: https://marc.info/?l=openbsd-ports&m=165060700222580&w=2 - - - - - 58530271 by Bodigrim at 2022-06-27T08:03:34-04:00 Add Foldable1 and Bifoldable1 type classes Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9 Instances roughly follow https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1 but the API of `Foldable1` was expanded in comparison to `semigroupoids`. Compatibility shim is available from https://github.com/phadej/foldable1 (to be released). Closes #13573. - - - - - a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00 add levity polymorphism to addrToAny# - - - - - f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00 add tests for addrToAny# levity - - - - - 07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00 hadrian: Update main README page This README had some quite out-of-date content about the build system so I did a complete pass deleting old material. I also made the section about flavours more prominent and mentioned flavour transformers. - - - - - 79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00 testsuite: Hide output from test compilations with verbosity==2 Previously the output from test compilations used to determine whether, e.g., profiling libraries are available was shown with verbosity levels >= 2. However, the default level is 2, meaning that most users were often spammed with confusing errors. Fix this by bumping the verbosity threshold for this output to >=3. Fixes #21760. - - - - - 995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00 configure: Only probe for LD in FIND_LD Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD rather early in `configure`. However, it turns out that this breaks `configure`'s `ld`-override logic, which assumes that `LD` was set by the user and aborts. Fixes #21778. - - - - - b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00 `.hs-boot` make rules: add missing order-only dependency on target directory Noticed missing target directory dependency as a build failure in `make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100): "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254 make: *** [Makefile:128: all] Error 2 shuffle=1656129254 Note that `cp` complains about inability to create target file. The change adds order-only dependency on a target directory (similar to the rest of rules in that file). The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build system megapatch`.) where upfront directory creation was never added to `.hs-boot` files. - - - - - 57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00 Mark AArch64/Darwin as requiring sign-extension Apple's AArch64 ABI requires that the caller sign-extend small integer arguments. Set platformCConvNeedsExtension to reflect this fact. Fixes #21773. - - - - - df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00 -ddump-llvm shouldn't imply -fllvm Previously -ddump-llvm would change the backend used, which contrasts with all other dump flags. This is quite surprising and cost me quite a bit of time. Dump flags should not change compiler behavior. Fixes #21776. - - - - - 70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Re-format argument handling logic Previously there were very long, hard to parse lines. Fix this. - - - - - 696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00 CmmToAsm/AArch64: Sign-extend narrow C arguments The AArch64/Darwin ABI requires that function arguments narrower than 32-bits must be sign-extended by the caller. We neglected to do this, resulting in #20735. Fixes #20735. - - - - - c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00 testsuite: Add test for #20735 - - - - - 16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00 integer-gmp: Fix cabal file Evidently fields may not come after sections in a cabal file. - - - - - 03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00 ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist) before the change `make install` was failing as: ``` "mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc" make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'. Stop. ``` I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf` is created (somewhat manually), but not the .install varianlt of it. The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere. Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784 - - - - - eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00 Comments only, about join points This MR just adds some documentation about why casts destroy join points, following #21716. - - - - - 251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00 Cleanup BuiltInSyntax vs UserSyntax There was some confusion about whether FUN/TYPE/One/Many should be BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as BuiltInSyntax is for things which are directly constructed by the parser rather than going through normal renaming channels. I fixed all the obviously wrong places I could find and added a test for the original bug which was caused by this (#21752) Fixes #21752 #20695 #18302 - - - - - 0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00 template-haskell: Bump version to 2.19.0.0 Bumps text and exceptions submodules due to bounds. - - - - - bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00 Tiny tweak to `IOPort#` documentation The exclamation mark and bracket don’t seem to make sense here. I’ve looked through the history, and I don’t think they’re deliberate – possibly a copy-and-paste error. - - - - - 70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00 Remove `CoreOccurAnal` constructor of the `CoreToDo` type It was dead code since the last occurence in an expression context got removed in 71916e1c018dded2e68d6769a2dbb8777da12664. - - - - - d0722170 by nineonine at 2022-07-01T08:15:56-04:00 Fix panic with UnliftedFFITypes+CApiFFI (#14624) When declaring foreign import using CAPI calling convention, using unlifted unboxed types would result in compiler panic. There was an attempt to fix the situation in #9274, however it only addressed some of the ByteArray cases. This patch fixes other missed cases for all prims that may be used as basic foreign types. - - - - - eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00 rts: gc stats: account properly for copied bytes in sequential collections We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow] counters during sequential collections. As well, we were double counting for parallel collections. To fix this we add an `else` clause to the `if (is_par_gc())`. The par_* counters do not need to be updated in the sequential case because they must be 0. - - - - - f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00 desugar: Look through ticks when warning about possible literal overflow Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up between the appliation of `neg` to its argument. This defeated the special logic which looks for `NegApp ... (HsOverLit` to warn about possible overflow if a user writes a negative literal (without out NegativeLiterals) in their code. Fixes #21701 - - - - - f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00 ci: Fix definition of slow-validate flavour (so that -dlint) is passed In this embarassing sequence of events we were running slow-validate without -dlint. - - - - - bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00 Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411 - - - - - 9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00 Data.Foldable1: Remove references to Foldable-specific note ...as discussed in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455. - - - - - 3a8970ac by romes at 2022-07-03T14:11:31-04:00 TTG: Move HsModule to L.H.S Move the definition of HsModule defined in GHC.Hs to Language.Haskell.Syntax with an added TTG parameter and corresponding extension fields. This is progress towards having the haskell-syntax package, as described in #21592 - - - - - f9f80995 by romes at 2022-07-03T14:11:31-04:00 TTG: Move ImpExp client-independent bits to L.H.S.ImpExp Move the GHC-independent definitions from GHC.Hs.ImpExp to Language.Haskell.Syntax.ImpExp with the required TTG extension fields such as to keep the AST independent from GHC. This is progress towards having the haskell-syntax package, as described in #21592 Bumps haddock submodule - - - - - c43dbac0 by romes at 2022-07-03T14:11:31-04:00 Refactor ModuleName to L.H.S.Module.Name ModuleName used to live in GHC.Unit.Module.Name. In this commit, the definition of ModuleName and its associated functions are moved to Language.Haskell.Syntax.Module.Name according to the current plan towards making the AST GHC-independent. The instances for ModuleName for Outputable, Uniquable and Binary were moved to the module in which the class is defined because these instances depend on GHC. The instance of Eq for ModuleName is slightly changed to no longer depend on unique explicitly and instead uses FastString's instance of Eq. - - - - - 2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00 Expand `Ord` instance for `Down` Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610 - - - - - 36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00 Add applyWhen to Data.Function per CLC prop Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233 - - - - - 3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00 hadrian: Don't read package environments in ghc-stage1 wrapper The stage1 compiler may be on the brink of existence and not have even a working base library. You may have installed packages globally with a similar stage2 compiler which will then lead to arguments such as --show-iface not even working because you are passing too many package flags. The solution is simple, don't read these implicit files. Fixes #21803 - - - - - aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00 Ticky:Make json info a separate field. Fixes #21233 - - - - - 74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00 Add docs:<pkg> command to hadrian to build docs for just one package - - - - - 418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00 upload-docs: propagate publish correctly in upload_sdist - - - - - ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00 docs-upload: Fix upload script when no packages are listed - - - - - d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00 hadrian: Add --haddock-base-url option for specifying base-url when generating docs The motiviation for this flag is to be able to produce documentation which is suitable for uploading for hackage, ie, the cross-package links work correctly. There are basically three values you want to set this to: * off - default, base_url = ../%pkg% which works for local browsing * on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload * on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation. The `%pkg%` string is a template variable which is replaced with the package identifier for the relevant package. This is one step towards fixing #21749 - - - - - 41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00 Add nightly job for generating docs suitable for hackage upload - - - - - 620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00 ghci: Support :set prompt in multi repl This adds supports for various :set commands apart from `:set <FLAG>` in multi repl, this includes `:set prompt` and so-on. Fixes #21796 - - - - - b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00 Vendor filepath inside template-haskell Adding filepath as a dependency of template-haskell means that it can't be reinstalled if any build-plan depends on template-haskell. This is a temporary solution for the 9.4 release. A longer term solution is to split-up the template-haskell package into the wired-in part and a non-wired-in part which can be reinstalled. This was deemed quite risky on the 9.4 release timescale. Fixes #21738 - - - - - c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00 Factor fields of `CoreDoSimplify` into separate data type This avoids some partiality. The work @mmhat is doing cleaning up and modularizing `Core.Opt` will build on this nicely. - - - - - d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00 https urls - - - - - 803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00 options and typos - - - - - 5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00 grammar - - - - - 4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00 sources - - - - - c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00 Fix lint warnings in bootstrap.py - - - - - 86ced2ad by romes at 2022-07-06T01:36:23-04:00 Restore Eq instance of ImportDeclQualifiedStyle Fixes #21819 - - - - - 3547e264 by romes at 2022-07-06T13:50:27-04:00 Prune L.H.S modules of GHC dependencies Move around datatypes, functions and instances that are GHC-specific out of the `Language.Haskell.Syntax.*` modules to reduce the GHC dependencies in them -- progressing towards #21592 Creates a module `Language.Haskell.Syntax.Basic` to hold basic definitions required by the other L.H.S modules (and don't belong in any of them) - - - - - e4eea07b by romes at 2022-07-06T13:50:27-04:00 TTG: Move CoreTickish out of LHS.Binds Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and move them to the extension point instance, according to the plan outlined in #21592 to separate the base AST from the GHC specific bits. - - - - - acc1816b by romes at 2022-07-06T13:50:27-04:00 TTG for ForeignImport/Export Add a TTG parameter to both `ForeignImport` and `ForeignExport` and, according to #21592, move the GHC-specific bits in them and in the other AST data types related to foreign imports and exports to the TTG extension point. - - - - - 371c5ecf by romes at 2022-07-06T13:50:27-04:00 TTG for HsTyLit Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText` fields to the extension point and out of the base AST. Progress towards #21592 - - - - - fd379d1b by romes at 2022-07-06T13:50:27-04:00 Remove many GHC dependencies from L.H.S Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC imports according to the plan in the linked issue. Moves more GHC-specific declarations to `GHC.*` and brings more required GHC-independent declarations to `Language.Haskell.Syntax.*` (extending e.g. `Language.Haskell.Syntax.Basic`). Progress towards #21592 Bump haddock submodule for !8308 ------------------------- Metric Decrease: hard_hole_fits ------------------------- - - - - - c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00 Fix exact printing of the HsRule name Prior to this branch, the HsRule name was XRec pass (SourceText,RuleName) and there is an ExactPrint instance for (SourceText, RuleName). The SourceText has moved to a different location, so synthesise the original to trigger the correct instance when printing. We need both the SourceText and RuleName when exact printing, as it is possible to have a NoSourceText variant, in which case we fall back to the FastString. - - - - - 665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00 driver: Fix issue with module loops and multiple home units We were attempting to rehydrate all dependencies of a particular module, but we actually only needed to rehydrate those of the current package (as those are the ones participating in the loop). This fixes loading GHC into a multi-unit session. Fixes #21814 - - - - - bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00 Remove a bogus #define from ClosureMacros.h - - - - - fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00 winio: make consoleReadNonBlocking not wait for any events at all. - - - - - 42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00 rts: allow NULL to be used as an invalid StgStablePtr - - - - - 3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00 RTS: Add stack marker to StgCRunAsm.S Every object file must be properly marked for non-executable stack, even if it contains no code. - - - - - a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00 Bump unix submodule Adds `config.sub` to unix's `.gitignore`, fixing #19574. - - - - - 3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00 ghci: Fix most calls to isLoaded to work in multi-mode The most egrarious thing this fixes is the report about the total number of loaded modules after starting a session. Ticket #20889 - - - - - fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00 Enable :edit command in ghci multi-mode. This works after the last change to isLoaded. Ticket #20888 - - - - - 46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00 Fix a scoping bug in the Specialiser In the call to `specLookupRule` in `already_covered`, in `specCalls`, we need an in-scope set that includes the free vars of the arguments. But we simply were not guaranteeing that: did not include the `rule_bndrs`. Easily fixed. I'm not sure how how this bug has lain for quite so long without biting us. Fixes #21828. - - - - - 6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Edit Note [idArity varies independently of dmdTypeDepth] ...and refer to it in GHC.Core.Lint.lintLetBind. Fixes #21452 - - - - - 89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00 Tiny documentation wibbles (comments only) - - - - - 61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix readme - - - - - 61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00 fix bootstrap - - - - - 8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00 tarball - - - - - e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Fix scopes for deriving clauses and instance signatures (#18425) - - - - - c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00 hie-files: Record location of filled in default method bindings This is useful for hie files to reconstruct the evidence that default methods depend on. - - - - - 9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00 testsuite: Factor out common parts from hiefile tests - - - - - 6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00 Hadrian: update documentation of settings The documentation for key-value settings was a bit out of date. This patch updates it to account for `cabal.configure.opts` and `hsc2hs.run.opts`. The user-settings document was also re-arranged, to make the key-value settings more prominent (as it doesn't involve changing the Hadrian source code, and thus doesn't require any recompilation of Hadrian). - - - - - a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00 Fix potential space leak that arise from ModuleGraphs retaining references to previous ModuleGraphs, in particular the lazy `mg_non_boot` field. This manifests in `extendMG`. Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which is only called in two places in the compiler, and should only be called at most once for every home unit: GHC.Driver.Make: mainModuleSrcPath :: Maybe String mainModuleSrcPath = do ms <- mgLookupModule mod_graph (mainModIs hue) ml_hs_file (ms_location ms) GHCI.UI: listModuleLine modl line = do graph <- GHC.getModuleGraph let this = GHC.mgLookupModule graph modl Instead `mgLookupModule` can be a linear function that looks through the entire list of `ModuleGraphNodes` Fixes #21816 - - - - - dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00 rts: Fix AdjustorPool bitmap manipulation Previously the implementation of bitmap_first_unset assumed that `__builtin_clz` would accept `uint8_t` however it apparently rather extends its argument to `unsigned int`. To fix this we simply revert to a naive implementation since handling the various corner cases with `clz` is quite tricky. This should be fine given that AdjustorPool isn't particularly hot. Ideally we would have a single, optimised bitmap implementation in the RTS but I'll leave this for future work. Fixes #21838. - - - - - ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00 Change GHCi bytecode return convention for unlifted datatypes. This changes the bytecode return convention for unlifted algebraic datatypes to be the same as for lifted types, i.e. ENTER/PUSH_ALTS instead of RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED Fixes #20849 - - - - - 5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00 Compute record-dot-syntax types Ensures type information for record-dot-syntax is included in HieASTs. See #21797 - - - - - 89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00 Add record-dot-syntax test - - - - - 4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00 Document RuntimeRep polymorphism limitations of catch#, et al As noted in #21868, several primops accepting continuations producing RuntimeRep-polymorphic results aren't nearly as polymorphic as their types suggest. Document this limitation and adapt the `UnliftedWeakPtr` test to avoid breaking this limitation in `keepAlive#`. - - - - - 4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00 Make keepAlive# out-of-line This is a naive approach to fixing the unsoundness noticed in #21708. Specifically, we remove the lowering of `keepAlive#` via CorePrep and instead turn it into an out-of-line primop. This is simple, inefficient (since the continuation must now be heap allocated), but good enough for 9.4.1. We will revisit this (particiularly via #16098) in a future release. Metric Increase: T4978 T7257 T9203 - - - - - 1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00 Suppress extra output from configure check for c++ libraries - - - - - 3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00 rel-notes: Drop mention of #21745 fix Since we have backported the fix to 9.4.1. - - - - - b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00 Align the behaviour of `dopt` and `log_dopt` Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying function `log_dopt`) were different as the latter did not take the verbosity level into account. This led to problems during the refactoring as we cannot simply replace calls to `dopt` with calls to `logHasDumpFlag`. In addition to that a subtle bug in the GHC module was fixed: `setSessionDynFlags` did not update the logger and as a consequence the verbosity value of the logger was not set appropriately. Fixes #21861 - - - - - 28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00 rts: forkOn context switches the target capability Fixes #21824 - - - - - f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Eliminate orphan Outputable instances Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and `OutputableP` instances for the Cmm AST. This makes it significantly easier to use the Cmm pretty-printers in tracing output without incurring module import cycles. - - - - - f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00 cmm: Move toBlockList to GHC.Cmm - - - - - fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00 compiler: Add haddock sections to GHC.Utils.Panic - - - - - 097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00 configure: Don't override Windows CXXFLAGS At some point we used the clang distribution from msys2's `MINGW64` environment for our Windows toolchain. This defaulted to using libgcc and libstdc++ for its runtime library. However, we found for a variety of reasons that compiler-rt, libunwind, and libc++ were more reliable, consequently we explicitly overrode the CXXFLAGS to use these. However, since then we have switched to use the `CLANG64` packaging, which default to these already. Consequently we can drop these arguments, silencing some redundant argument warnings from clang. Fixes #21669. - - - - - e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Check that there are no NULL ctors - - - - - 616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/Elf: Introduce support for invoking finalizers on unload Addresses #20494. - - - - - cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add T20494 - - - - - 03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Rename finit field to fini fini is short for "finalizer", which does not contain a "t". - - - - - 033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Refactor handling of oc->info Previously we would free oc->info after running initializers. However, we can't do this is we want to also run finalizers. Moreover, freeing oc->info so early was wrong for another reason: we will need it in order to unregister the exception tables (see the call to `RtlDeleteFunctionTable`). In service of #20494. - - - - - f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Add finalization support This implements #20494 for the PEi386 linker. Happily, this also appears to fix `T9405`, resolving #21361. - - - - - 2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00 Loader: Implement gnu-style -l:$path syntax Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic. - - - - - 5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00 Statically-link against libc++ on Windows Unfortunately on Windows we have no RPATH-like facility, making dynamic linking extremely fragile. Since we cannot assume that the user will add their GHC installation to `$PATH` (and therefore their DLL search path) we cannot assume that the loader will be able to locate our `libc++.dll`. To avoid this, we instead statically link against `libc++.a` on Windows. Fixes #21435. - - - - - 8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run It turns out that PE objects may have multiple `.ctors`/`.dtors` sections but the RTS linker had assumed that there was only one. Fix this. Fixes #21618. - - - - - fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Respect dtor/ctor priority Previously we would run constructors and destructors in arbitrary order despite explicit priorities. Fixes #21847. - - - - - 1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00 testsuite: Add test for #21618 and #21847 - - - - - 6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/PEi386: Fix exception unwind unregistration RtlDeleteFunctionTable expects a pointer to the .pdata section yet we passed it the .xdata section. Happily, this fixes #21354. - - - - - d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Drop dead code - - - - - d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Use section flags to identify initializers - - - - - fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00 rts/linker/MachO: Introduce finalizer support - - - - - 5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl - - - - - 6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker/Elf: Work around GCC 6 init/fini behavior It appears that GCC 6t (at least on i386) fails to give init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY section types, instead marking them as SHT_PROGBITS. This caused T20494 to fail on Debian. - - - - - 5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00 testsuite: Mark T13366Cxx as unbroken on Darwin - - - - - 1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Fix resolution of __dso_handle on Darwin Darwin expects a leading underscore. - - - - - a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Clean up section kinds - - - - - aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00 rts/linker: Ensure that __cxa_finalize is called on code unload - - - - - 028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00 testsuite: Fix T11829 on Centos 7 It appears that Centos 7 has a more strict C++ compiler than most distributions since std::runtime_error is defined in <stdexcept> rather than <exception>. In T11829 we mistakenly imported the latter. - - - - - a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00 hadrian: Rename documentation directories for consistency with make * Rename `docs` to `doc` * Place pdf documentation in `doc/` instead of `doc/pdfs/` Fixes #21164. - - - - - b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00 Fix incorrect proof of applyWhen’s properties - - - - - eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00 hadrian: Add multi:<pkg> and multi targets for starting a multi-repl This patch adds support to hadrian for starting a multi-repl containing all the packages which stage0 can build. In particular, there is the new user-facing command: ``` ./hadrian/ghci-multi ``` which when executed will start a multi-repl containing the `ghc` package and all it's dependencies. This is implemented by two new hadrian targets: ``` ./hadrian/build multi:<pkg> ``` Construct the arguments for a multi-repl session where the top-level package is <pkg>. For example, `./hadrian/ghci-multi` is implemented using `multi:ghc` target. There is also the `multi` command which constructs a repl for everything in stage0 which we can build. - - - - - 19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00 changelog typo - - - - - af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00 typos - - - - - 415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00 Refactor SpecConstr to use treat bindings uniformly This patch, provoked by #21457, simplifies SpecConstr by treating top-level and nested bindings uniformly (see the new scBind). * Eliminates the mysterious scTopBindEnv * Refactors scBind to handle top-level and nested definitions uniformly. * But, for now at least, continues the status quo of not doing SpecConstr for top-level non-recursive bindings. (In contrast we do specialise nested non-recursive bindings, although the original paper did not; see Note [Local let bindings].) I tried the effect of specialising top-level non-recursive bindings (which is now dead easy to switch on, unlike before) but found some regressions, so I backed off. See !8135. It's a pure refactoring. I think it'll do a better job in a few cases, but there is no regression test. - - - - - d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00 Rule matching: Don't compute the FVs if we don't look at them. - - - - - 5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 White space only in FamInstEnv - - - - - ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make transferPolyIdInfo work for CPR I don't know why this hasn't bitten us before, but it was plain wrong. - - - - - 9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Inline mapAccumLM This function is called in inner loops in the compiler, and it's overloaded and higher order. Best just to inline it. This popped up when I was looking at something else. I think perhaps GHC is delicately balanced on the cusp of inlining this automatically. - - - - - d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Make SetLevels honour floatConsts This fix, in the definition of profitableFloat, is just for consistency. `floatConsts` should do what it says! I don't think it'll affect anything much, though. - - - - - d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00 Refactor wantToUnboxArg a bit * Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg and similarly wantToUnboxResult to canUnboxResult. * Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg, avoiding some yukky duplication. I decided it was clearer to give it a new data type for its return type, because I nedeed the FD_RecBox case which was not otherwise readiliy expressible. * Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload * Get rid of the Unlift constructor of UnboxingDecision, eliminate two panics, and two arguments to canUnboxArg (new name). Much nicer now. - - - - - 6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00 Allow running memInventory when the concurrent nonmoving gc is enabled If the nonmoving gc is enabled and we are using a threaded RTS, we now try to grab the collector mutex to avoid memInventory and the collection racing. Before memInventory was disabled. - - - - - aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00 gitignore: don't ignore all aclocal.m4 files While GHC's own aclocal.m4 is generated by the aclocal tool, other packages' aclocal.m4 are committed in the repository. Previously `.gitignore` included an entry which covered *any* file named `aclocal.m4`, which lead to quite some confusion (e.g. see #21740). Fix this by modifying GHC's `.gitignore` to only cover GHC's own `aclocal.m4`. - - - - - 4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00 Add mapAccumM, forAccumM to Data.Traversable Approved by Core Libraries Committee in https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433 - - - - - bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00 configure: Use AC_PATH_TOOL to detect tools Previously we used AC_PATH_PROG which, as noted by #21601, does not look for tools with a target prefix, breaking cross-compilation. Fixes #21601. - - - - - e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00 driver: Fix implementation of -S We were failing to stop before running the assembler so the object file was also created. Fixes #21869 - - - - - e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00 rts/ProfHeap: Ensure new Censuses are zeroed When growing the Census array ProfHeap previously neglected to zero the new part of the array. Consequently `freeEra` would attempt to free random words that often looked suspiciously like pointers. Fixes #21880. - - - - - 81d65f7f by sheaf at 2022-07-21T15:37:22+02:00 Make withDict opaque to the specialiser As pointed out in #21575, it is not sufficient to set withDict to inline after the typeclass specialiser, because we might inline withDict in one module and then import it in another, and we run into the same problem. This means we could still end up with incorrect runtime results because the typeclass specialiser would assume that distinct typeclass evidence terms at the same type are equal, when this is not necessarily the case when using withDict. Instead, this patch introduces a new magicId, 'nospec', which is only inlined in CorePrep. We make use of it in the definition of withDict to ensure that the typeclass specialiser does not common up distinct typeclass evidence terms. Fixes #21575 - - - - - 9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00 Refactored Simplify pass * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify namespace and GHC.Core.Opt.Stats. Also removed services from configuration records. * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration. * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm` and moved the Simplify driver to GHC.Core.Opt.Simplify. * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env. * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment in GHC.Core.Opt.Simplify.Monad. * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions for those in a new module GHC.Driver.Config.Core.Opt.Simplify. Also added initialization functions for `SimplMode` to that module. * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types and the counting types and functions (`SimplCount` and `Tick`) to new module GHC.Core.Opt.Stats. * Added getter functions for the fields of `SimplMode`. The pedantic bottoms option and the platform are retrieved from the ArityOpts and RuleOpts and the getter functions allow us to retrieve values from `SpecEnv` without the knowledge where the data is stored exactly. * Moved the coercion optimization options from the top environment to `SimplMode`. This way the values left in the top environment are those dealing with monadic functionality, namely logging, IO related stuff and counting. Added a note "The environments of the Simplify pass". * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead. * Prep work before removing `InteractiveContext` from `HscEnv`. - - - - - 2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00 Make the specialiser deal better with specialised methods This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368. - - - - - ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00 ghc-boot: Clean up UTF-8 codecs In preparation for moving the UTF-8 codecs into `base`: * Move them to GHC.Utils.Encoding.UTF8 * Make names more consistent * Add some Haddocks - - - - - e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00 base: Introduce GHC.Encoding.UTF8 Here we copy a subset of the UTF-8 implementation living in `ghc-boot` into `base`, with the intent of dropping the former in the future. For this reason, the `ghc-boot` copy is now CPP-guarded on `MIN_VERSION_base(4,18,0)`. Naturally, we can't copy *all* of the functions defined by `ghc-boot` as some depend upon `bytestring`; we rather just copy those which only depend upon `base` and `ghc-prim`. Further consolidation? ---------------------- Currently GHC ships with at least five UTF-8 implementations: * the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this can be used at a number of types including `Addr#`, `ByteArray#`, `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this can be removed in GHC 9.6+2, when the copies in `base` will become available to `ghc-boot`. * the copy of the `ghc-boot` definition now exported by `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`, `ByteArray#`, and `ForeignPtr` * the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`; this is specialised at `Addr#`. * the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`; this is specialised at `Addr#` but, unlike the above, supports recovery in the presence of partial codepoints (since in IO contexts codepoints may be broken across buffers) * the implementation provided by the `text` library This does seem a tad silly. On the other hand, these implementations *do* materially differ from one another (e.g. in the types they support, the detail in errors they can report, and the ability to recover from partial codepoints). Consequently, it's quite unclear that further consolidate would be worthwhile. - - - - - f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00 Add a Note summarising GHC's UTF-8 implementations GHC has a somewhat dizzying array of UTF-8 implementations. This note describes why this is the case. - - - - - 72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00 upload_ghc_libs: Fix path to documentation The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35 but this one occurrence was note updated. Finally closes #21164. - - - - - a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00 Add test for #21871 This adds a test for #21871, which was fixed by the No Skolem Info rework (MR !7105). Fixes #21871 - - - - - 6379f942 by sheaf at 2022-07-22T08:18:46-04:00 Add test for #21360 The way record updates are typechecked/desugared changed in MR !7981. Because we desugar in the typechecker to a simple case expression, the pattern match checker becomes able to spot the long-distance information and avoid emitting an incorrect pattern match warning. Fixes #21360 - - - - - ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00 Hadrian: don't try to build "unix" on Windows - - - - - dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Implement DeepSubsumption This MR adds the language extension -XDeepSubsumption, implementing GHC proposal #511. This change mitigates the impact of GHC proposal The changes are highly localised, by design. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. The main changes are: * Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010, but off in Haskell2021. -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change. -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds: it makes type inference more complicated and less predictable, but it may be convenient in practice. * The main changes are in: * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result type. Without deep subsumption, unifyExpectedType would be sufficent. See Note [Deep subsumption] in GHC.Tc.Utils.Unify. * There are no changes to Quick Look at all. * The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to GHC.Magic.Dict * I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where we'd forgotten to take the free vars of the multiplicity of an Id. * I also had to fix tcSplitNestedSigmaTys When I did the shallow-subsumption patch commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f Date: Sun Feb 2 18:23:11 2020 +0000 Simple subsumption I changed tcSplitNestedSigmaTys to not look through function arrows any more. But that was actually an un-forced change. This function is used only in * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect All to do with validity checking and error messages. Acutally its fine to look under function arrows here, and quite useful a test DeepSubsumption05 (a test motivated by a build failure in the `lens` package) shows. The fix is easy. I added Note [tcSplitNestedSigmaTys]. - - - - - e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption - - - - - 67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00 Add DeepSubsumption08 - - - - - 5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00 Fix the interaction of operator sections and deep subsumption Fixes DeepSubsumption08 - - - - - 918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00 Add DeepSubsumption09 - - - - - 2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00 Default implementation for mempty/(<>) Approved by: https://github.com/haskell/core-libraries-committee/issues/61 This adds a default implementation for `mempty` and `(<>)` along with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid` instances can be defined in terms of `sconcat` / `mconcat`. The description for each class has also been updated to include the equivalent set of laws for the `sconcat`-only / `mconcat`-only instances. - - - - - 73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00 ci: Disable (broken) perf-nofib See #21859 - - - - - c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00 Docs: clarify ConstraintKinds infelicity GHC doesn't consistently require the ConstraintKinds extension to be enabled, as it allows programs such as type families returning a constraint without this extension. MR !7784 fixes this infelicity, but breaking user programs was deemed to not be worth it, so we document it instead. Fixes #21061. - - - - - 5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00 More improvements to worker/wrapper This patch fixes #21888, and simplifies finaliseArgBoxities by eliminating the (recently introduced) data type FinalDecision. A delicate interaction meant that this patch commit d1c25a48154236861a413e058ea38d1b8320273f Date: Tue Jul 12 16:33:46 2022 +0100 Refactor wantToUnboxArg a bit make worker/wrapper go into an infinite loop. This patch fixes it by narrowing the handling of case (B) of Note [Boxity for bottoming functions], to deal only the arguemnts that are type variables. Only then do we drop the trimBoxity call, which is what caused the bug. I also * Added documentation of case (B), which was previously completely un-mentioned. And a regression test, T21888a, to test it. * Made unboxDeeplyDmd stop at lazy demands. It's rare anyway for a bottoming function to have a lazy argument (mainly when the data type is recursive and then we don't want to unbox deeply). Plus there is Note [No lazy, Unboxed demands in demand signature] * Refactored the Case equation for dmdAnal a bit, to do less redundant pattern matching. - - - - - b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00 Fix a small buglet in tryEtaReduce Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was making an ill-formed cast. It didn't matter, because the subsequent guard discarded it; but still worth fixing. Spurious warnings are distracting. - - - - - 3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00 Fix #21889, GHCi misbehaves with Ctrl-C on Windows On Windows, we create multiple levels of wrappers for GHCi which ultimately execute ghc --interactive. In order to handle console events properly, each of these wrappers must call FreeConsole() in order to hand off event processing to the child process. See #14150. In addition to this, FreeConsole must only be called from interactive processes (#13411). This commit makes two changes to fix this situation: 1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole` if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi. 2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`: Before: ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe After: ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe - - - - - 79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00 docs: Fix documentation of \cases Fixes #21902. - - - - - e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00 ghc-cabal: allow Cabal 3.8 to unbreak make build When bootstrapping GHC 9.4.*, the build will fail when configuring ghc-cabal as part of the make based build system due to this upper bound, as Cabal has been updated to a 3.8 release. Reference #21914, see especially https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699 - - - - - 726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Fix isEvaldUnfolding and isValueUnfolding This fixes (1) in #21831. Easy, obviously correct. - - - - - 5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Switch off eta-expansion in rules and unfoldings I think this change will make little difference except to reduce clutter. But that's it -- if it causes problems we can switch it on again. - - - - - d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Teach SpecConstr about typeDeterminesValue This patch addresses #21831, point 2. See Note [generaliseDictPats] in SpecConstr I took the opportunity to refactor the construction of specialisation rules a bit, so that the rule name says what type we are specialising at. Surprisingly, there's a 20% decrease in compile time for test perf/compiler/T18223. I took a look at it, and the code size seems the same throughout. I did a quick ticky profile which seemed to show a bit less substitution going on. Hmm. Maybe it's the "don't do eta-expansion in stable unfoldings" patch, which is part of the same MR as this patch. Anyway, since it's a move in the right direction, I didn't think it was worth looking into further. Metric Decrease: T18223 - - - - - 65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00 Add a 'notes' file in testsuite/tests/perf/compiler This file is just a place to accumlate notes about particular benchmarks, so that I don't keep re-inventing the wheel. - - - - - 61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00 Get the in-scope set right in FamInstEnv.injectiveBranches There was an assert error, as Gergo pointed out in #21896. I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs. And also to GHC.Core.Unify.niFixTCvSubst. I also took the opportunity to get a couple more InScopeSets right, and to change some substTyUnchecked into substTy. This MR touches a lot of other files, but only because I also took the opportunity to introduce mkInScopeSetList, and use it. - - - - - 4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00 Add location to cc phase - - - - - 96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00 Avoid as pipeline when compiling c - - - - - 2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00 testsuite: Skip test cases involving -S when testing unregisterised GHC We no longer generate .s files anyway. Metric Decrease: MultiLayerModules T10421 T13035 T13701 T14697 T16875 T18140 T18304 T18923 T9198 - - - - - 82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00 testsuite: introduce nonmoving_thread_sanity way (cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae) - - - - - 4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Track segment state It can often be useful during debugging to be able to determine the state of a nonmoving segment. Introduce some state, enabled by DEBUG, to track this. (cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f) - - - - - 54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00 rts/nonmoving: Don't scavenge objects which weren't evacuated This fixes a rather subtle bug in the logic responsible for scavenging objects evacuated to the non-moving generation. In particular, objects can be allocated into the non-moving generation by two ways: a. evacuation out of from-space by the garbage collector b. direct allocation by the mutator Like all evacuation, objects moved by (a) must be scavenged, since they may contain references to other objects located in from-space. To accomplish this we have the following scheme: * each nonmoving segment's block descriptor has a scan pointer which points to the first object which has yet to be scavenged * the GC tracks a set of "todo" segments which have pending scavenging work * to scavenge a segment, we scavenge each of the unmarked blocks between the scan pointer and segment's `next_free` pointer. We skip marked blocks since we know the allocator wouldn't have allocated into marked blocks (since they contain presumably live data). We can stop at `next_free` since, by definition, the GC could not have evacuated any objects to blocks above `next_free` (otherwise `next_free wouldn't be the first free block). However, this neglected to consider objects allocated by path (b). In short, the problem is that objects directly allocated by the mutator may become unreachable (but not swept, since the containing segment is not yet full), at which point they may contain references to swept objects. Specifically, we observed this in #21885 in the following way: 1. the mutator (specifically in #21885, a `lockCAF`) allocates an object (specifically a blackhole, which here we will call `blkh`; see Note [Static objects under the nonmoving collector] for the reason why) on the non-moving heap. The bitmap of the allocated block remains 0 (since allocation doesn't affect the bitmap) and the containing segment's (which we will call `blkh_seg`) `next_free` is advanced. 2. We enter the blackhole, evaluating the blackhole to produce a result (specificaly a cons cell) in the nursery 3. The blackhole gets updated into an indirection pointing to the cons cell; it is pushed to the generational remembered set 4. we perform a GC, the cons cell is evacuated into the nonmoving heap (into segment `cons_seg`) 5. the cons cell is marked 6. the GC concludes 7. the CAF and blackhole become unreachable 8. `cons_seg` is filled 9. we start another GC; the cons cell is swept 10. we start a new GC 11. something is evacuated into `blkh_seg`, adding it to the "todo" list 12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks between `scan` and `next_free`, which includes `blkh`). We attempt to evacuate `blkh`'s indirectee, which is the previously-swept cons cell. This is unsafe, since the indirectee is no longer a valid heap object. The problem here was that the scavenging logic *assumed* that (a) was the only source of allocations into the non-moving heap and therefore *all* unmarked blocks between `scan` and `next_free` were evacuated. However, due to (b) this is not true. The solution is to ensure that that the scanned region only encompasses the region of objects allocated during evacuation. We do this by updating `scan` as we push the segment to the todo-segment list to point to the block which was evacuated into. Doing this required changing the nonmoving scavenging implementation's update of the `scan` pointer to bump it *once*, instead of after scavenging each block as was done previously. This is because we may end up evacuating into the segment being scavenged as we scavenge it. This was quite tricky to discover but the result is quite simple, demonstrating yet again that global mutable state should be used exceedingly sparingly. Fixes #21885 (cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060) - - - - - 25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00 testsuite: Skip a few tests as in the nonmoving collector Residency monitoring under the non-moving collector is quite conservative (e.g. the reported value is larger than reality) since otherwise we would need to block on concurrent collection. Skip a few tests that are sensitive to residency. (cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70) - - - - - 42147534 by sternenseemann at 2022-07-26T16:26:53-04:00 hadrian: add flag disabling selftest rules which require QuickCheck The hadrian executable depends on QuickCheck for building, meaning this library (and its dependencies) will need to be built for bootstrapping GHC in the future. Building QuickCheck, however, can require TemplateHaskell. When building a statically linking GHC toolchain, TemplateHaskell can be tricky to get to work, and cross-compiling TemplateHaskell doesn't work at all without -fexternal-interpreter, so QuickCheck introduces an element of fragility to GHC's bootstrap. Since the selftest rules are the only part of hadrian that need QuickCheck, we can easily eliminate this bootstrap dependency when required by introducing a `selftest` flag guarding the rules' inclusion. Closes #8699. - - - - - 9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00 Regression test for #21848 - - - - - ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00 driver: Don't create LinkNodes when -no-link is enabled Fixes #21866 - - - - - fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00 Docs: fix mistaken claim about kind signatures This patch fixes #21806 by rectifying an incorrect claim about the usage of kind variables in the header of a data declaration with a standalone kind signature. It also adds some clarifications about the number of parameters expected in GADT declarations and in type family declarations. - - - - - 2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00 testsuite: Correctly set withNativeCodeGen Fixes #21918 - - - - - f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00 Fix since annotations in GHC.Stack.CloneStack Fixes #21894 - - - - - aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00 Add -dsuppress-coercion-types to make coercions even smaller. Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)`` simply print `` `cast` <Co:11> :: ... `` - - - - - 97655ad8 by sheaf at 2022-08-02T19:27:29-04:00 User's guide: fix typo in hasfield.rst Fixes #21950 - - - - - 35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00 Remove TCvSubst and use Subst for both term and type-level subst This patch removes the TCvSubst data type and instead uses Subst as the environment for both term and type level substitution. This change is partially motivated by the existential type proposal, which will introduce types that contain expressions and therefore forces us to carry around an "IdSubstEnv" even when substituting for types. It also reduces the amount of code because "Subst" and "TCvSubst" share a lot of common operations. There isn't any noticeable impact on performance (geo. mean for ghc/alloc is around 0.0% but we have -94 loc and one less data type to worry abount). Currently, the "TCvSubst" data type for substitution on types is identical to the "Subst" data type except the former doesn't store "IdSubstEnv". Using "Subst" for type-level substitution means there will be a redundant field stored in the data type. However, in cases where the substitution starts from the expression, using "Subst" for type-level substitution saves us from having to project "Subst" into a "TCvSubst". This probably explains why the allocation is mostly even despite the redundant field. The patch deletes "TCvSubst" and moves "Subst" and its relevant functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst". Substitution on expressions is still defined in "GHC.Core.Subst" so we don't have to expose the definition of "Expr" in the hs-boot file that "GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a distinct function from "isEmptySubst"; the former ignores the emptiness of "IdSubstEnv"). These exceptions mainly exist for performance reasons and will go away when "Expr" and "Type" are mutually recursively defined (we won't be able to take those shortcuts if we can't make the assumption that expressions don't appear in types). - - - - - b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00 Fix TH + defer-type-errors interaction (#21920) Previously, we had to disable defer-type-errors in splices because of #7276. But this fix is no longer necessary, the test T7276 no longer segfaults and is now correctly deferred. - - - - - fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00 Add a note about about W/W for unlifting strict arguments This fixes #21236. - - - - - fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force safeInferred to avoid retaining extra copy of DynFlags This will only have a (very) modest impact on memory but we don't want to retain old copies of DynFlags hanging around so best to force this value. - - - - - 0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Force name selectors to ensure no reference to Ids enter the NameCache I observed some unforced thunks in the NameCache which were retaining a whole Id, which ends up retaining a Type.. which ends up retaining old copies of HscEnv containing stale HomeModInfo. - - - - - 0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00 Fix leaks in --make mode when there are module loops This patch fixes quite a tricky leak where we would end up retaining stale ModDetails due to rehydrating modules against non-finalised interfaces. == Loops with multiple boot files It is possible for a module graph to have a loop (SCC, when ignoring boot files) which requires multiple boot files to break. In this case we must perform the necessary hydration steps before and after compiling modules which have boot files which are described above for corectness but also perform an additional hydration step at the end of the SCC to remove space leaks. Consider the following example: ┌───────┐ ┌───────┐ │ │ │ │ │ A │ │ B │ │ │ │ │ └─────┬─┘ └───┬───┘ │ │ ┌────▼─────────▼──┐ │ │ │ C │ └────┬─────────┬──┘ │ │ ┌────▼──┐ ┌───▼───┐ │ │ │ │ │ A-boot│ │ B-boot│ │ │ │ │ └───────┘ └───────┘ A, B and C live together in a SCC. Say we compile the modules in order A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps (because A has a boot file). Therefore C will be hydrated relative to A, and the ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again, and so B will reference C/A,B, its interface will be hydrated relative to both A and B. Now there is a space leak because say C is a very big module, there are now two different copies of ModDetails kept alive by modules A and B. The way to avoid this space leak is to rehydrate an entire SCC together at the end of compilation so that all the ModDetails point to interfaces for .hs files. In this example, when we hydrate A, B and C together then both A and B will refer to C/A,B. See #21900 for some more discussion. ------------------------------------------------------- In addition to this simple case, there is also the potential for a leak during parallel upsweep which is also fixed by this patch. Transcibed is Note [ModuleNameSet, efficiency and space leaks] Note [ModuleNameSet, efficiency and space leaks] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ During unsweep the results of compiling modules are placed into a MVar, to find the environment the module needs to compile itself in the MVar is consulted and the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking module dependencies and recreating the HUG from scratch each time is very expensive. In serial mode (-j1), this all works out fine because a module can only be compiled after its dependencies have finished compiling and not interleaved with compiling module loops. Therefore when we create the finalised or no loop interfaces, the HUG only contains finalised interfaces. In parallel mode, we have to be more careful because the HUG variable can contain non-finalised interfaces which have been started by another thread. In order to avoid a space leak where a finalised interface is compiled against a HPT which contains a non-finalised interface we have to restrict the HUG to only the visible modules. The visible modules is recording in the ModuleNameSet, this is propagated upwards whilst compiling and explains which transitive modules are visible from a certain point. This set is then used to restrict the HUG before the module is compiled to only the visible modules and thus avoiding this tricky space leak. Efficiency of the ModuleNameSet is of utmost importance because a union occurs for each edge in the module graph. Therefore the set is represented directly as an IntSet which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode. See test "jspace" for an example which used to trigger this problem. Fixes #21900 - - - - - 1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00 Store interfaces in ModIfaceCache more directly I realised hydration was completely irrelavant for this cache because the ModDetails are pruned from the result. So now it simplifies things a lot to just store the ModIface and Linkable, which we can put into the cache straight away rather than wait for the final version of a HomeModInfo to appear. - - - - - 6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00 cmm: Remove unused ReadOnlyData16 We don't actually emit rodata16 sections anywhere. - - - - - 16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00 findExternalRules: Don't needlessly traverse the list of rules. - - - - - 52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00 Remove backported items from 9.6 release notes They have been backported to 9.4 in commits 5423d84bd9a28f, 13c81cb6be95c5, 67ccbd6b2d4b9b. - - - - - 78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00 ci: Fix pages job The job has been failing because we don't bundle haddock docs anymore in the docs dist created by hadrian. Fixes #21789 - - - - - 037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00 codeGen/X86: Don't clobber switch variable in switch generation Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was safe to clobber the switch variable when generating code for a jump table since we were at the end of a block. However, this assumption is wrong; the register could be live in the jump target. Fixes #21968. - - - - - 50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00 Fix equality operator in jspace test - - - - - e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Improve BUILD_PAP comments - - - - - 41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Make dropTail comment a haddock comment - - - - - ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Add one more sanity check in stg_restore_cccs - - - - - 1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00 StgToCmm: Fix isSimpleScrut when profiling is enabled. When profiling is enabled we must enter functions that might represent thunks in order for their sccs to show up in the profile. We might allocate even if the function is already evaluated in this case. So we can't consider any potential function thunk to be a simple scrut when profiling. Not doing so caused profiled binaries to segfault. - - - - - fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00 Change `-fprof-late` to insert cost centres after unfolding creation. The former behaviour of adding cost centres after optimization but before unfoldings are created is not available via the flag `prof-late-inline` instead. I also reduced the overhead of -fprof-late* by pushing the cost centres into lambdas. This means the cost centres will only account for execution of functions and not their partial application. Further I made LATE_CC cost centres it's own CC flavour so they now won't clash with user defined ones if a user uses the same string for a custom scc. LateCC: Don't put cost centres inside constructor workers. With -fprof-late they are rarely useful as the worker is usually inlined. Even if the worker is not inlined or we use -fprof-late-linline they are generally not helpful but bloat compile and run time significantly. So we just don't add sccs inside constructor workers. ------------------------- Metric Decrease: T13701 ------------------------- - - - - - f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00 gitlab-ci: Fix hadrian bootstrapping of release pipelines Previously we would attempt to test hadrian bootstrapping in the `validate` build flavour. However, `ci.sh` refuses to run validation builds during release pipelines, resulting in job failures. Fix this by testing bootstrapping in the `release` flavour during release pipelines. We also attempted to record perf notes for these builds, which is redundant work and undesirable now since we no longer build in a consistent flavour. - - - - - c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00 compiler: Eliminate two uses of foldr in favor of foldl' These two uses constructed maps, which is a case where foldl' is generally more efficient since we avoid constructing an intermediate O(n)-depth stack. - - - - - d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00 rts: Fix code style - - - - - 57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00 genprimopcode: Drop ArrayArray# references As ArrayArray# no longer exists - - - - - 7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00 base: Organize Haddocks in GHC.Conc.Sync - - - - - aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00 Add primop to list threads A user came to #ghc yesterday wondering how best to check whether they were leaking threads. We ended up using the eventlog but it seems to me like it would be generally useful if Haskell programs could query their own threads. - - - - - 6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00 rts: Move thread labels into TSO This eliminates the thread label HashTable and instead tracks this information in the TSO, allowing us to use proper StgArrBytes arrays for backing the label and greatly simplifying management of object lifetimes when we expose them to the user with the coming `threadLabel#` primop. - - - - - 1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00 Add a primop to query the label of a thread - - - - - 43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00 base: Share finalization thread label For efficiency's sake we float the thread label assigned to the finalization thread to the top-level, ensuring that we only need to encode the label once. - - - - - 1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00 users-guide: Add release notes entry for thread introspection support - - - - - 09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix binary distribution install attributes Previously we would use plain `cp` to install various parts of the binary distribution. However, `cp`'s behavior w.r.t. file attributes is quite unclear; for this reason it is much better to rather use `install`. Fixes #21965. - - - - - 2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00 hadrian: Fix installation of system-cxx-std-lib package conf - - - - - 7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00 gitlab-ci: Bump Docker images To give the ARMv7 job access to lld, fixing #21875. - - - - - afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Don't use mk/config.mk.in Ultimately we want to drop mk/config.mk so here I extract the bits needed by the Hadrian bindist installation logic into a Hadrian-specific file. While doing this I fixed binary distribution installation, #21901. - - - - - b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00 hadrian: Fix naming of cross-compiler wrappers - - - - - 78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00 hadrian: Extend xattr Darwin hack to cover /lib As noted in #21506, it is now necessary to remove extended attributes from `/lib` as well as `/bin` to avoid SIP issues on Darwin. Fixes #21506. - - - - - 20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00 NCG(x86): Compile add+shift as lea if possible. - - - - - 742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00 dataToTag#: Skip runtime tag check if argument is infered tagged This addresses one part of #21710. - - - - - 1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00 rts: remove redundant stg_traceCcszh This out-of-line primop has no Haskell wrapper and hasn't been used anywhere in the tree. Furthermore, the code gets in the way of !7632, so it should be garbage collected. - - - - - a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00 Document a divergence from the report in parsing function lhss. GHC is happy to parse `(f) x y = x + y` when it should be a parse error based on the Haskell report. Seems harmless enough so we won't fix it but it's documented now. Fixes #19788 - - - - - 5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00 gitlab-ci: Add release job for aarch64/debian 11 - - - - - 5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Introduce validation job for aarch64 cross-compilation Begins to address #11958. - - - - - e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00 Bump process submodule - - - - - ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00 gitlab-ci: Add basic support for cross-compiler testiing Here we add a simple qemu-based test for cross-compilers. - - - - - 50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00 rts: Ensure that Array# card arrays are initialized In #19143 I noticed that newArray# failed to initialize the card table of newly-allocated arrays. However, embarrassingly, I then only fixed the issue in newArrayArray# and, in so doing, introduced the potential for an integer underflow on zero-length arrays (#21962). Here I fix the issue in newArray#, this time ensuring that we do not underflow in pathological cases. Fixes #19143. - - - - - e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00 testsuite: Add test for #21962 - - - - - c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00 gitlab-ci: Don't use coreutils on Darwin In general we want to ensure that the tested environment is as similar as possible to the environment the user will use. In the case of Darwin, this means we want to use the system's BSD command-line utilities, not coreutils. This would have caught #21974. - - - - - 1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00 hadrian: Fix bindist installation on Darwin It turns out that `cp -P` on Darwin does not always copy a symlink as a symlink. In order to get these semantics one must pass `-RP`. It's not entirely clear whether this is valid under POSIX, but it is nevertheless what Apple does. - - - - - 681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00 hadrian: Fix access mode of installed package registration files Previously hadrian's bindist Makefile would modify package registrations placed by `install` via a shell pipeline and `mv`. However, the use of `mv` means that if umask is set then the user may otherwise end up with package registrations which are inaccessible. Fix this by ensuring that the mode is 0644. - - - - - e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00 Cleanups around pretty-printing * Remove hack when printing OccNames. No longer needed since e3dcc0d5 * Remove unused `pprCmms` and `instance Outputable Instr` * Simplify `pprCLabel` (no need to pass platform) * Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by ImmLit, but that can take just a String instead. * Remove instance `Outputable CLabel` - proper output of labels needs a platform, and is done by the `OutputableP` instance - - - - - 66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00 rts/linker: Resolve iconv_* on FreeBSD FreeBSD's libiconv includes an implementation of the iconv_* functions in libc. Unfortunately these can only be resolved using dlvsym, which is how the RTS linker usually resolves such functions. To fix this we include an ad-hoc special case for iconv_*. Fixes #20354. - - - - - 5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00 system-cxx-std-lib: Add support for FreeBSD libcxxrt - - - - - ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00 gitlab-ci: Bump to use freebsd13 runners - - - - - d71a2051 by sheaf at 2022-08-09T13:47:28-04:00 Fix size_up_alloc to account for UnliftedDatatypes The size_up_alloc function mistakenly considered any type that isn't lifted to not allocate anything, which is wrong. What we want instead is to check the type isn't boxed. This accounts for (BoxedRep Unlifted). Fixes #21939 - - - - - 76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00 testsuite: 21651 add test for closeFdWith + setNumCapabilities This bug does not affect windows, which does not use the base module GHC.Event.Thread. - - - - - 7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00 base: Fix races in IOManager (setNumCapabilities,closeFdWith) Fix for #21651 Fixes three bugs: - writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith. - The race in closeFdWith described in the ticket. - A race in getSystemEventManager where it accesses the 'IOArray' in 'eventManager' before 'ioManagerCapabilitiesChanged' has written to 'eventManager', causing an Array Index exception. The fix here is to 'yield' and retry. - - - - - dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00 Updates language extension documentation Adding a 'Status' field with a few values: - Deprecated - Experimental - InternalUseOnly - Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98' Those values are pulled from the existing descriptions or elsewhere in the documentation. While at it, include the :implied by: where appropriate, to provide more detail. Fixes #21475 - - - - - 823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00 hadrian RunRest: add type signature for stageNumber avoids warning seen on 9.4.1: src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults] • Defaulting the following constraints to type ‘Integer’ (Show a0) arising from a use of ‘show’ at src/Settings/Builders/RunTest.hs:264:53-84 (Num a0) arising from a use of ‘stageNumber’ at src/Settings/Builders/RunTest.hs:264:59-83 • In the second argument of ‘(++)’, namely ‘show (stageNumber (C.stage ctx))’ In the second argument of ‘($)’, namely ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’ In the expression: arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | 264 | , arg "-e", arg $ "config.stage=" ++ show (stageNumber (C.stage ctx)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ compilation tested locally - - - - - f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00 Add support for external static plugins (#20964) This patch adds a new command-line flag: -fplugin-library=<file-path>;<unit-id>;<module>;<args> used like this: -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"] It allows a plugin to be loaded directly from a shared library. With this approach, GHC doesn't compile anything for the plugin and doesn't load any .hi file for the plugin and its dependencies. As such GHC doesn't need to support two environments (one for plugins, one for target code), which was the more ambitious approach tracked in #14335. Fix #20964 Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Fix ARMv7 build It appears that the CI refactoring carried out in 5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some critical configuration: setting the build/host/target platforms and forcing use of a non-broken linker. - - - - - 596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00 gitlab-ci: Run ARMv7 jobs when ~ARM label is used - - - - - 7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00 hadrian: Don't attempt to install documentation if doc/ doesn't exist Previously we would attempt to install documentation even if the `doc` directory doesn't exist (e.g. due to `--docs=none`). This would result in the surprising side-effect of the entire contents of the bindist being installed in the destination documentation directory. Fix this. Fixes #21976. - - - - - 67575f20 by normalcoder at 2022-08-10T15:38:34-04:00 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms - - - - - 45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00 Note [Trimming auto-rules]: State that this improves compiler perf. - - - - - 5c24b1b3 by Bodigrim at 2022-08-10T22:41:50-04:00 Document that threadDelay / timeout are susceptible to overflows on 32-bit machines - - - - - ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00 EPA: DotFieldOcc does not have exact print annotations For the code {-# LANGUAGE OverloadedRecordUpdate #-} operatorUpdate f = f{(+) = 1} There are no exact print annotations for the parens around the + symbol, nor does normal ppr print them. This MR fixes that. Closes #21805 Updates haddock submodule - - - - - dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00 Revert "gitlab-ci: Add release job for aarch64/debian 11" This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46. The job was not tested before being merged and fails CI (https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392) Ticket #22005 - - - - - ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00 typo - - - - - cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00 CmmToLlvm: Don't aliasify builtin LLVM variables Our aliasification logic would previously turn builtin LLVM variables into aliases, which apparently confuses LLVM. This manifested in initializers failing to be emitted, resulting in many profiling failures with the LLVM backend. Fixes #22019. - - - - - dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00 run_ci: remove monoidal-containers Fixes #21492 MonoidalMap is inlined and used to implement Variables, as before. The top-level value "jobs" is reimplemented as a regular Map, since it doesn't use the monoidal union anyway. - - - - - 64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00 CmmToAsm/AArch64: correct a typo - - - - - f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00 Fix #21979 - compact-share failing with -O I don't have good reason to believe the optimization level should affect if sharing works or not here. So limit the test to the normal way. - - - - - 68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix reference to dead llvm-version substitution Fixes #22052. - - - - - 28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Fix incorrect reference to `:extension: role - - - - - 71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Add :ghc-flag: reference - - - - - 385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00 hadrian: Place manpage in docroot This relocates it from docs/ to doc/ - - - - - 84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00 Bump haddock submodule Includes merge of `main` into `ghc-head` as well as some Haddock users guide fixes. - - - - - 59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00 base: Add changelog entries from ghc-9.2 Closes #21922. - - - - - a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00 relnotes: Add "included libraries" section As noted in #21988, some users rely on this. - - - - - a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00 users-guide: Rephrase the rewrite rule documentation Previously the wording was a tad unclear. Fix this. Closes #21114. - - - - - 3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00 Implement Response File support for HPC This is an improvement to HPC authored by Richard Wallace (https://github.com/purefn) and myself. I have received permission from him to attempt to upstream it. This improvement was originally implemented as a patch to HPC via input-output-hk/haskell.nix: https://github.com/input-output-hk/haskell.nix/pull/1464 Paraphrasing Richard, HPC currently requires all inputs as command line arguments. With large projects this can result in an argument list too long error. I have only seen this error in Nix, but I assume it can occur is a plain Unix environment. This MR adds the standard response file syntax support to HPC. For example you can now pass a file to the command line which contains the arguments. ``` hpc @response_file_1 @response_file_2 ... The contents of a Response File must have this format: COMMAND ... example: report my_library.tix --include=ModuleA --include=ModuleB ``` Updates hpc submodule Co-authored-by: Richard Wallace <rwallace at thewallacepack.net> Fixes #22050 - - - - - 436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00 ghc-heap: Fix decoding of TSO closures An extra field was added to the TSO structure in 6d1700b6 but the decoding logic in ghc-heap was not updated for this new field. Fixes #22046 - - - - - a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00 driver: Honour -x option The -x option is used to manually specify which phase a file should be started to be compiled from (even if it lacks the correct extension). I just failed to implement this when refactoring the driver. In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to preprocess source files using GHC. I added a test to exercise this case. Fixes #22044 - - - - - e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00 Be more careful in chooseInferredQuantifiers This fixes #22065. We were failing to retain a quantifier that was mentioned in the kind of another retained quantifier. Easy to fix. - - - - - 714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00 testsuite: Add test for #21583 - - - - - 989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00 compiler: Drop --build-id=none hack Since 2011 the object-joining implementation has had a hack to pass `--build-id=none` to `ld` when supported, seemingly to work around a linker bug. This hack is now unnecessary and may break downstream users who expect objects to have valid build-ids. Remove it. Closes #22060. - - - - - 519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00 Make ru_fn field strict to avoid retaining Ids It's better to perform this projection from Id to Name strictly so we don't retain an old Id (hence IdInfo, hence Unfolding, hence everything etc) - - - - - 7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force `getOccFS bndr` to avoid retaining reference to Bndr. This is another symptom of #19619 - - - - - 4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00 Force unfoldings when they are cleaned-up in Tidy and CorePrep If these thunks are not forced then the entire unfolding for the binding is live throughout the whole of CodeGen despite the fact it should have been discarded. Fixes #22071 - - - - - 2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00 haddock docs: Fix links from identifiers to dependent packages When implementing the base_url changes I made the pretty bad mistake of zipping together two lists which were in different orders. The simpler thing to do is just modify `haddockDependencies` to also return the package identifier so that everything stays in sync. Fixes #22001 - - - - - 9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00 Revert "Refactor SpecConstr to use treat bindings uniformly" This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729. This refactoring introduced quite a severe residency regression (900MB live from 650MB live when compiling mmark), see #21993 for a reproducer and more discussion. Ticket #21993 - - - - - 9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00 tc: warn about lazy annotations on unlifted arguments (fixes #21951) - - - - - e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00 Fix #22048 where we failed to drop rules for -fomit-interface-pragmas. Now we also filter the local rules (again) which fixes the issue. - - - - - 51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00 Print constraints in quotes (#21167) This patch improves the uniformity of error message formatting by printing constraints in quotes, as we do for types. Fix #21167 - - - - - ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00 19217 Implicitly quantify type variables in :kind command - - - - - 9939e95f by MorrowM at 2022-08-21T16:51:38-04:00 Recognize file-header pragmas in GHCi (#21507) - - - - - fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00 hadrian: Fix bootstrapping with ghc-9.4 The error was that we were trying to link together containers from boot package library (which depends template-haskell in boot package library) template-haskell from in-tree package database So the fix is to build containers in stage0 (and link against template-haskell built in stage0). Fixes #21981 - - - - - b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00 Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942. * refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization * `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence * `ParensT` constructor is now always printed parenthesized * adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down * using `>=` instead of former `>` to match the Core type printing logic * some test outputs have changed, losing extraneous parentheses - - - - - fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00 Fix and test for issue #21723 - - - - - 33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00 Test for issue #21942 - - - - - c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00 Updated the changelog - - - - - 80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00 hadrian: Don't duplicate binaries on installation Previously we used `install` on symbolic links, which ended up copying the target file rather than installing a symbolic link. Fixes #22062. - - - - - b929063e by M Farkas-Dyck at 2022-08-24T02:37:01-04:00 Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`. Closes #22092. - - - - - 112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00 driver: don't actually merge objects when ar -L works - - - - - a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00 rts: Consistently use MiB in stats output Previously we would say `MB` even where we meant `MiB`. - - - - - a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00 Fix arityType: -fpedantic-bottoms, join points, etc This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223 - - - - - 909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00 upload_ghc_libs: Add means of passing Hackage credentials - - - - - 28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00 Scrub some partiality in `CommonBlockElim`. - - - - - 54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00 hadrian: Fix whitespace Previously this region of Settings.Packages was incorrectly indented. - - - - - c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00 validate: Drop --legacy flag In preparation for removal of the legacy `make`-based build system. - - - - - 822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00 gitlab-ci: Drop make build validation jobs In preparation for removal of the `make`-based build system - - - - - 6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop make build system Here we at long last remove the `make`-based build system, it having been replaced with the Shake-based Hadrian build system. Users are encouraged to refer to the documentation in `hadrian/doc` and this [1] blog post for details on using Hadrian. Closes #17527. [1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html - - - - - dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00 Remove testsuite/tests/perf/haddock/.gitignore As noted in #16802, this is no longer needed. Closes #16802. - - - - - fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop hc-build script This has not worked for many, many years and relied on the now-removed `make`-based build system. - - - - - 659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mkdirhier This is only used by nofib's dead `dist` target - - - - - 4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00 Drop mk/{build,install,config}.mk.in - - - - - 46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00 compiler: Drop comment references to make - - - - - d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add inits1 and tails1 to Data.List.NonEmpty See https://github.com/haskell/core-libraries-committee/issues/67 - - - - - 8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00 Add since annotations and changelog entries - - - - - 6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00 Fix redundant import This fixes a build error on x86_64-linux-alpine3_12-validate. See the function 'loadExternalPlugins' defined in this file. - - - - - 4786acf7 by sheaf at 2022-08-26T15:05:23-04:00 Pmc: consider any 2 dicts of the same type equal This patch massages the keys used in the `TmOracle` `CoreMap` to ensure that dictionaries of coherent classes give the same key. That is, whenever we have an expression we want to insert or lookup in the `TmOracle` `CoreMap`, we first replace any dictionary `$dict_abcd :: ct` with a value of the form `error @ct`. This allows us to common-up view pattern functions with required constraints whose arguments differed only in the uniques of the dictionaries they were provided, thus fixing #21662. This is a rather ad-hoc change to the keys used in the `TmOracle` `CoreMap`. In the long run, we would probably want to use a different representation for the keys instead of simply using `CoreExpr` as-is. This more ambitious plan is outlined in #19272. Fixes #21662 Updates unix submodule - - - - - f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00 Remove label style from printing context Previously, the SDocContext used for code generation contained information whether the labels should use Asm or C style. However, at every individual call site, this is known statically. This removes the parameter to 'PprCode' and replaces every 'pdoc' used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'. The OutputableP instance is now used only for dumps. The output of T15155 changes, it now uses the Asm style (which is faithful to what actually happens). - - - - - 1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00 boot: cleanup legacy args Cleanup legacy boot script args, following removal of the legacy make build system. - - - - - 95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00 Improve SpecConstr for evals As #21763 showed, we were over-specialising in some cases, when the function involved was doing a simple 'eval', but not taking the value apart, or branching on it. This MR fixes the problem. See Note [Do not specialise evals]. Nofib barely budges, except that spectral/cichelli allocates about 3% less. Compiler bytes-allocated improves a bit geo. mean -0.1% minimum -0.5% maximum +0.0% The -0.5% is on T11303b, for what it's worth. - - - - - 565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Revert "Revert "Refactor SpecConstr to use treat bindings uniformly"" This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8. This commit was originally reverted due to an increase in space usage. This was diagnosed as because the SCE increased in size and that was being retained by another leak. See #22102 - - - - - 82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Avoid retaining bindings via ModGuts held on the stack It's better to overwrite the bindings fields of the ModGuts before starting an iteration as then all the old bindings can be collected as soon as the simplifier has processed them. Otherwise we end up with the old bindings being alive until right at the end of the simplifier pass as the mg_binds field is only modified right at the end. - - - - - 64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00 Force imposs_deflt_cons in filterAlts This fixes a pretty serious space leak as the forced thunk would retain `Alt b` values which would then contain reference to a lot of old bindings and other simplifier gunk. The OtherCon unfolding was not forced on subsequent simplifier runs so more and more old stuff would be retained until the end of simplification. Fixing this has a drastic effect on maximum residency for the mmark package which goes from ``` 45,005,401,056 bytes allocated in the heap 17,227,721,856 bytes copied during GC 818,281,720 bytes maximum residency (33 sample(s)) 9,659,144 bytes maximum slop 2245 MiB total memory in use (0 MB lost due to fragmentation) ``` to ``` 45,039,453,304 bytes allocated in the heap 13,128,181,400 bytes copied during GC 331,546,608 bytes maximum residency (40 sample(s)) 7,471,120 bytes maximum slop 916 MiB total memory in use (0 MB lost due to fragmentation) ``` See #21993 for some more discussion. - - - - - a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00 Use Solo to avoid retaining the SCE but to avoid performing the substitution The use of Solo here allows us to force the selection into the SCE to obtain the Subst but without forcing the substitution to be applied. The resulting thunk is placed into a lazy field which is rarely forced, so forcing it regresses peformance. - - - - - 161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00 Fix a nasty loop in Tidy As the remarkably-simple #22112 showed, we were making a black hole in the unfolding of a self-recursive binding. Boo! It's a bit tricky. Documented in GHC.Iface.Tidy, Note [tidyTopUnfolding: avoiding black holes] - - - - - 68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnIllegalHsigDefaultMethods TcRnBadGenericMethod TcRnWarningMinimalDefIncomplete TcRnDefaultMethodForPragmaLacksBinding TcRnIgnoreSpecialisePragmaOnDefMethod TcRnBadMethodErr TcRnNoExplicitAssocTypeOrDefaultDeclaration - - - - - cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00 Fix a bug in anyInRnEnvR This bug was a subtle error in anyInRnEnvR, introduced by commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06 Author: Andreas Klebinger <klebinger.andreas at gmx.at> Date: Sat Jul 9 01:19:52 2022 +0200 Rule matching: Don't compute the FVs if we don't look at them. The net result was #22028, where a rewrite rule would wrongly match on a lambda. The fix to that function is easy. - - - - - 0154bc80 by sheaf at 2022-08-30T06:05:41-04:00 Various Hadrian bootstrapping fixes - Don't always produce a distribution archive (#21629) - Use correct executable names for ghc-pkg and hsc2hs on windows (we were missing the .exe file extension) - Fix a bug where we weren't using the right archive format on Windows when unpacking the bootstrap sources. Fixes #21629 - - - - - 451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00 ci: Attempt using normal submodule cloning strategy We do not use any recursively cloned submodules, and this protects us from flaky upstream remotes. Fixes #22121 - - - - - 9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: stray "--" - - - - - 3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00 Fix typo in Any docs: syntatic -> syntactic - - - - - 7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00 Add a missing trimArityType This buglet was exposed by #22114, a consequence of my earlier refactoring of arity for join points. - - - - - e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump binary submodule to 0.8.9.1 - - - - - 4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00 Bump stm submodule to 2.5.1.0 - - - - - 837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00 users-guide: Document system-cxx-std-lib - - - - - f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00 Update submodule containers to 0.6.6 - - - - - 4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00 Update submodule process to 1.6.15.0 - - - - - 1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00 Bump directory submodule to 1.3.7.1 - - - - - 7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00 Bump text submodule to 2.0.1 - - - - - fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00 Bump deepseq submodule to 1.4.8.0 - - - - - a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00 Add dates to base, ghc-prim changelogs - - - - - 2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00 Update autoconf scripts Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983 - - - - - e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00 Bump bytestring submodule to 0.11.3.1 - - - - - f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00 Update submodule Cabal to tag Cabal-v3.8.1.0 closes #21931 - - - - - e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00 Refine in-tree compiler args for --test-compiler=stage1 Some of the logic to calculate in-tree arguments was not correct for the stage1 compiler. Namely we were not correctly reporting whether we were building static or dynamic executables and whether debug assertions were enabled. Fixes #22096 - - - - - 6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00 Make ghcDebugAssertions into a Stage predicate (Stage -> Bool) We also care whether we have debug assertions enabled for a stage one compiler, but the way which we turned on the assertions was quite different from the stage2 compiler. This makes the logic for turning on consistent across both and has the advantage of being able to correct determine in in-tree args whether a flavour enables assertions or not. Ticket #22096 - - - - - 15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00 Add regression test for #21550 This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5 "Use local instances with least superclass depth" - - - - - 7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00 Minor cleanup - Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused), isCoVar_maybe (duplicated by getCoVar_maybe) - Replace a few occurrences of voidPrimId with (# #). void# is a deprecated synonym for the unboxed tuple. - Use showSDoc in :show linker. This makes it consistent with the other :show commands - - - - - 31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00 Change Ord defaults per CLC proposal Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267 - - - - - 7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00 Fix bootstrap with ghc-9.0 It turns out Solo is a very recent addition to base, so for older GHC versions we just defined it inline here the one place we use it in the compiler. - - - - - d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00 DmdAnal: Don't panic in addCaseBndrDmd (#22039) Rather conservatively return Top. See Note [Untyped demand on case-alternative binders]. I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and `fieldBndrDmds`. Fixes #22039. - - - - - 25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00 gitlab-ci: Ensure that ghc derivation is in scope Previously the lint-ci job attempted to use cabal-install (specifically `cabal update`) without a GHC in PATH. However, cabal-install-3.8 appears to want GHC, even for `cabal update`. - - - - - f37b621f by sheaf at 2022-09-06T11:51:53+00:00 Update instances.rst, clarifying InstanceSigs Fixes #22103 - - - - - d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00 Fix :add docs in user guide - - - - - 808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00 ci: remove unused build_make/test_make in ci script - - - - - d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00 typo - - - - - fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00 typos - - - - - a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00 whitespace - - - - - 04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00 CmmToAsm: remove unused ModLocation from NatM_State - - - - - ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Minor SDoc cleanup Change calls to renderWithContext with showSDocOneLine; it's more efficient and explanatory. Remove polyPatSig (unused) - - - - - 7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00 Remove Outputable Char instance Use 'text' instead of 'ppr'. Using 'ppr' on the list "hello" rendered as "h,e,l,l,o". - - - - - 77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Export liftA2 from Prelude Changes: In order to be warning free and compatible, we hide Applicative(..) from Prelude in a few places and instead import it directly from Control.Applicative. Please see the migration guide at https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md for more details. This means that Applicative is now exported in its entirety from Prelude. Motivation: This change is motivated by a few things: * liftA2 is an often used function, even more so than (<*>) for some people. * When implementing Applicative, the compiler will prompt you for either an implementation of (<*>) or of liftA2, but trying to use the latter ends with an error, without further imports. This could be confusing for newbies. * For teaching, it is often times easier to introduce liftA2 first, as it is a natural generalisation of fmap. * This change seems to have been unanimously and enthusiastically accepted by the CLC members, possibly indicating a lot of love for it. * This change causes very limited breakage, see the linked issue below for an investigation on this. See https://github.com/haskell/core-libraries-committee/issues/50 for the surrounding discussion and more details. - - - - - 442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Add changelog entry for liftA2 export from Prelude - - - - - fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule containers to one with liftA2 warnings fixed - - - - - f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Bump submodule Cabal to one with liftA2 warnings fixed - - - - - a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00 Isolate some Applicative hidings to GHC.Prelude By reexporting the entirety of Applicative from GHC.Prelude, we can save ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude. This also has the benefit of isolating this type of change to GHC.Prelude, so that people in the future don't have to think about it. - - - - - 9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00 CmmToC: enable 64-bit CallishMachOp on 32-bit targets Normally, the unregisterised builds avoid generating 64-bit CallishMachOp in StgToCmm, so CmmToC doesn't support these. However, there do exist cases where we'd like to invoke cmmToC for other cmm inputs which may contain such CallishMachOps, and it's a rather low effort to add support for these since they only require calling into existing ghc-prim cbits. - - - - - 04062510 by Alexis King at 2022-09-11T11:30:32+02:00 Add native delimited continuations to the RTS This patch implements GHC proposal 313, "Delimited continuation primops", by adding native support for delimited continuations to the GHC RTS. All things considered, the patch is relatively small. It almost exclusively consists of changes to the RTS; the compiler itself is essentially unaffected. The primops come with fairly extensive Haddock documentation, and an overview of the implementation strategy is given in the Notes in rts/Continuation.c. This first stab at the implementation prioritizes simplicity over performance. Most notably, every continuation is always stored as a single, contiguous chunk of stack. If one of these chunks is particularly large, it can result in poor performance, as the current implementation does not attempt to cleverly squeeze a subset of the stack frames into the existing stack: it must fit all at once. If this proves to be a performance issue in practice, a cleverer strategy would be a worthwhile target for future improvements. - - - - - ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00 rts: fix missing dirty_MVAR argument in stg_writeIOPortzh - - - - - a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00 ci: enable parallel compression for xz - - - - - 3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00 Windows: Always define _UCRT when compiling C code As seen in #22159, this is required to ensure correct behavior when MinGW-w64 headers are in the `C_INCLUDE_PATH`. Fixes #22159. - - - - - 65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00 Add diagnostic codes This MR adds diagnostic codes, assigning unique numeric codes to error and warnings, e.g. error: [GHC-53633] Pattern match is redundant This is achieved as follows: - a type family GhcDiagnosticCode that gives the diagnostic code for each diagnostic constructor, - a type family ConRecursInto that specifies whether to recur into an argument of the constructor to obtain a more fine-grained code (e.g. different error codes for different 'deriving' errors), - generics machinery to generate the value-level function assigning each diagnostic its error code; see Note [Diagnostic codes using generics] in GHC.Types.Error.Codes. The upshot is that, to add a new diagnostic code, contributors only need to modify the two type families mentioned above. All logic relating to diagnostic codes is thus contained to the GHC.Types.Error.Codes module, with no code duplication. This MR also refactors error message datatypes a bit, ensuring we can derive Generic for them, and cleans up the logic around constraint solver reports by splitting up 'TcSolverReportInfo' into separate datatypes (see #20772). Fixes #21684 - - - - - 362cca13 by sheaf at 2022-09-13T10:27:53-04:00 Diagnostic codes: acccept test changes The testsuite output now contains diagnostic codes, so many tests need to be updated at once. We decided it was best to keep the diagnostic codes in the testsuite output, so that contributors don't inadvertently make changes to the diagnostic codes. - - - - - 08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00 Allow imports to reference multiple fields with the same name (#21625) If a module `M` exports two fields `f` (using DuplicateRecordFields), we can still accept import M (f) import M hiding (f) and treat `f` as referencing both of them. This was accepted in GHC 9.0, but gave rise to an ambiguity error in GHC 9.2. See #21625. This patch also documents this behaviour in the user's guide, and updates the test for #16745 which is now treated differently. - - - - - c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00 ci: remove unused appveyor config - - - - - dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00 compiler: remove unused lazy state monad - - - - - 646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00 Fix typos This fixes various typos and spelling mistakes in the compiler. Fixes #21891 - - - - - 7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00 hadrian: Bump index state This bumps the index state so a build plan can also be found when booting with 9.4. Fixes #22165 - - - - - 98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Use a stamp file to record when a package is built in a certain way Before this patch which library ways we had built wasn't recorded directly. So you would run into issues if you build the .conf file with some library ways before switching the library ways which you wanted to build. Now there is one stamp file for each way, so in order to build a specific way you can need that specific stamp file rather than going indirectly via the .conf file. - - - - - b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Inplace/Final package databases There are now two different package databases per stage. An inplace package database contains .conf files which point directly into the build directories. The final package database contains .conf files which point into the installed locations. The inplace .conf files are created before any building happens and have fake ABI hash values. The final .conf files are created after a package finished building and contains the proper ABI has. The motivation for this is to make the dependency structure more fine-grained when building modules. Now a module depends just depends directly on M.o from package p rather than the .conf file depend on the .conf file for package p. So when all of a modules direct dependencies have finished building we can start building it rather than waiting for the whole package to finish. The secondary motivation is that the multi-repl doesn't need to build everything before starting the multi-repl session. We can just configure the inplace package-db and use that in order to start the repl. - - - - - 6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add some more packages to multi-cradle The main improvement here is to pass `-this-unit-id` for executables so that they can be added to the multi-cradle if desired as well as normal library packages. - - - - - e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Need builders needed by Cabal Configure in parallel Because of the use of withStaged (which needs the necessary builder) when configuring a package, the builds of stage1:exe:ghc-bin and stage1:exe:ghc-pkg where being linearised when building a specific target like `binary-dist-dir`. Thankfully the fix is quite local, to supply all the `withStaged` arguments together so the needs can be batched together and hence performed in parallel. Fixes #22093 - - - - - c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00 Remove stage1:exe:ghc-bin pre-build from CI script CI builds stage1:exe:ghc-bin before the binary-dist target which introduces some quite bad linearisation (see #22093) because we don't build stage1 compiler in parallel with anything. Then when the binary-dist target is started we have to build stage1:exe:ghc-pkg before doing anything. Fixes #22094 - - - - - 71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00 hadrian: Add extra implicit dependencies from DeriveLift ghc -M should know that modules which use DeriveLift (or TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have to add these extra edges manually or the modules will be compiled before TH.Lib.Internal is compiled which leads to a desugarer error. - - - - - 43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00 Repair c++ probing on OpenBSD Failure without this change: ``` checking C++ standard library flavour... libc++ checking for linkage against 'c++ c++abi'... failed checking for linkage against 'c++ cxxrt'... failed configure: error: Failed to find C++ standard library ``` - - - - - 534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00 libraries: template-haskell: vendor filepath differently Vendoring with ../ in hs-source-dirs prevents upload to hackage. (cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842) - - - - - bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00 Unbreak Hadrian with Cabal 3.8. - - - - - df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00 Fix typos - - - - - d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00 Tag inference: Fix #21954 by retaining tagsigs of vars in function position. For an expression like: case x of y Con z -> z If we also retain the tag sig for z we can generate code to immediately return it rather than calling out to stg_ap_0_fast. - - - - - 7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00 Stg.InferTags.Rewrite - Avoid some thunks. - - - - - 88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: enable -fprof-late only for profiling ways - - - - - d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00 hadrian: add late_ccs flavour transformer - - - - - ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00 configure: remove unused program checks - - - - - 9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00 Update to Unicode 15.0 - - - - - c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00 Avoid partial head and tail in ghc-heap; replace with total pattern-matching - - - - - 616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00 hadrian: relax Cabal upper bound to allow building with Cabal-3.8 A follow up of !8910. - - - - - df35d994 by Alexis King at 2022-09-16T14:01:11-04:00 Add links to the continuations haddocks in the docs for each primop fixes #22176 - - - - - 383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00 -Wunused-pattern-binds: Recurse into patterns to check whether there's a splice See the examples in #22057 which show we have to traverse deeply into a pattern to determine whether it contains a splice or not. The original implementation pointed this out but deemed this very shallow traversal "too expensive". Fixes #22057 I also fixed an oversight in !7821 which meant we lost a warning which was present in 9.2.2. Fixes #22067 - - - - - 5031bf49 by sheaf at 2022-09-16T21:42:49-04:00 Hadrian: Don't try to build terminfo on Windows Commit b42cedbe introduced a dependency on terminfo on Windows, but that package isn't available on Windows. - - - - - c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00 Clean up some. In particular: • Delete some dead code, largely under `GHC.Utils`. • Clean up a few definitions in `GHC.Utils.(Misc, Monad)`. • Clean up `GHC.Types.SrcLoc`. • Derive stock `Functor, Foldable, Traversable` for more types. • Derive more instances for newtypes. Bump haddock submodule. - - - - - 85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00 driver: pass original Cmm filename in ModLocation When compiling Cmm, the ml_hs_file field is used to indicate Cmm filename when later generating DWARF information. We should pass the original filename here, otherwise for preprocessed Cmm files, the filename will be a temporary filename which is confusing. - - - - - 63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: remove legacy logging cabal flag - - - - - bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00 rts: make threaded ways optional For certain targets (e.g. wasm32-wasi), the threaded rts is known not to work. This patch adds a "threaded" cabal flag to rts to make threaded rts ways optional. Hadrian enables this flag iff the flavour rtsWays contains threaded ways. - - - - - 8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00 DeriveFunctor: Check for last type variables using dataConUnivTyVars Previously, derived instances of `Functor` (as well as the related classes `Foldable`, `Traversable`, and `Generic1`) would determine which constraints to infer by checking for fields that contain the last type variable. The problem was that this last type variable was taken from `tyConTyVars`. For GADTs, the type variables in each data constructor are _not_ the same type variables as in `tyConTyVars`, leading to #22167. This fixes the issue by instead checking for the last type variable using `dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185, which also replaced an errant use of `tyConTyVars` with type variables from each data constructor.) Fixes #22167. - - - - - 78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: pass updated buffer to actions (#22201) In the lexer, predicates have the following type: { ... } :: user -- predicate state -> AlexInput -- input stream before the token -> Int -- length of the token -> AlexInput -- input stream after the token -> Bool -- True <=> accept the token This is documented in the Alex manual. There is access to the input stream both before and after the token. But when the time comes to construct the token, GHC passes only the initial string buffer to the lexer action. This patch fixes it: - type Action = PsSpan -> StringBuffer -> Int -> P (PsLocated Token) + type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token) Now lexer actions have access to the string buffer both before and after the token, just like the predicates. It's just a matter of passing an additional function parameter throughout the lexer. - - - - - 75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00 Lexer: define varsym without predicates (#22201) Before this patch, the varsym lexing rules were defined as follows: <0> { @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix } @varsym / { followedByOpeningToken } { varsym_prefix } @varsym / { precededByClosingToken } { varsym_suffix } @varsym { varsym_loose_infix } } Unfortunately, this meant that the predicates 'precededByClosingToken' and 'followedByOpeningToken' were recomputed several times before we could figure out the whitespace context. With this patch, we check for whitespace context directly in the lexer action: <0> { @varsym { with_op_ws varsym } } The checking for opening/closing tokens happens in 'with_op_ws' now, which is part of the lexer action rather than the lexer predicate. - - - - - c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00 Scrub partiality about `NewOrData`. Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor. Closes #22070. Bump haddock submodule. - - - - - 1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00 CmmToC: emit __builtin_unreachable() after noreturn ccalls Emit a __builtin_unreachable() call after a foreign call marked as CmmNeverReturns. This is crucial to generate correctly typed code for wasm; as for other archs, this is also beneficial for the C compiler optimizations. - - - - - 19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00 Document :unadd GHCi command in user guide - - - - - 545ff490 by sheaf at 2022-09-20T03:50:06-04:00 Hadrian: merge archives even in stage 0 We now always merge .a archives when ar supports -L. This change is necessary in order to bootstrap GHC using GHC 9.4 on Windows, as nested archives aren't supported. Not doing so triggered bug #21990 when trying to use the Win32 package, with errors such as: Not a x86_64 PE+ file. Unknown COFF 4 type in getHeaderInfo. ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info We have to be careful about which ar is meant: in stage 0, the check should be done on the system ar (system-ar in system.config). - - - - - 59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00 Fix -Woperator-whitespace for consym (part of #19372) Due to an oversight, the initial specification and implementation of -Woperator-whitespace focused on varsym exclusively and completely ignored consym. This meant that expressions such as "x+ y" would produce a warning, while "x:+ y" would not. The specification was corrected in ghc-proposals pull request #404, and this patch updates the implementation accordingly. Regression test included. - - - - - c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00 Add `Eq` and `Ord` instances for `Generically1` These are needed so the subsequent commit overhauling the `*1` classes type-checks. - - - - - 7beb356e by John Ericson at 2022-09-20T13:11:50-04:00 Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking This change is approved by the Core Libraries commitee in https://github.com/haskell/core-libraries-committee/issues/10 The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for `Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`. These have the proper flexible contexts that are exactly what the instance needs: For example, instead of ```haskell instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where (==) = eq1 ``` we do ```haskell deriving instance Eq (f (g a)) => Eq (Compose f g a) ``` But, that change alone is rather breaking, because until now `Eq (f a)` and `Eq1 f` (and respectively the other classes and their `*1` equivalents too) are *incomparable* constraints. This has always been an annoyance of working with the `*1` classes, and now it would rear it's head one last time as an pesky migration. Instead, we give the `*1` classes superclasses, like so: ```haskell (forall a. Eq a => Eq (f a)) => Eq1 f ``` along with some laws that canonicity is preserved, like: ```haskell liftEq (==) = (==) ``` and likewise for `*2` classes: ```haskell (forall a. Eq a => Eq1 (f a)) => Eq2 f ``` and laws: ```haskell liftEq2 (==) = liftEq1 ``` The `*1` classes also have default methods using the `*2` classes where possible. What this means, as explained in the docs, is that `*1` classes really are generations of the regular classes, indicating that the methods can be split into a canonical lifting combined with a canonical inner, with the super class "witnessing" the laws[1] in a fashion. Circling back to the pragmatics of migrating, note that the superclass means evidence for the old `Sum`, `Product`, and `Compose` instances is (more than) sufficient, so breakage is less likely --- as long no instances are "missing", existing polymorphic code will continue to work. Breakage can occur when a datatype implements the `*1` class but not the corresponding regular class, but this is almost certainly an oversight. For example, containers made that mistake for `Tree` and `Ord`, which I fixed in https://github.com/haskell/containers/pull/761, but fixing the issue by adding `Ord1` was extremely *un*controversial. `Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show` instances. It is unlikely this would have been caught without implementing this change. ----- [1]: In fact, someday, when the laws are part of the language and not only documentation, we might be able to drop the superclass field of the dictionary by using the laws to recover the superclass in an instance-agnostic manner, e.g. with a *non*-overloaded function with type: ```haskell DictEq1 f -> DictEq a -> DictEq (f a) ``` But I don't wish to get into optomizations now, just demonstrate the close relationship between the law and the superclass. Bump haddock submodule because of test output changing. - - - - - 6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00 Add notes to ghc-prim Haddocks that users should not import it - - - - - ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00 docs: clarify that LLVM codegen is not available in unregisterised mode The current docs are misleading and suggest that it is possible to use LLVM codegen from an unregisterised build. This is not the case; attempting to pass `-fllvm` to an unregisterised build warns: ``` when making flags consistent: warning: Target platform uses unregisterised ABI, so compiling via C ``` and uses the C codegen anyway. - - - - - 854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00 rts: remove copy-paste error from `cabal.rts.in` This was, likely accidentally, introduced in 4bf542bf1c. See: 4bf542bf1cdf2fa468457fc0af21333478293476 - - - - - c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00 hadrian: Add extra_dependencies edges for all different ways The hack to add extra dependencies needed by DeriveLift extension missed the cases for profiles and dynamic ways. For the profiled way this leads to errors like: ``` GHC error in desugarer lookup in Data.IntSet.Internal: Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’ Perhaps you haven't installed the profiling libraries for package ‘template-haskell’? Use -v (or `:set -v` in ghci) to see a list of the files searched for. ghc: panic! (the 'impossible' happened) GHC version 9.5.20220916: initDs ``` Therefore the fix is to add these extra edges in. Fixes #22197 - - - - - a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00 users-guide: fix incorrect ghcappdata folder for unix and windows - - - - - 06ccad0d by sheaf at 2022-09-21T08:28:49-04:00 Don't use isUnliftedType in isTagged The function GHC.Stg.InferTags.Rewrite.isTagged can be given the Id of a join point, which might be representation polymorphic. This would cause the call to isUnliftedType to crash. It's better to use typeLevity_maybe instead. Fixes #22212 - - - - - c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00 Add fragmentation statistic to GHC.Stats Implements #21537 - - - - - 2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00 Rename Solo[constructor] to MkSolo Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst) Moves all tuples to GHC.Tuple.Prim Updates ghc-prim version (and bumps bounds in dependents) updates haddock submodule updates deepseq submodule updates text submodule - - - - - 9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00 Update filepath to filepath-1.4.100.0 Updates submodule * Always rely on vendored filepath * filepath must be built as stage0 dependency because it uses template-haskell. Towards #22098 - - - - - 615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00 Minor refactor around Outputable * Replace 'text . show' and 'ppr' with 'int'. * Remove Outputable.hs-boot, no longer needed * Use pprWithCommas * Factor out instructions in AArch64 codegen - - - - - aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00 Demand: Clear distinction between Call SubDmd and eval Dmd (#21717) In #21717 we saw a reportedly unsound strictness signature due to an unsound definition of plusSubDmd on Calls. This patch contains a description and the fix to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`. This fix means we also get rid of the special handling of `-fpedantic-bottoms` in eta-reduction. Thanks to less strict and actually sound strictness results, we will no longer eta-reduce the problematic cases in the first place, even without `-fpedantic-bottoms`. So fixing the unsoundness also makes our eta-reduction code simpler with less hacks to explain. But there is another, more unfortunate side-effect: We *unfix* #21085, but fortunately we have a new fix ready: See `Note [mkCall and plusSubDmd]`. There's another change: I decided to make `Note [SubDemand denotes at least one evaluation]` a lot simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument demands are lazy. That leads to less precise results, but in turn rids ourselves from the need for 4 different `OpMode`s and the complication of `Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code that is in line with the paper draft on Demand Analysis. I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for posterity. The fallout in terms of regressions is negligible, as the testsuite and NoFib shows. ``` Program Allocs Instrs -------------------------------------------------------------------------------- hidden +0.2% -0.2% linear -0.0% -0.7% -------------------------------------------------------------------------------- Min -0.0% -0.7% Max +0.2% +0.0% Geometric Mean +0.0% -0.0% ``` Fixes #21717. - - - - - 9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00 implement proposal 106 (Define Kinds Without Promotion) (fixes #6024) includes corresponding changes to haddock submodule - - - - - c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00 Apply some tricks to speed up core lint. Below are the noteworthy changes and if given their impact on compiler allocations for a type heavy module: * Use the oneShot trick on LintM * Use a unboxed tuple for the result of LintM: ~6% reduction * Avoid a thunk for the result of typeKind in lintType: ~5% reduction * lint_app: Don't allocate the error msg in the hot code path: ~4% reduction * lint_app: Eagerly force the in scope set: ~4% * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2% * lintM: Use a unboxed maybe for the `a` result: ~12% * lint_app: make go_app tail recursive to avoid allocating the go function as heap closure: ~7% * expandSynTyCon_maybe: Use a specialized data type For a less type heavy module like nofib/spectral/simple compiled with -O -dcore-lint allocations went down by ~24% and compile time by ~9%. ------------------------- Metric Decrease: T1969 ------------------------- - - - - - b74b6191 by sheaf at 2022-09-28T15:08:10-04:00 matchLocalInst: do domination analysis When multiple Given quantified constraints match a Wanted, and there is a quantified constraint that dominates all others, we now pick it to solve the Wanted. See Note [Use only the best matching quantified constraint]. For example: [G] d1: forall a b. ( Eq a, Num b, C a b ) => D a b [G] d2: forall a . C a Int => D a Int [W] {w}: D a Int When solving the Wanted, we find that both Givens match, but we pick the second, because it has a weaker precondition, C a Int, compared to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1; see Note [When does a quantified instance dominate another?]. This domination test is done purely in terms of superclass expansion, in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt to do a full round of constraint solving; this simple check suffices for now. Fixes #22216 and #22223 - - - - - 2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Improve aggressive specialisation This patch fixes #21286, by not unboxing dictionaries in worker/wrapper (ever). The main payload is tiny: * In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox dictionaries in `get_dmd`. See Note [Do not unbox class dictionaries] in that module * I also found that imported wrappers were being fruitlessly specialised, so I fixed that too, in canSpecImport. See Note [Specialising imported functions] point (2). In doing due diligence in the testsuite I fixed a number of other things: * Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make, and Note [Inline specialisations] in GHC.Core.Opt.Specialise, and remove duplication between the two. The new Note describes how we specialise functions with an INLINABLE pragma. And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`. * Improve Note [Worker/wrapper for INLINABLE functions] in GHC.Core.Opt.WorkWrap. And (critially) make an actual change which is to propagate the user-written pragma from the original function to the wrapper; see `mkStrWrapperInlinePrag`. * Write new Note [Specialising imported functions] in GHC.Core.Opt.Specialise All this has a big effect on some compile times. This is compiler/perf, showing only changes over 1%: Metrics: compile_time/bytes allocated ------------------------------------- LargeRecord(normal) -50.2% GOOD ManyConstructors(normal) +1.0% MultiLayerModulesTH_OneShot(normal) +2.6% PmSeriesG(normal) -1.1% T10547(normal) -1.2% T11195(normal) -1.2% T11276(normal) -1.0% T11303b(normal) -1.6% T11545(normal) -1.4% T11822(normal) -1.3% T12150(optasm) -1.0% T12234(optasm) -1.2% T13056(optasm) -9.3% GOOD T13253(normal) -3.8% GOOD T15164(normal) -3.6% GOOD T16190(normal) -2.1% T16577(normal) -2.8% GOOD T16875(normal) -1.6% T17836(normal) +2.2% T17977b(normal) -1.0% T18223(normal) -33.3% GOOD T18282(normal) -3.4% GOOD T18304(normal) -1.4% T18698a(normal) -1.4% GOOD T18698b(normal) -1.3% GOOD T19695(normal) -2.5% GOOD T5837(normal) -2.3% T9630(normal) -33.0% GOOD WWRec(normal) -9.7% GOOD hard_hole_fits(normal) -2.1% GOOD hie002(normal) +1.6% geo. mean -2.2% minimum -50.2% maximum +2.6% I diligently investigated some of the big drops. * Caused by not doing w/w for dictionaries: T13056, T15164, WWRec, T18223 * Caused by not fruitlessly specialising wrappers LargeRecord, T9630 For runtimes, here is perf/should+_run: Metrics: runtime/bytes allocated -------------------------------- T12990(normal) -3.8% T5205(normal) -1.3% T9203(normal) -10.7% GOOD haddock.Cabal(normal) +0.1% haddock.base(normal) -1.1% haddock.compiler(normal) -0.3% lazy-bs-alloc(normal) -0.2% ------------------------------------------ geo. mean -0.3% minimum -10.7% maximum +0.1% I did not investigate exactly what happens in T9203. Nofib is a wash: +-------------------------------++--+-----------+-----------+ | || | tsv (rel) | std. err. | +===============================++==+===========+===========+ | real/anna || | -0.13% | 0.0% | | real/fem || | +0.13% | 0.0% | | real/fulsom || | -0.16% | 0.0% | | real/lift || | -1.55% | 0.0% | | real/reptile || | -0.11% | 0.0% | | real/smallpt || | +0.51% | 0.0% | | spectral/constraints || | +0.20% | 0.0% | | spectral/dom-lt || | +1.80% | 0.0% | | spectral/expert || | +0.33% | 0.0% | +===============================++==+===========+===========+ | geom mean || | | | +-------------------------------++--+-----------+-----------+ I spent quite some time investigating dom-lt, but it's pretty complicated. See my note on !7847. Conclusion: it's just a delicate inlining interaction, and we have plenty of those. Metric Decrease: LargeRecord T13056 T13253 T15164 T16577 T18223 T18282 T18698a T18698b T19695 T9630 WWRec hard_hole_fits T9203 - - - - - addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 Refactor UnfoldingSource and IfaceUnfolding I finally got tired of the way that IfaceUnfolding reflected a previous structure of unfoldings, not the current one. This MR refactors UnfoldingSource and IfaceUnfolding to be simpler and more consistent. It's largely just a refactor, but in UnfoldingSource (which moves to GHC.Types.Basic, since it is now used in IfaceSyn too), I distinguish between /user-specified/ and /system-generated/ stable unfoldings. data UnfoldingSource = VanillaSrc | StableUserSrc -- From a user-specified pragma | StableSystemSrc -- From a system-generated unfolding | CompulsorySrc This has a minor effect in CSE (see the use of isisStableUserUnfolding in GHC.Core.Opt.CSE), which I tripped over when working on specialisation, but it seems like a Good Thing to know anyway. - - - - - 7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00 INLINE/INLINEABLE pragmas in Foreign.Marshal.Array Foreign.Marshal.Array contains many small functions, all of which are overloaded, and which are critical for performance. Yet none of them had pragmas, so it was a fluke whether or not they got inlined. This patch makes them all either INLINE (small ones) or INLINEABLE and hence specialisable (larger ones). See Note [Specialising array operations] in that module. - - - - - b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00 Export OnOff from GHC.Driver.Session I was working on fixing an issue where HLS was trying to pass its DynFlags to HLint, but didn't pass any of the disabled language extensions, which HLint would then assume are on because of their default values. Currently it's not possible to get any of the "No" flags because the `DynFlags.extensions` field can't really be used since it is [OnOff Extension] and OnOff is not exported. So let's export it. - - - - - 2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00 Avoid Data.List.group; prefer Data.List.NonEmpty.group This allows to avoid further partiality, e. g., map head . group is replaced by map NE.head . NE.group, and there are less panic calls. - - - - - bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00 Clean up `findWiredInUnit`. In particular, avoid `head`. - - - - - 6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00 Eliminate headFS, use unconsFS instead A small step towards #22185 to avoid partial functions + safe implementation of `startsWithUnderscore`. - - - - - 5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00 Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231) Justification in #22231. Short form: In a demand like `1C1(C1(L))` it was too easy to confuse which `1` belongs to which `C`. Now that should be more obvious. Fixes #22231 - - - - - ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00 Revert "ci: enable parallel compression for xz" Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners. This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab. - - - - - f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00 Boxity: Don't update Boxity unless worker/wrapper follows (#21754) A small refactoring in our Core Opt pipeline and some new functions for transfering argument boxities from one signature to another to facilitate `Note [Don't change boxity without worker/wrapper]`. Fixes #21754. - - - - - 4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00 Scrub various partiality involving empty lists. Avoids some uses of `head` and `tail`, and some panics when an argument is null. - - - - - 95ead839 by Alexis King at 2022-10-01T00:37:43-04:00 Fix a bug in continuation capture across multiple stack chunks - - - - - 22096652 by Bodigrim at 2022-10-01T00:38:22-04:00 Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc `viewCons` used to ignore `Many` constructor completely, returning `VNothing`. `viewSnoc` violated internal invariant of `Many` being a non-empty list. - - - - - 48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00 chore: extend `.editorconfig` for C files - - - - - b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00 Fix docs for pattern synonyms - - - - - 463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00 Use sameByteArray# in sameByteArray - - - - - fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00 Minor fixes following Unicode 15.0.0 update - Fix changelog for Unicode 15.0.0 - Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell". - - - - - 8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00 rts: don't enforce aligned((8)) on 32-bit targets We simply need to align to the word size for pointer tagging to work. On 32-bit targets, aligned((8)) is wasteful. - - - - - 532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00 Export symbolSing, SSymbol, and friends (CLC#85) This implements this Core Libraries Proposal: https://github.com/haskell/core-libraries-committee/issues/85 In particular, it: 1. Exposes the `symbolSing` method of `KnownSymbol`, 2. Exports the abstract `SSymbol` type used in `symbolSing`, and 3. Defines an API for interacting with `SSymbol`. This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and `charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2) of #21568. - - - - - d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00 Remove mention of make from README.md - - - - - 945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00 Add a newline before since pragma in Data.Array.Byte - - - - - 44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00 Parser/PostProcess: rename failOp* functions There are three functions named failOp* in the parser: failOpNotEnabledImportQualifiedPost failOpImportQualifiedTwice failOpFewArgs Only the last one has anything to do with operators. The other two were named this way either by mistake or due to a misunderstanding of what "op" stands for. This small patch corrects this. - - - - - 96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00 Make rewrite rules "win" over inlining If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961 - - - - - ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00 Utils.JSON: do not escapeJsonString in ToJson String instance as `escapeJsonString` is used in `renderJSON`, so the `JSString` constructor is meant to carry the unescaped string. - - - - - fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Tidy implicit binds We want to put implicit binds into fat interface files, so the easiest thing to do seems to be to treat them uniformly with other binders. - - - - - e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00 Interface Files with Core Definitions This commit adds three new flags * -fwrite-if-simplified-core: Writes the whole core program into an interface file * -fbyte-code-and-object-code: Generate both byte code and object code when compiling a file * -fprefer-byte-code: Prefer to use byte-code if it's available when running TH splices. The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline at the point just after simplification and before code generation. Once compilation is restarted then code can be created for the byte code backend. This can significantly speed up start-times for projects in GHCi. HLS already implements its own version of these extended interface files for this reason. Preferring to use byte-code means that we can avoid some potentially expensive code generation steps (see #21700) * Producing object code is much slower than producing bytecode, and normally you need to compile with `-dynamic-too` to produce code in the static and dynamic way, the dynamic way just for Template Haskell execution when using a dynamically linked compiler. * Linking many large object files, which happens once per splice, can be quite expensive compared to linking bytecode. And you can get GHC to compile the necessary byte code so `-fprefer-byte-code` has access to it by using `-fbyte-code-and-object-code`. Fixes #21067 - - - - - 9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00 Teach -fno-code about -fprefer-byte-code This patch teachs the code generation logic of -fno-code about -fprefer-byte-code, so that if we need to generate code for a module which prefers byte code, then we generate byte code rather than object code. We keep track separately which modules need object code and which byte code and then enable the relevant code generation for each. Typically the option will be enabled globally so one of these sets should be empty and we will just turn on byte code or object code generation. We also fix the bug where we would generate code for a module which enables Template Haskell despite the fact it was unecessary. Fixes #22016 - - - - - caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Don't keep exit join points so much We were religiously keeping exit join points throughout, which had some bad effects (#21148, #22084). This MR does two things: * Arranges that exit join points are inhibited from inlining only in /one/ Simplifier pass (right after Exitification). See Note [Be selective about not-inlining exit join points] in GHC.Core.Opt.Exitify It's not a big deal, but it shaves 0.1% off compile times. * Inline used-once non-recursive join points very aggressively Given join j x = rhs in joinrec k y = ....j x.... where this is the only occurrence of `j`, we want to inline `j`. (Unless sm_keep_exits is on.) See Note [Inline used-once non-recursive join points] in GHC.Core.Opt.Simplify.Utils This is just a tidy-up really. It doesn't change allocation, but getting rid of a binding is always good. Very effect on nofib -- some up and down. - - - - - 284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00 Make SpecConstr bale out less often When doing performance debugging on #22084 / !8901, I found that the algorithm in SpecConstr.decreaseSpecCount was so aggressive that if there were /more/ specialisations available for an outer function, that could more or less kill off specialisation for an /inner/ function. (An example was in nofib/spectral/fibheaps.) This patch makes it a bit more aggressive, by dividing by 2, rather than by the number of outer specialisations. This makes the program bigger, temporarily: T19695(normal) ghc/alloc +11.3% BAD because we get more specialisation. But lots of other programs compile a bit faster and the geometric mean in perf/compiler is 0.0%. Metric Increase: T19695 - - - - - 66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00 CmmToC: emit explicit tail calls when the C compiler supports it Clang 13+ supports annotating a return statement using the musttail attribute, which guarantees that it lowers to a tail call if compilation succeeds. This patch takes advantage of that feature for the unregisterised code generator. The configure script tests availability of the musttail attribute, if it's available, the Cmm tail calls will become C tail calls that avoids the mini interpreter trampoline overhead. Nothing is affected if the musttail attribute is not supported. Clang documentation: https://clang.llvm.org/docs/AttributeReference.html#musttail - - - - - 7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00 Don't include BufPos in interface files Ticket #22162 pointed out that the build directory was leaking into the ABI hash of a module because the BufPos depended on the location of the build tree. BufPos is only used in GHC.Parser.PostProcess.Haddock, and the information doesn't need to be propagated outside the context of a module. Fixes #22162 - - - - - dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00 CLabel: fix isInfoTableLabel isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work. - - - - - da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00 Extend documentation for Data.List, mostly wrt infinite lists - - - - - 9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00 Expand comment for Data.List.permutations - - - - - d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00 ByteArray# is unlifted, not unboxed - - - - - f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Add missing declaration of stg_noDuplicate - - - - - 69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move CString, CStringLen to GHC.Foreign - - - - - f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00 base: Move IPE helpers to GHC.InfoProv - - - - - 866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00 rts: Refactor IPE tracing support - - - - - 6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00 Refactor IPE initialization Here we refactor the representation of info table provenance information in object code to significantly reduce its size and link-time impact. Specifically, we deduplicate strings and represent them as 32-bit offsets into a common string table. In addition, we rework the registration logic to eliminate allocation from the registration path, which is run from a static initializer where things like allocation are technically undefined behavior (although it did previously seem to work). For similar reasons we eliminate lock usage from registration path, instead relying on atomic CAS. Closes #22077. - - - - - 9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00 Separate IPE source file from span The source file name can very often be shared across many IPE entries whereas the source coordinates are generally unique. Separate the two to exploit sharing of the former. - - - - - 27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00 Make Cmm Lint messages use dump style Lint errors indicate an internal error in GHC, so it makes sense to use it instead of the user style. This is consistent with Core Lint and STG Lint: https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429 https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144 Fixes #22218. - - - - - 64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00 Mark T7919 as fragile On x86_64-linux, T7919 timed out ~30 times during July 2022. And again ~30 times in September 2022. - - - - - 481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00 rts: Don't hint inlining of appendToRunQueue These hints have resulted in compile-time warnings due to failed inlinings for quite some time. Moreover, it's quite unlikely that inlining them is all that beneficial given that they are rather sizeable functions. Resolves #22280. - - - - - 81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00 remove name shadowing - - - - - 626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00 winio: do not re-translate input when handle is uncooked - - - - - 5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00 Unrestricted OverloadedLabels (#11671) Implements GHC proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst - - - - - ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00 Add a perf test for the generics code pattern from #21839. This code showed a strong shift between compile time (got worse) and run time (got a lot better) recently which is perfectly acceptable. However it wasn't clear why the compile time regression was happening initially so I'm adding this test to make it easier to track such changes in the future. - - - - - 78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Consolidate initializer/finalizer handling Here we extend our treatment of initializer/finalizer priorities to include ELF and in so doing refactor things to share the implementation with PEi386. As well, I fix a subtle misconception of the ordering behavior for `.ctors`. Fixes #21847. - - - - - 44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00 rts/linker: Add support for .fini sections - - - - - beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00 Update phases.rst (the name of the original source file is $1, not $2) - - - - - eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00 Clearer error msg for newtype GADTs with defaulted kind When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447 - - - - - 43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00 Add standard Unicode case predicates isUpperCase and isLowerCase. These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower. Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403. Fixes #14589 - - - - - aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00 Add type signatures in where-clause of Data.List.permutations The type of interleave' is very much revealing, otherwise it's extremely tough to decipher. - - - - - ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00 rts: Use pthread_setname_np correctly on Darwin As noted in #22206, pthread_setname_np on Darwin only supports setting the name of the calling thread. Consequently we must introduce a trampoline which first sets the thread name before entering the thread entrypoint. - - - - - 8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00 testsuite: Add test for #22282 This will complement mpickering's more general port of foundation's numerical testsuite, providing a test for the specific case found in #22282. - - - - - 62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00 ncg/aarch64: Fix sub-word sign extension yet again In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues to do with sign extension in the AArch64 NCG found by ghc/test-primops>. However, this patch made a critical error, assuming that getSomeReg would allocate a fresh register for the result of its evaluation. However, this is not the case as `getSomeReg (CmmReg r) == r`. Consequently, any mutation of the register returned by `getSomeReg` may have unwanted side-effects on other expressions also mentioning `r`. In the fix listed above, this manifested as the registers containing the operands of binary arithmetic operations being incorrectly sign-extended. This resulted in #22282. Sadly, the rather simple structure of the tests generated by `test-primops` meant that this particular case was not exercised. Even more surprisingly, none of our testsuite caught this case. Here we fix this by ensuring that intermediate sign extension is performed in a fresh register. Fixes #22282. - - - - - 54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: ensure we are below maxHeapSize after returning megablocks When the heap is heavily block fragmented the live byte size might be low while the memory usage is high. We want to ensure that heap overflow triggers in these cases. We do so by checking that we can return enough megablocks to under maxHeapSize at the end of GC. - - - - - 29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00 rts: trigger a major collection if megablock usage exceeds maxHeapSize When the heap is suffering from block fragmentation, live bytes might be low while megablock usage is high. If megablock usage exceeds maxHeapSize, we want to trigger a major GC to try to recover some memory otherwise we will die from a heapOverflow at the end of the GC. Fixes #21927 - - - - - 4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00 Add realease note for #21927 - - - - - c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00 DmdAnal: Look through unfoldings of DataCon wrappers (#22241) Previously, the demand signature we computed upfront for a DataCon wrapper lacked boxity information and was much less precise than the demand transformer for the DataCon worker. In this patch we adopt the solution to look through unfoldings of DataCon wrappers during Demand Analysis, but still attach a demand signature for other passes such as the Simplifier. See `Note [DmdAnal for DataCon wrappers]` for more details. Fixes #22241. - - - - - 8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00 Add `Enum (Down a)` instance that swaps `succ` and `pred` See https://github.com/haskell/core-libraries-committee/issues/51 for discussion. The key points driving the implementation are the following two ideas: * For the `Int` type, `comparing (complement @Int)` behaves exactly as an order-swapping `compare @Int`. * `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`, if only the corner case of starting at the very end is handled specially - - - - - d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00 Update the check-exact infrastructure to match ghc-exactprint GHC tests the exact print annotations using the contents of utils/check-exact. The same functionality is provided via https://github.com/alanz/ghc-exactprint The latter was updated to ensure it works with all of the files on hackage when 9.2 was released, as well as updated to ensure users of the library could work properly (apply-refact, retrie, etc). This commit brings the changes from ghc-exactprint into GHC/utils/check-exact, adapting for the changes to master. Once it lands, it will form the basis for the 9.4 version of ghc-exactprint. See also discussion around this process at #21355 - - - - - 08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00 Avoid allocating intermediate lists for non recursive bindings. We do so by having an explicit folding function that doesn't need to allocate intermediate lists first. Fixes #22196 - - - - - ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00 Testsuite: Add a new tables_next_to_code predicate. And use it to avoid T21710a failing on non-tntc archs. Fixes #22169 - - - - - abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00 example rewrite - - - - - 39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00 remove redirect - - - - - 0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00 use heredoc - - - - - 0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00 testsuite: Fix typo when setting llvm_ways Since 2014 llvm_ways has been set to [] so none of the tests which use only_ways(llvm_ways) have worked as expected. Hopefully the tests still pass with this typo fix! - - - - - ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00 Fix T15155l not getting -fllvm - - - - - 0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00 Fix GHCis interaction with tag inference. I had assumed that wrappers were not inlined in interactive mode. Meaning we would always execute the compiled wrapper which properly takes care of upholding the strict field invariant. This turned out to be wrong. So instead we now run tag inference even when we generate bytecode. In that case only for correctness not performance reasons although it will be still beneficial for runtime in some cases. I further fixed a bug where GHCi didn't tag nullary constructors properly when used as arguments. Which caused segfaults when calling into compiled functions which expect the strict field invariant to be upheld. Fixes #22042 and #21083 ------------------------- Metric Increase: T4801 Metric Decrease: T13035 ------------------------- - - - - - 9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00 Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions. - - - - - f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00 configure: Bump minimum bootstrap GHC version Fixes #22245 - - - - - ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00 Build System: Remove out-of-date comment about make build system Both make and hadrian interleave compilation of modules of different modules and don't respect the package boundaries. Therefore I just remove this comment which points out this "difference". Fixes #22253 - - - - - e1bbd368 by Matthew Pickering at 2022-10-18T16:15:49+02:00 Allow configuration of error message printing This MR implements the idea of #21731 that the printing of a diagnostic method should be configurable at the printing time. The interface of the `Diagnostic` class is modified from: ``` class Diagnostic a where diagnosticMessage :: a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` to ``` class Diagnostic a where type DiagnosticOpts a defaultDiagnosticOpts :: DiagnosticOpts a diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc diagnosticReason :: a -> DiagnosticReason diagnosticHints :: a -> [GhcHint] ``` and so each `Diagnostic` can implement their own configuration record which can then be supplied by a client in order to dictate how to print out the error message. At the moment this only allows us to implement #21722 nicely but in future it is more natural to separate the configuration of how much information we put into an error message and how much we decide to print out of it. Updates Haddock submodule - - - - - 99dc3e3d by Matthew Pickering at 2022-10-18T16:15:53+02:00 Add -fsuppress-error-contexts to disable printing error contexts in errors In many development environments, the source span is the primary means of seeing what an error message relates to, and the In the expression: and In an equation for: clauses are not particularly relevant. However, they can grow to be quite long, which can make the message itself both feel overwhelming and interact badly with limited-space areas. It's simple to implement this flag so we might as well do it and give the user control about how they see their messages. Fixes #21722 - - - - - 5b3a992f by Dai at 2022-10-19T10:45:45-04:00 Add VecSlot for unboxed sums of SIMD vectors This patch adds the missing `VecRep` case to `primRepSlot` function and all the necessary machinery to carry this new `VecSlot` through code generation. This allows programs involving unboxed sums of SIMD vectors to be written and compiled. Fixes #22187 - - - - - 6d7d9181 by sheaf at 2022-10-19T10:45:45-04:00 Remove SIMD conversions This patch makes it so that packing/unpacking SIMD vectors always uses the right sized types, e.g. unpacking a Word16X4# will give a tuple of Word16#s. As a result, we can get rid of the conversion instructions that were previously required. Fixes #22296 - - - - - 3be48877 by sheaf at 2022-10-19T10:45:45-04:00 Cmm Lint: relax SIMD register assignment check As noted in #22297, SIMD vector registers can be used to store different kinds of values, e.g. xmm1 can be used both to store integer and floating point values. The Cmm type system doesn't properly account for this, so we weaken the Cmm register assignment lint check to only compare widths when comparing a vector type with its allocated vector register. - - - - - f7b7a312 by sheaf at 2022-10-19T10:45:45-04:00 Disable some SIMD tests on non-X86 architectures - - - - - 83638dce by M Farkas-Dyck at 2022-10-19T10:46:29-04:00 Scrub various partiality involving lists (again). Lets us avoid some use of `head` and `tail`, and some panics. - - - - - c3732c62 by M Farkas-Dyck at 2022-10-19T10:47:13-04:00 Enforce invariant of `ListBag` constructor. - - - - - 488d3631 by Bodigrim at 2022-10-19T10:47:52-04:00 More precise types for fields of OverlappingInstances and UnsafeOverlap in TcSolverReportMsg It's clear from asserts in `GHC.Tc.Errors` that `overlappingInstances_matches` and `unsafeOverlapped` are supposed to be non-empty, and `unsafeOverlap_matches` contains a single instance, but these invariants are immediately lost afterwards and not encoded in types. This patch enforces the invariants by pattern matching and makes types more precise, avoiding asserts and partial functions such as `head`. - - - - - 607ce263 by sheaf at 2022-10-19T10:47:52-04:00 Rename unsafeOverlap_matches -> unsafeOverlap_match in UnsafeOverlap - - - - - 1fab9598 by Matthew Pickering at 2022-10-19T10:48:29-04:00 Add SpliceTypes test for hie files This test checks that typed splices and quotes get the right type information when used in hiefiles. See #21619 - - - - - a8b52786 by Jan Hrček at 2022-10-19T10:49:09-04:00 Small language fixes in 'Using GHC' - - - - - 1dab1167 by Gergő Érdi at 2022-10-19T10:49:51-04:00 Fix typo in `Opt_WriteIfSimplifiedCore`'s name - - - - - b17cfc9c by sheaf at 2022-10-19T10:50:37-04:00 TyEq:N assertion: only for saturated applications The assertion that checked TyEq:N in canEqCanLHSFinish incorrectly triggered in the case of an unsaturated newtype TyCon heading the RHS, even though we can't unwrap such an application. Now, we only trigger an assertion failure in case of a saturated application of a newtype TyCon. Fixes #22310 - - - - - ff6f2228 by M Farkas-Dyck at 2022-10-20T16:15:51-04:00 CoreToStg: purge `DynFlags`. - - - - - 1ebd521f by Matthew Pickering at 2022-10-20T16:16:27-04:00 ci: Make fat014 test robust For some reason I implemented this as a makefile test rather than a ghci_script test. Hopefully making it a ghci_script test makes it more robust. Fixes #22313 - - - - - 8cd6f435 by Curran McConnell at 2022-10-21T02:58:01-04:00 remove a no-warn directive from GHC.Cmm.ContFlowOpt This patch is motivated by the desire to remove the {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} directive at the top of GHC.Cmm.ContFlowOpt. (Based on the text in this coding standards doc, I understand it's a goal of the project to remove such directives.) I chose this task because I'm a new contributor to GHC, and it seemed like a good way to get acquainted with the patching process. In order to address the warning that arose when I removed the no-warn directive, I added a case to removeUnreachableBlocksProc to handle the CmmData constructor. Clearly, since this partial function has not been erroring out in the wild, its inputs are always in practice wrapped by the CmmProc constructor. Therefore the CmmData case is handled by a precise panic (which is an improvement over the partial pattern match from before). - - - - - a2af7c4c by Nicolas Trangez at 2022-10-21T02:58:39-04:00 build: get rid of `HAVE_TIME_H` As advertized by `autoreconf`: > All current systems provide time.h; it need not be checked for. Hence, remove the check for it in `configure.ac` and remove conditional inclusion of the header in `HAVE_TIME_H` blocks where applicable. The `time.h` header was being included in various source files without a `HAVE_TIME_H` guard already anyway. - - - - - 25cdc630 by Nicolas Trangez at 2022-10-21T02:58:39-04:00 rts: remove use of `TIME_WITH_SYS_TIME` `autoreconf` will insert an `m4_warning` when the obsolescent `AC_HEADER_TIME` macro is used: > Update your code to rely only on HAVE_SYS_TIME_H, > then remove this warning and the obsolete code below it. > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. Presence of `sys/time.h` was already checked in an earlier `AC_CHECK_HEADERS` invocation, so `AC_HEADER_TIME` can be dropped and guards relying on `TIME_WITH_SYS_TIME` can be reworked to (unconditionally) include `time.h` and include `sys/time.h` based on `HAVE_SYS_TIME_H`. Note the documentation of `AC_HEADER_TIME` in (at least) Autoconf 2.67 says > This macro is obsolescent, as current systems can include both files > when they exist. New programs need not use this macro. - - - - - 1fe7921c by Eric Lindblad at 2022-10-21T02:59:21-04:00 runhaskell - - - - - e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00 Document how to quote certain names with spaces Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236 - - - - - 0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00 Fix syntax - - - - - a4dbd102 by Ben Gamari at 2022-10-21T09:11:12-04:00 Fix manifest filename when writing Windows .rc files As noted in #12971, we previously used `show` which resulted in inappropriate escaping of non-ASCII characters. - - - - - 30f0d9a9 by Ben Gamari at 2022-10-21T09:11:12-04:00 Write response files in UTF-8 on Windows This reverts the workaround introduced in f63c8ef33ec9666688163abe4ccf2d6c0428a7e7, which taught our response file logic to write response files with the `latin1` encoding to workaround `gcc`'s lacking Unicode support. This is now no longer necessary (and in fact actively unhelpful) since we rather use Clang. - - - - - b8304648 by M Farkas-Dyck at 2022-10-21T09:11:56-04:00 Scrub some partiality in `GHC.Core.Opt.Simplify.Utils`. - - - - - 09ec7de2 by Teo Camarasu at 2022-10-21T13:23:07-04:00 template-haskell: Improve documentation of strictness annotation types Before it was undocumentated that DecidedLazy can be returned by reifyConStrictness for strict fields. This can happen when a field has an unlifted type or its the single field of a newtype constructor. Fixes #21380 - - - - - 88172069 by M Farkas-Dyck at 2022-10-21T13:23:51-04:00 Delete `eqExpr`, since GHC 9.4 has been released. - - - - - 86e6549e by Ömer Sinan Ağacan at 2022-10-22T07:41:30-04:00 Introduce a standard thunk for allocating strings Currently for a top-level closure in the form hey = unpackCString# x we generate code like this: Main.hey_entry() // [R1] { info_tbls: [(c2T4, label: Main.hey_info rep: HeapRep static { Thunk } srt: Nothing)] stack_info: arg_space: 8 updfr_space: Just 8 } {offset c2T4: // global _rqm::P64 = R1; if ((Sp + 8) - 24 < SpLim) (likely: False) goto c2T5; else goto c2T6; c2T5: // global R1 = _rqm::P64; call (stg_gc_enter_1)(R1) args: 8, res: 0, upd: 8; c2T6: // global (_c2T1::I64) = call "ccall" arg hints: [PtrHint, PtrHint] result hints: [PtrHint] newCAF(BaseReg, _rqm::P64); if (_c2T1::I64 == 0) goto c2T3; else goto c2T2; c2T3: // global call (I64[_rqm::P64])() args: 8, res: 0, upd: 8; c2T2: // global I64[Sp - 16] = stg_bh_upd_frame_info; I64[Sp - 8] = _c2T1::I64; R2 = hey1_r2Gg_bytes; Sp = Sp - 16; call GHC.CString.unpackCString#_info(R2) args: 24, res: 0, upd: 24; } } This code is generated for every string literal. Only difference between top-level closures like this is the argument for the bytes of the string (hey1_r2Gg_bytes in the code above). With this patch we introduce a standard thunk in the RTS, called stg_MK_STRING_info, that does what `unpackCString# x` does, except it gets the bytes address from the payload. Using this, for the closure above, we generate this: Main.hey_closure" { Main.hey_closure: const stg_MK_STRING_info; const 0; // padding for indirectee const 0; // static link const 0; // saved info const hey1_r1Gg_bytes; // the payload } This is much smaller in code. Metric Decrease: T10421 T11195 T12150 T12425 T16577 T18282 T18698a T18698b Co-Authored By: Ben Gamari <ben at well-typed.com> - - - - - 1937016b by Andreas Klebinger at 2022-10-22T07:42:06-04:00 hadrian: Improve error for wrong key/value errors. - - - - - 11fe42d8 by Vladislav Zavialov at 2022-10-23T00:11:50+03:00 Class layout info (#19623) Updates the haddock submodule. - - - - - f0a90c11 by Sven Tennie at 2022-10-24T00:12:51-04:00 Pin used way for test cloneMyStack (#21977) cloneMyStack checks the order of closures on the cloned stack. This may change for different ways. Thus we limit this test to one way (normal). - - - - - 0614e74d by Aaron Allen at 2022-10-24T17:11:21+02:00 Convert Diagnostics in GHC.Tc.Gen.Splice (#20116) Replaces uses of `TcRnUnknownMessage` in `GHC.Tc.Gen.Splice` with structured diagnostics. closes #20116 - - - - - 8d2dbe2d by Andreas Klebinger at 2022-10-24T15:59:41-04:00 Improve stg lint for unboxed sums. It now properly lints cases where sums end up distributed over multiple args after unarise. Fixes #22026. - - - - - 41406da5 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Fix binder-swap bug This patch fixes #21229 properly, by avoiding doing a binder-swap on dictionary Ids. This is pretty subtle, and explained in Note [Care with binder-swap on dictionaries]. Test is already in simplCore/should_run/T21229 This allows us to restore a feature to the specialiser that we had to revert: see Note [Specialising polymorphic dictionaries]. (This is done in a separate patch.) I also modularised things, using a new function scrutBinderSwap_maybe in all the places where we are (effectively) doing a binder-swap, notably * Simplify.Iteration.addAltUnfoldings * SpecConstr.extendCaseBndrs In Simplify.Iteration.addAltUnfoldings I also eliminated a guard Many <- idMult case_bndr because we concluded, in #22123, that it was doing no good. - - - - - 5a997e16 by Simon Peyton Jones at 2022-10-25T18:07:03-04:00 Make the specialiser handle polymorphic specialisation Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a program run (a lot) slower, because less specialisation took place overall. It turned out that the specialiser was missing opportunities because of quantified type variables. It was quite easy to fix. The story is given in Note [Specialising polymorphic dictionaries] Two other minor fixes in the specialiser * There is no benefit in specialising data constructor /wrappers/. (They can appear overloaded because they are given a dictionary to store in the constructor.) Small guard in canSpecImport. * There was a buglet in the UnspecArg case of specHeader, in the case where there is a dead binder. We need a LitRubbish filler for the specUnfolding stuff. I expanded Note [Drop dead args from specialisations] to explain. There is a 4% increase in compile time for T15164, because we generate more specialised code. This seems OK. Metric Increase: T15164 - - - - - 7f203d00 by Sylvain Henry at 2022-10-25T18:07:43-04:00 Numeric exceptions: replace FFI calls with primops ghc-bignum needs a way to raise numerical exceptions defined in base package. At the time we used FFI calls into primops defined in the RTS. These FFI calls had to be wrapped into hacky bottoming functions because "foreign import prim" syntax doesn't support giving a bottoming demand to the foreign call (cf #16929). These hacky wrapper functions trip up the JavaScript backend (#21078) because they are polymorphic in their return type. This commit replaces them with primops very similar to raise# but raising predefined exceptions. - - - - - 0988a23d by Sylvain Henry at 2022-10-25T18:08:24-04:00 Enable popcount rewrite rule when cross-compiling The comment applies only when host's word size < target's word size. So we can relax the guard. - - - - - a2f53ac8 by Sylvain Henry at 2022-10-25T18:09:05-04:00 Add GHC.SysTools.Cpp module Move doCpp out of the driver to be able to use it in the upcoming JS backend. - - - - - 1fd7f201 by Ben Gamari at 2022-10-25T18:09:42-04:00 llvm-targets: Add datalayouts for big-endian AArch64 targets Fixes #22311. Thanks to @zeldin for the patch. - - - - - f5a486eb by Krzysztof Gogolewski at 2022-10-25T18:10:19-04:00 Cleanup String/FastString conversions Remove unused mkPtrString and isUnderscoreFS. We no longer use mkPtrString since 1d03d8bef96. Remove unnecessary conversions between FastString and String and back. - - - - - f7bfb40c by Ryan Scott at 2022-10-26T00:01:24-04:00 Broaden the in-scope sets for liftEnvSubst and composeTCvSubst This patch fixes two distinct (but closely related) buglets that were uncovered in #22235: * `liftEnvSubst` used an empty in-scope set, which was not wide enough to cover the variables in the range of the substitution. This patch fixes this by populating the in-scope set from the free variables in the range of the substitution. * `composeTCvSubst` applied the first substitution argument to the range of the second substitution argument, but the first substitution's in-scope set was not wide enough to cover the range of the second substutition. We similarly fix this issue in this patch by widening the first substitution's in-scope set before applying it. Fixes #22235. - - - - - 0270cc54 by Vladislav Zavialov at 2022-10-26T00:02:01-04:00 Introduce TcRnWithHsDocContext (#22346) Before this patch, GHC used withHsDocContext to attach an HsDocContext to an error message: addErr $ mkTcRnUnknownMessage $ mkPlainError noHints (withHsDocContext ctxt msg) The problem with this approach is that it only works with TcRnUnknownMessage. But could we attach an HsDocContext to a structured error message in a generic way? This patch solves the problem by introducing a new constructor to TcRnMessage: data TcRnMessage where ... TcRnWithHsDocContext :: !HsDocContext -> !TcRnMessage -> TcRnMessage ... - - - - - 9ab31f42 by Sylvain Henry at 2022-10-26T09:32:20+02:00 Testsuite: more precise test options Necessary for newer cross-compiling backends (JS, Wasm) that don't support TH yet. - - - - - f60a1a62 by Vladislav Zavialov at 2022-10-26T12:17:14-04:00 Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) When faced with VDQ in the type of a term, GHC generates the following error message: Illegal visible, dependent quantification in the type of a term (GHC does not yet support this) Prior to this patch, there were two ways this message could have been generated and represented: 1. with the dedicated constructor TcRnVDQInTermType (see check_type in GHC.Tc.Validity) 2. with the transitional constructor TcRnUnknownMessage (see noNestedForallsContextsErr in GHC.Rename.Utils) Not only this led to duplication of code generating the final SDoc, it also made it tricky to track the origin of the error message. This patch fixes the problem by using TcRnVDQInTermType exclusively. - - - - - 223e159d by Owen Shepherd at 2022-10-27T13:54:33-04:00 Remove source location information from interface files This change aims to minimize source location information leaking into interface files, which makes ABI hashes dependent on the build location. The `Binary (Located a)` instance has been removed completely. It seems that the HIE interface still needs the ability to serialize SrcSpans, but by wrapping the instances, it should be a lot more difficult to inadvertently add source location information. - - - - - 22e3deb9 by Simon Peyton Jones at 2022-10-27T13:55:37-04:00 Add missing dict binds to specialiser I had forgotten to add the auxiliary dict bindings to the /unfolding/ of a specialised function. This caused #22358, which reports failures when compiling Hackage packages fixed-vector indexed-traversable Regression test T22357 is snarfed from indexed-traversable - - - - - a8ed36f9 by Evan Relf at 2022-10-27T13:56:36-04:00 Fix broken link to `async` package - - - - - 750846cd by Zubin Duggal at 2022-10-28T00:49:22-04:00 Pass correct package db when testing stage1. It used to pick the db for stage-2 which obviously didn't work. - - - - - ad612f55 by Krzysztof Gogolewski at 2022-10-28T00:50:00-04:00 Minor SDoc-related cleanup * Rename pprCLabel to pprCLabelStyle, and use the name pprCLabel for a function using CStyle (analogous to pprAsmLabel) * Move LabelStyle to the CLabel module, it no longer needs to be in Outputable. * Move calls to 'text' right next to literals, to make sure the text/str rule is triggered. * Remove FastString/String roundtrip in Tc.Deriv.Generate * Introduce showSDocForUser', which abstracts over a pattern in GHCi.UI - - - - - c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 517b6822 by Ben Gamari at 2022-11-04T20:37:31-04:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 10 changed files: - − .appveyor.sh - .editorconfig - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/darwin/nix/sources.json - + .gitlab/darwin/nix/sources.nix - + .gitlab/darwin/toolchain.nix - + .gitlab/gen_ci.hs - + .gitlab/generate_jobs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a1b4b50db69e0e1be21893395d38c4ca83e91b8f...517b68227c01b97d01a1d796a583d587e85fd4f2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a1b4b50db69e0e1be21893395d38c4ca83e91b8f...517b68227c01b97d01a1d796a583d587e85fd4f2 You're receiving 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 Nov 5 04:29:39 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 05 Nov 2022 00:29:39 -0400 Subject: [Git][ghc/ghc][master] CI: Allow hadrian-ghc-in-ghci to run in nightlies Message-ID: <6365e6b318427_11c7e219fb71745119f0@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -347,7 +347,10 @@ hlint-ghc-and-base: hadrian-ghc-in-ghci: stage: quick-build - needs: [lint-linters, lint-submods] + needs: + - job: lint-linters + - job: lint-submods + optional: true image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10:$DOCKER_REV" before_script: # workaround for docker permissions View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bdc8cbb3a0808632fc6b33a7e3c10212f5d8a5e9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bdc8cbb3a0808632fc6b33a7e3c10212f5d8a5e9 You're receiving 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 Nov 5 04:30:10 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 05 Nov 2022 00:30:10 -0400 Subject: [Git][ghc/ghc][master] Minor refactor around FastStrings Message-ID: <6365e6d2af98d_11c7e219fb71745157e8@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - 30 changed files: - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/Monad.hs - compiler/GHC/Tc/Validity.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c0e379322965aa87b14923f6d8e1ef5cd677925 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c0e379322965aa87b14923f6d8e1ef5cd677925 You're receiving 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 Nov 5 14:41:47 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 05 Nov 2022 10:41:47 -0400 Subject: [Git][ghc/ghc][wip/tsan/codegen] 5 commits: codeGen: Introduce ThreadSanitizer instrumentation Message-ID: <6366762b42cd9_11c7e251504537270@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 70bb022f by Ben Gamari at 2022-11-05T10:25:44-04:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 61f155e3 by Ben Gamari at 2022-11-05T10:26:55-04:00 cmm: Introduce MemoryOrderings - - - - - 3132f8a7 by Ben Gamari at 2022-11-05T10:26:59-04:00 llvm: Respect memory specified orderings - - - - - e9541fd3 by Ben Gamari at 2022-11-05T10:36:38-04:00 cmm/Parser: Reduce some repetition - - - - - 3fd980dd by Ben Gamari at 2022-11-05T10:41:04-04:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 17 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/ghc.cabal.in Changes: ===================================== compiler/GHC/Cmm/Config.hs ===================================== @@ -19,6 +19,7 @@ data CmmConfig = CmmConfig , cmmDoLinting :: !Bool -- ^ Do Cmm Linting Optimization or not , cmmOptElimCommonBlks :: !Bool -- ^ Eliminate common blocks or not , cmmOptSink :: !Bool -- ^ Perform sink after stack layout or not + , cmmOptThreadSanitizer :: !Bool -- ^ Instrument memory accesses for ThreadSanitizer , cmmGenStackUnwindInstr :: !Bool -- ^ Generate stack unwinding instructions (for debugging) , cmmExternalDynamicRefs :: !Bool -- ^ Generate code to link against dynamic libraries , cmmDoCmmSwitchPlans :: !Bool -- ^ Should the Cmm pass replace Stg switch statements ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -94,6 +94,9 @@ $white_no_nl+ ; "!=" { kw CmmT_Ne } "&&" { kw CmmT_BoolAnd } "||" { kw CmmT_BoolOr } + "%acquire" { kw CmmT_Acquire } + "%release" { kw CmmT_Release } + "%seq_cst" { kw CmmT_SeqCst } "True" { kw CmmT_True } "False" { kw CmmT_False } @@ -183,6 +186,9 @@ data CmmToken | CmmT_False | CmmT_True | CmmT_likely + | CmmT_Acquire + | CmmT_Release + | CmmT_SeqCst deriving (Show) -- ----------------------------------------------------------------------------- ===================================== compiler/GHC/Cmm/MachOp.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Cmm.MachOp , machOpMemcpyishAlign -- Atomic read-modify-write + , MemoryOrdering(..) , AtomicMachOp(..) ) where @@ -668,8 +669,8 @@ data CallishMachOp -- Atomic read-modify-write. | MO_AtomicRMW Width AtomicMachOp - | MO_AtomicRead Width - | MO_AtomicWrite Width + | MO_AtomicRead Width MemoryOrdering + | MO_AtomicWrite Width MemoryOrdering -- | Atomic compare-and-swap. Arguments are @[dest, expected, new]@. -- Sequentially consistent. -- Possible future refactoring: should this be an'MO_AtomicRMW' variant? @@ -684,6 +685,13 @@ data CallishMachOp | MO_ResumeThread deriving (Eq, Show) +-- | C11 memory ordering semantics. +data MemoryOrdering + = MemOrderAcquire -- ^ acquire ordering + | MemOrderRelease -- ^ release ordering + | MemOrderSeqCst -- ^ sequentially consistent + deriving (Eq, Ord, Show) + -- | The operation to perform atomically. data AtomicMachOp = AMO_Add ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -313,6 +313,9 @@ import qualified Data.ByteString.Char8 as BS8 'True' { L _ (CmmT_True ) } 'False' { L _ (CmmT_False) } 'likely'{ L _ (CmmT_likely)} + 'acquire'{ L _ (CmmT_Acquire)} + 'release'{ L _ (CmmT_Release)} + 'seq_cst'{ L _ (CmmT_SeqCst)} 'CLOSURE' { L _ (CmmT_CLOSURE) } 'INFO_TABLE' { L _ (CmmT_INFO_TABLE) } @@ -627,8 +630,10 @@ stmt :: { CmmParse () } | lreg '=' expr ';' { do reg <- $1; e <- $3; withSourceNote $2 $4 (emitAssign reg e) } + | mem_ordering type '[' expr ']' '=' expr ';' + { do mord <- $1; withSourceNote $3 $8 (doStore (Just mord) $2 $4 $7) } | type '[' expr ']' '=' expr ';' - { withSourceNote $2 $7 (doStore $1 $3 $6) } + { withSourceNote $2 $7 (doStore Nothing $1 $3 $6) } -- Gah! We really want to say "foreign_results" but that causes -- a shift/reduce conflict with assignment. We either @@ -678,6 +683,13 @@ unwind_regs | GLOBALREG '=' expr_or_unknown { do e <- $3; return [($1, e)] } +-- | A memory ordering +mem_ordering :: { CmmParse MemoryOrdering } +mem_ordering + : 'release' { do return MemOrderRelease } + | 'acquire' { do return MemOrderAcquire } + | 'seq_cst' { do return MemOrderSeqCst } + -- | Used by unwind to indicate unknown unwinding values. expr_or_unknown :: { CmmParse (Maybe CmmExpr) } @@ -953,6 +965,7 @@ exprMacros profile align_check = listToUFM [ platform = profilePlatform profile -- we understand a subset of C-- primitives: +machOps :: UniqFM FastString (Width -> MachOp) machOps = listToUFM $ map (\(x, y) -> (mkFastString x, y)) [ ( "add", MO_Add ), @@ -1074,37 +1087,31 @@ callishMachOps platform = listToUFM $ ( "suspendThread", (MO_SuspendThread,) ), ( "resumeThread", (MO_ResumeThread,) ), - ("prefetch0", (MO_Prefetch_Data 0,)), - ("prefetch1", (MO_Prefetch_Data 1,)), - ("prefetch2", (MO_Prefetch_Data 2,)), - ("prefetch3", (MO_Prefetch_Data 3,)), - - ( "popcnt8", (MO_PopCnt W8,)), - ( "popcnt16", (MO_PopCnt W16,)), - ( "popcnt32", (MO_PopCnt W32,)), - ( "popcnt64", (MO_PopCnt W64,)), - - ( "pdep8", (MO_Pdep W8,)), - ( "pdep16", (MO_Pdep W16,)), - ( "pdep32", (MO_Pdep W32,)), - ( "pdep64", (MO_Pdep W64,)), - - ( "pext8", (MO_Pext W8,)), - ( "pext16", (MO_Pext W16,)), - ( "pext32", (MO_Pext W32,)), - ( "pext64", (MO_Pext W64,)), - - ( "cmpxchg8", (MO_Cmpxchg W8,)), - ( "cmpxchg16", (MO_Cmpxchg W16,)), - ( "cmpxchg32", (MO_Cmpxchg W32,)), - ( "cmpxchg64", (MO_Cmpxchg W64,)), - - ( "xchg8", (MO_Xchg W8,)), - ( "xchg16", (MO_Xchg W16,)), - ( "xchg32", (MO_Xchg W32,)), - ( "xchg64", (MO_Xchg W64,)) + ( "prefetch0", (MO_Prefetch_Data 0,)), + ( "prefetch1", (MO_Prefetch_Data 1,)), + ( "prefetch2", (MO_Prefetch_Data 2,)), + ( "prefetch3", (MO_Prefetch_Data 3,)) + ] ++ concat + [ allWidths "popcnt" MO_PopCnt + , allWidths "pdep" MO_Pdep + , allWidths "pext" MO_Pext + , allWidths "cmpxchg" MO_Cmpxchg + , allWidths "xchg" MO_Xchg + , allWidths "load_acq" (\w -> MO_AtomicRead w MemOrderAcquire) + , allWidths "load_seqcst" (\w -> MO_AtomicRead w MemOrderSeqCst) + , allWidths "store_rel" (\w -> MO_AtomicWrite w MemOrderRelease) + , allWidths "store_seqcst" (\w -> MO_AtomicWrite w MemOrderSeqCst) ] where + allWidths + :: String + -> (Width -> CallishMachOp) + -> [(FastString, a -> (CallishMachOp, a))] + allWidths name f = + [ (mkFastString $ name ++ show (widthInBits w), (f w,)) + | w <- [W8, W16, W32, W64] + ] + memcpyLikeTweakArgs :: (Int -> CallishMachOp) -> [CmmExpr] -> (CallishMachOp, [CmmExpr]) memcpyLikeTweakArgs op [] = pgmError "memcpy-like function requires at least one argument" memcpyLikeTweakArgs op args@(_:_) = @@ -1348,8 +1355,12 @@ primCall results_code name args_code let (p, args') = f args code (emitPrimCall (map fst results) p args') -doStore :: CmmType -> CmmParse CmmExpr -> CmmParse CmmExpr -> CmmParse () -doStore rep addr_code val_code +doStore :: Maybe MemoryOrdering + -> CmmType + -> CmmParse CmmExpr -- ^ address + -> CmmParse CmmExpr -- ^ value + -> CmmParse () +doStore mem_ord rep addr_code val_code = do platform <- getPlatform addr <- addr_code val <- val_code @@ -1363,7 +1374,7 @@ doStore rep addr_code val_code let coerce_val | val_width /= rep_width = CmmMachOp (MO_UU_Conv val_width rep_width) [val] | otherwise = val - emitStore addr coerce_val + emitStore mem_ord addr coerce_val -- ----------------------------------------------------------------------------- -- If-then-else and boolean expressions ===================================== compiler/GHC/Cmm/Pipeline.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Cmm.LayoutStack import GHC.Cmm.ProcPoint import GHC.Cmm.Sink import GHC.Cmm.Switch.Implement +import GHC.Cmm.ThreadSanitizer import GHC.Types.Unique.Supply @@ -160,6 +161,12 @@ cpsTop logger platform cfg proc = -- See Note [unreachable blocks] dumps Opt_D_dump_cmm_cfg "Post control-flow optimisations" g + g <- {-# SCC "annotateTSAN" #-} return $ + if cmmOptThreadSanitizer cfg + then map (annotateTSAN platform) g + else g + dumps Opt_D_dump_cmm_thread_sanitizer "ThreadSanitizer instrumentation" g -- TODO: flag + return (Left (cafEnv, g)) where dump = dumpGraph logger platform (cmmDoLinting cfg) ===================================== compiler/GHC/Cmm/ThreadSanitizer.hs ===================================== @@ -0,0 +1,109 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} + +-- | Annotate a CmmGraph with ThreadSanitizer instrumentation calls. +module GHC.Cmm.ThreadSanitizer (annotateTSAN) where + +import GHC.Prelude + +import GHC.Platform +import GHC.Cmm +import GHC.Cmm.Utils +import GHC.Cmm.CLabel +import GHC.Cmm.Dataflow +import GHC.Cmm.Dataflow.Block +import GHC.Cmm.Dataflow.Graph +import GHC.Data.FastString +import GHC.Types.Basic +import GHC.Types.ForeignCall + +annotateTSAN :: Platform -> CmmDecl -> CmmDecl +annotateTSAN platform (CmmProc hdr lbl regs g) = + CmmProc hdr lbl regs (annotateGraph platform g) +annotateTSAN _platform decl = decl + +annotateGraph :: Platform -> CmmGraph -> CmmGraph +annotateGraph _platform graph = + modifyGraph (mapGraphBlocks annotateBlock) graph + +mapBlockList :: (forall e' x'. n e' x' -> Block n e' x') + -> Block n e x -> Block n e x +mapBlockList f (BlockCO n rest ) = f n `blockAppend` mapBlockList f rest +mapBlockList f (BlockCC n rest m) = f n `blockAppend` mapBlockList f rest `blockAppend` f m +mapBlockList f (BlockOC rest m) = mapBlockList f rest `blockAppend` f m +mapBlockList _ BNil = BNil +mapBlockList f (BMiddle blk) = f blk +mapBlockList f (BCat a b) = mapBlockList f a `blockAppend` mapBlockList f b +mapBlockList f (BSnoc a n) = mapBlockList f a `blockAppend` f n +mapBlockList f (BCons n a) = f n `blockAppend` mapBlockList f a + +annotateBlock :: Block CmmNode e x -> Block CmmNode e x +annotateBlock = mapBlockList annotateNode + +annotateNode :: CmmNode e x -> Block CmmNode e x +annotateNode node@(CmmEntry{}) = BlockCO node BNil +annotateNode node@(CmmComment{}) = BMiddle node +annotateNode node@(CmmTick{}) = BMiddle node +annotateNode node@(CmmUnwind{}) = BMiddle node +annotateNode node@(CmmAssign{}) = annotateNodeOO node +annotateNode node@(CmmStore dest _ty _align) = + blockFromList (map tsanLoad (collectLoadsNode node) ++ [tsanStore dest]) `blockSnoc` node +annotateNode node@(CmmUnsafeForeignCall (PrimTarget op) _formals args) = + blockFromList (annotatePrim op args ++ foldMap annotateExpr args) `blockSnoc` node +annotateNode node@(CmmUnsafeForeignCall{}) = annotateNodeOO node +annotateNode node@(CmmBranch{}) = annotateNodeOC node +annotateNode node@(CmmCondBranch{}) = annotateNodeOC node +annotateNode node@(CmmSwitch{}) = annotateNodeOC node +annotateNode node@(CmmCall{}) = annotateNodeOC node +annotateNode node@(CmmForeignCall{}) = annotateNodeOC node + +annotateNodeOO :: CmmNode O O -> Block CmmNode O O +annotateNodeOO node = + blockFromList (map tsanLoad (collectLoadsNode node)) `blockSnoc` node + +annotateNodeOC :: CmmNode O C -> Block CmmNode O C +annotateNodeOC node = + blockFromList (map tsanLoad (collectLoadsNode node)) `blockJoinTail` node + +annotateExpr :: CmmExpr -> [CmmNode O O] +annotateExpr expr = + map tsanLoad (collectExprLoads expr) + +annotatePrim :: CallishMachOp -> [CmmActual] -> [CmmNode O O] +annotatePrim MO_ReadBarrier _args = [] -- TODO +annotatePrim MO_WriteBarrier _args = [] -- TODO +annotatePrim (MO_AtomicRMW _w _op) _args = [] -- TODO +annotatePrim (MO_AtomicRead _w _) _args = [] -- TODO +annotatePrim (MO_AtomicWrite _w _) _args = [] -- TODO +annotatePrim (MO_Cmpxchg _w) _args = [] -- TODO +annotatePrim (MO_Xchg _w) _args = [] -- TODO +annotatePrim _ _ = [] + +collectLoadsNode :: CmmNode e x -> [CmmExpr] +collectLoadsNode node = + foldExp (\exp rest -> collectExprLoads exp ++ rest) node [] + +-- | Collect all of the memory locations loaded from by a 'CmmExpr'. +collectExprLoads :: CmmExpr -> [CmmExpr] +collectExprLoads (CmmLit _) = [] +collectExprLoads (CmmLoad e _ty _align) = [e] +collectExprLoads (CmmReg _) = [] +collectExprLoads (CmmMachOp _op args) = foldMap collectExprLoads args -- TODO +collectExprLoads (CmmStackSlot _ _) = [] +collectExprLoads (CmmRegOff _ _) = [] + +tsanStore :: CmmExpr -> CmmNode O O +tsanStore dest = + CmmUnsafeForeignCall ftarget [] [dest] + where + ftarget = ForeignTarget (CmmLit (CmmLabel lbl)) conv + conv = ForeignConvention CCallConv [AddrHint] [] CmmMayReturn + lbl = mkForeignLabel (fsLit "__tsan_write8") Nothing ForeignLabelInExternalPackage IsFunction + +tsanLoad :: CmmExpr -> CmmNode O O +tsanLoad dest = + CmmUnsafeForeignCall ftarget [] [dest] + where + ftarget = ForeignTarget (CmmLit (CmmLabel lbl)) conv + conv = ForeignConvention CCallConv [AddrHint] [] CmmMayReturn + lbl = mkForeignLabel (fsLit "__tsan_read8") Nothing ForeignLabelInExternalPackage IsFunction ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -1537,8 +1537,8 @@ genCCall target dest_regs arg_regs bid = do -- -- Atomic read-modify-write. MO_AtomicRMW w amop -> mkCCall (atomicRMWLabel w amop) - MO_AtomicRead w -> mkCCall (atomicReadLabel w) - MO_AtomicWrite w -> mkCCall (atomicWriteLabel w) + MO_AtomicRead w _ -> mkCCall (atomicReadLabel w) + MO_AtomicWrite w _ -> mkCCall (atomicWriteLabel w) MO_Cmpxchg w -> mkCCall (cmpxchgLabel w) -- -- Should be an AtomicRMW variant eventually. -- -- Sequential consistent. ===================================== compiler/GHC/CmmToAsm/PPC/CodeGen.hs ===================================== @@ -1173,7 +1173,7 @@ genCCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n] (n_reg, n_code) <- getSomeReg n return (op dst dst (RIReg n_reg), n_code) -genCCall (PrimTarget (MO_AtomicRead width)) [dst] [addr] +genCCall (PrimTarget (MO_AtomicRead width _)) [dst] [addr] = do let fmt = intFormat width reg_dst = getLocalRegReg dst form = if widthInBits width == 64 then DS else D @@ -1200,7 +1200,7 @@ genCCall (PrimTarget (MO_AtomicRead width)) [dst] [addr] -- This is also what gcc does. -genCCall (PrimTarget (MO_AtomicWrite width)) [] [addr, val] = do +genCCall (PrimTarget (MO_AtomicWrite width _)) [] [addr, val] = do code <- assignMem_IntCode (intFormat width) addr val return $ unitOL HWSYNC `appOL` code @@ -2067,8 +2067,8 @@ genCCall' config gcp target dest_regs args MO_AtomicRMW {} -> unsupported MO_Cmpxchg w -> (cmpxchgLabel w, False) MO_Xchg w -> (xchgLabel w, False) - MO_AtomicRead _ -> unsupported - MO_AtomicWrite _ -> unsupported + MO_AtomicRead _ _ -> unsupported + MO_AtomicWrite _ _ -> unsupported MO_S_Mul2 {} -> unsupported MO_S_QuotRem {} -> unsupported ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2203,8 +2203,8 @@ genSimplePrim bid (MO_Pdep width) [dst] [src,mask] = genPdep bid widt genSimplePrim bid (MO_Pext width) [dst] [src,mask] = genPext bid width dst src mask genSimplePrim bid (MO_Clz width) [dst] [src] = genClz bid width dst src genSimplePrim bid (MO_UF_Conv width) [dst] [src] = genWordToFloat bid width dst src -genSimplePrim _ (MO_AtomicRead w) [dst] [addr] = genAtomicRead w dst addr -genSimplePrim _ (MO_AtomicWrite w) [] [addr,val] = genAtomicWrite w addr val +genSimplePrim _ (MO_AtomicRead w _) [dst] [addr] = genAtomicRead w dst addr +genSimplePrim _ (MO_AtomicWrite w _) [] [addr,val] = genAtomicWrite w addr val genSimplePrim bid (MO_Cmpxchg width) [dst] [addr,old,new] = genCmpXchg bid width dst addr old new genSimplePrim _ (MO_Xchg width) [dst] [addr, value] = genXchg width dst addr value genSimplePrim _ (MO_AddWordC w) [r,c] [x,y] = genAddSubRetCarry w ADD_CC (const Nothing) CARRY r c x y ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -950,8 +950,9 @@ pprCallishMachOp_for_C mop MO_AtomicRMW w amop -> ftext (atomicRMWLabel w amop) MO_Cmpxchg w -> ftext (cmpxchgLabel w) MO_Xchg w -> ftext (xchgLabel w) - MO_AtomicRead w -> ftext (atomicReadLabel w) - MO_AtomicWrite w -> ftext (atomicWriteLabel w) + -- TODO: handle orderings + MO_AtomicRead w _ -> ftext (atomicReadLabel w) + MO_AtomicWrite w _ -> ftext (atomicWriteLabel w) MO_UF_Conv w -> ftext (word2FloatLabel w) MO_S_Mul2 {} -> unsupported ===================================== compiler/GHC/CmmToLlvm/CodeGen.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.Semigroup as Semigroup import Data.List ( nub ) import Data.Maybe ( catMaybes ) -type Atomic = Bool +type Atomic = Maybe MemoryOrdering type LlvmStatements = OrdList LlvmStatement data Signage = Signed | Unsigned deriving (Eq, Show) @@ -265,9 +265,9 @@ genCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n] = runStmtsDecls $ retVar <- doExprW targetTy $ AtomicRMW op ptrVar nVar SyncSeqCst statement $ Store retVar dstVar Nothing -genCall (PrimTarget (MO_AtomicRead _)) [dst] [addr] = runStmtsDecls $ do +genCall (PrimTarget (MO_AtomicRead _ mem_ord)) [dst] [addr] = runStmtsDecls $ do dstV <- getCmmRegW (CmmLocal dst) - v1 <- genLoadW True addr (localRegType dst) NaturallyAligned + v1 <- genLoadW (Just mem_ord) addr (localRegType dst) NaturallyAligned statement $ Store v1 dstV Nothing genCall (PrimTarget (MO_Cmpxchg _width)) @@ -294,13 +294,14 @@ genCall (PrimTarget (MO_Xchg _width)) [dst] [addr, val] = runStmtsDecls $ do resVar <- doExprW (getVarType valVar) (AtomicRMW LAO_Xchg ptrVar valVar SyncSeqCst) statement $ Store resVar dstV Nothing -genCall (PrimTarget (MO_AtomicWrite _width)) [] [addr, val] = runStmtsDecls $ do +genCall (PrimTarget (MO_AtomicWrite _width mem_ord)) [] [addr, val] = runStmtsDecls $ do addrVar <- exprToVarW addr valVar <- exprToVarW val let ptrTy = pLift $ getVarType valVar ptrExpr = Cast LM_Inttoptr addrVar ptrTy ptrVar <- doExprW ptrTy ptrExpr - statement $ Expr $ AtomicRMW LAO_Xchg ptrVar valVar SyncSeqCst + let ordering = convertMemoryOrdering mem_ord + statement $ Expr $ AtomicRMW LAO_Xchg ptrVar valVar ordering -- Handle memcpy function specifically since llvm's intrinsic version takes -- some extra parameters. @@ -1012,11 +1013,11 @@ cmmPrimOpFunctions mop = do MO_Touch -> unsupported MO_UF_Conv _ -> unsupported - MO_AtomicRead _ -> unsupported - MO_AtomicRMW _ _ -> unsupported - MO_AtomicWrite _ -> unsupported - MO_Cmpxchg _ -> unsupported - MO_Xchg _ -> unsupported + MO_AtomicRead _ _ -> unsupported + MO_AtomicRMW _ _ -> unsupported + MO_AtomicWrite _ _ -> unsupported + MO_Cmpxchg _ -> unsupported + MO_Xchg _ -> unsupported MO_I64_ToI -> dontReach64 MO_I64_FromI -> dontReach64 @@ -1368,7 +1369,7 @@ exprToVarOpt opt e = case e of -> genLit opt lit CmmLoad e' ty align - -> genLoad False e' ty align + -> genLoad Nothing e' ty align -- Cmmreg in expression is the value, so must load. If you want actual -- reg pointer, call getCmmReg directly. @@ -1893,7 +1894,8 @@ case we will need a more granular way of specifying alignment. mkLoad :: Atomic -> LlvmVar -> AlignmentSpec -> LlvmExpression mkLoad atomic vptr alignment - | atomic = ALoad SyncSeqCst False vptr + | Just mem_ord <- atomic + = ALoad (convertMemoryOrdering mem_ord) False vptr | otherwise = Load vptr align where ty = pLower (getVarType vptr) @@ -2030,6 +2032,11 @@ genLit _ CmmHighStackMark -- * Misc -- +convertMemoryOrdering :: MemoryOrdering -> LlvmSyncOrdering +convertMemoryOrdering MemOrderAcquire = SyncAcquire +convertMemoryOrdering MemOrderRelease = SyncRelease +convertMemoryOrdering MemOrderSeqCst = SyncSeqCst + -- | Find CmmRegs that get assigned and allocate them on the stack -- -- Any register that gets written needs to be allocated on the ===================================== compiler/GHC/Driver/Config/Cmm.hs ===================================== @@ -18,6 +18,7 @@ initCmmConfig dflags = CmmConfig , cmmDoLinting = gopt Opt_DoCmmLinting dflags , cmmOptElimCommonBlks = gopt Opt_CmmElimCommonBlocks dflags , cmmOptSink = gopt Opt_CmmSink dflags + , cmmOptThreadSanitizer = gopt Opt_CmmThreadSanitizer dflags , cmmGenStackUnwindInstr = debugLevel dflags > 0 , cmmExternalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags , cmmDoCmmSwitchPlans = not . backendHasNativeSwitch . backend $ dflags ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -66,6 +66,7 @@ data DumpFlag | Opt_D_dump_cmm_split | Opt_D_dump_cmm_info | Opt_D_dump_cmm_cps + | Opt_D_dump_cmm_thread_sanitizer -- end cmm subflags | Opt_D_dump_cfg_weights -- ^ Dump the cfg used for block layout. | Opt_D_dump_asm @@ -352,6 +353,7 @@ data GeneralFlag | Opt_Ticky_Dyn_Thunk | Opt_Ticky_Tag | Opt_Ticky_AP -- ^ Use regular thunks even when we could use std ap thunks in order to get entry counts + | Opt_CmmThreadSanitizer | Opt_RPath | Opt_RelativeDynlibPaths | Opt_CompactUnwind -- ^ @-fcompact-unwind@ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2436,6 +2436,8 @@ dynamic_flags_deps = [ (setDumpFlag Opt_D_dump_cmm_cps) , make_ord_flag defGhcFlag "ddump-cmm-opt" (setDumpFlag Opt_D_dump_opt_cmm) + , make_ord_flag defGhcFlag "ddump-cmm-thread-sanitizer" + (setDumpFlag Opt_D_dump_cmm_thread_sanitizer) , make_ord_flag defGhcFlag "ddump-cfg-weights" (setDumpFlag Opt_D_dump_cfg_weights) , make_ord_flag defGhcFlag "ddump-core-stats" @@ -3509,8 +3511,8 @@ fFlagsDeps = [ unless (platformOS (targetPlatform dflags) == OSDarwin && turn_on) (addWarn "-compact-unwind is only implemented by the darwin platform. Ignoring.") return dflags)), - flagSpec "show-error-context" Opt_ShowErrorContext - + flagSpec "show-error-context" Opt_ShowErrorContext, + flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer ] ++ fHoleFlags ===================================== compiler/GHC/StgToCmm/ExtCode.hs ===================================== @@ -231,8 +231,12 @@ emitLabel = code . F.emitLabel emitAssign :: CmmReg -> CmmExpr -> CmmParse () emitAssign l r = code (F.emitAssign l r) -emitStore :: CmmExpr -> CmmExpr -> CmmParse () -emitStore l r = code (F.emitStore l r) +emitStore :: Maybe MemoryOrdering -> CmmExpr -> CmmExpr -> CmmParse () +emitStore (Just mem_ord) l r = do + platform <- getPlatform + let w = typeWidth $ cmmExprType platform r + emit $ mkUnsafeCall (PrimTarget $ MO_AtomicWrite w mem_ord) [] [l,r] +emitStore Nothing l r = code (F.emitStore l r) getCode :: CmmParse a -> CmmParse CmmAGraph getCode (EC ec) = EC $ \c e s -> do ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -3011,7 +3011,7 @@ doAtomicReadAddr doAtomicReadAddr res addr ty = emitPrimCall [ res ] - (MO_AtomicRead (typeWidth ty)) + (MO_AtomicRead (typeWidth ty) MemOrderSeqCst) [ addr ] -- | Emit an atomic write to a byte array that acts as a memory barrier. @@ -3039,7 +3039,7 @@ doAtomicWriteAddr doAtomicWriteAddr addr ty val = emitPrimCall [ {- no results -} ] - (MO_AtomicWrite (typeWidth ty)) + (MO_AtomicWrite (typeWidth ty) MemOrderSeqCst) [ addr, val ] doCasByteArray ===================================== compiler/ghc.cabal.in ===================================== @@ -213,6 +213,7 @@ Library GHC.Cmm.Sink GHC.Cmm.Switch GHC.Cmm.Switch.Implement + GHC.Cmm.ThreadSanitizer GHC.CmmToAsm GHC.Cmm.LRegSet GHC.CmmToAsm.AArch64 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/517b68227c01b97d01a1d796a583d587e85fd4f2...3fd980dd8a676d2e6dae77de5ed90d401650fac5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/517b68227c01b97d01a1d796a583d587e85fd4f2...3fd980dd8a676d2e6dae77de5ed90d401650fac5 You're receiving 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 Nov 5 17:23:41 2022 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Sat, 05 Nov 2022 13:23:41 -0400 Subject: [Git][ghc/ghc][wip/bump-boot-libraries] 5 commits: CI: Allow hadrian-ghc-in-ghci to run in nightlies Message-ID: <63669c1d37023_11c7e2515045429bb@gitlab.mail> Cheng Shao pushed to branch wip/bump-boot-libraries at Glasgow Haskell Compiler / GHC Commits: bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - 13fc972c by Cheng Shao at 2022-11-05T17:23:20+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab09b6fc12e33c016a06806c1c2ae47e7fc5935c...13fc972ca15e3f929c3fd95656da6e18f87d9cb0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ab09b6fc12e33c016a06806c1c2ae47e7fc5935c...13fc972ca15e3f929c3fd95656da6e18f87d9cb0 You're receiving 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 Nov 5 21:56:56 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Sat, 05 Nov 2022 17:56:56 -0400 Subject: [Git][ghc/ghc][wip/tsan/codegen] 5 commits: codeGen: Introduce ThreadSanitizer instrumentation Message-ID: <6366dc28f0cd3_11c7e22d4a928c5582c2@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 93a7079f by Ben Gamari at 2022-11-05T17:56:39-04:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - e1850660 by Ben Gamari at 2022-11-05T17:56:39-04:00 cmm: Introduce MemoryOrderings - - - - - fa0262bb by Ben Gamari at 2022-11-05T17:56:39-04:00 llvm: Respect memory specified orderings - - - - - b890f998 by Ben Gamari at 2022-11-05T17:56:39-04:00 cmm/Parser: Reduce some repetition - - - - - 43509a9f by Ben Gamari at 2022-11-05T17:56:39-04:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 18 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst Changes: ===================================== compiler/GHC/Cmm/Config.hs ===================================== @@ -19,6 +19,7 @@ data CmmConfig = CmmConfig , cmmDoLinting :: !Bool -- ^ Do Cmm Linting Optimization or not , cmmOptElimCommonBlks :: !Bool -- ^ Eliminate common blocks or not , cmmOptSink :: !Bool -- ^ Perform sink after stack layout or not + , cmmOptThreadSanitizer :: !Bool -- ^ Instrument memory accesses for ThreadSanitizer , cmmGenStackUnwindInstr :: !Bool -- ^ Generate stack unwinding instructions (for debugging) , cmmExternalDynamicRefs :: !Bool -- ^ Generate code to link against dynamic libraries , cmmDoCmmSwitchPlans :: !Bool -- ^ Should the Cmm pass replace Stg switch statements ===================================== compiler/GHC/Cmm/Lexer.x ===================================== @@ -94,6 +94,9 @@ $white_no_nl+ ; "!=" { kw CmmT_Ne } "&&" { kw CmmT_BoolAnd } "||" { kw CmmT_BoolOr } + "%acquire" { kw CmmT_Acquire } + "%release" { kw CmmT_Release } + "%seq_cst" { kw CmmT_SeqCst } "True" { kw CmmT_True } "False" { kw CmmT_False } @@ -183,6 +186,9 @@ data CmmToken | CmmT_False | CmmT_True | CmmT_likely + | CmmT_Acquire + | CmmT_Release + | CmmT_SeqCst deriving (Show) -- ----------------------------------------------------------------------------- ===================================== compiler/GHC/Cmm/MachOp.hs ===================================== @@ -24,6 +24,7 @@ module GHC.Cmm.MachOp , machOpMemcpyishAlign -- Atomic read-modify-write + , MemoryOrdering(..) , AtomicMachOp(..) ) where @@ -668,8 +669,8 @@ data CallishMachOp -- Atomic read-modify-write. | MO_AtomicRMW Width AtomicMachOp - | MO_AtomicRead Width - | MO_AtomicWrite Width + | MO_AtomicRead Width MemoryOrdering + | MO_AtomicWrite Width MemoryOrdering -- | Atomic compare-and-swap. Arguments are @[dest, expected, new]@. -- Sequentially consistent. -- Possible future refactoring: should this be an'MO_AtomicRMW' variant? @@ -684,6 +685,13 @@ data CallishMachOp | MO_ResumeThread deriving (Eq, Show) +-- | C11 memory ordering semantics. +data MemoryOrdering + = MemOrderAcquire -- ^ acquire ordering + | MemOrderRelease -- ^ release ordering + | MemOrderSeqCst -- ^ sequentially consistent + deriving (Eq, Ord, Show) + -- | The operation to perform atomically. data AtomicMachOp = AMO_Add ===================================== compiler/GHC/Cmm/Parser.y ===================================== @@ -313,6 +313,9 @@ import qualified Data.ByteString.Char8 as BS8 'True' { L _ (CmmT_True ) } 'False' { L _ (CmmT_False) } 'likely'{ L _ (CmmT_likely)} + 'acquire'{ L _ (CmmT_Acquire)} + 'release'{ L _ (CmmT_Release)} + 'seq_cst'{ L _ (CmmT_SeqCst)} 'CLOSURE' { L _ (CmmT_CLOSURE) } 'INFO_TABLE' { L _ (CmmT_INFO_TABLE) } @@ -627,8 +630,10 @@ stmt :: { CmmParse () } | lreg '=' expr ';' { do reg <- $1; e <- $3; withSourceNote $2 $4 (emitAssign reg e) } + | mem_ordering type '[' expr ']' '=' expr ';' + { do mord <- $1; withSourceNote $3 $8 (doStore (Just mord) $2 $4 $7) } | type '[' expr ']' '=' expr ';' - { withSourceNote $2 $7 (doStore $1 $3 $6) } + { withSourceNote $2 $7 (doStore Nothing $1 $3 $6) } -- Gah! We really want to say "foreign_results" but that causes -- a shift/reduce conflict with assignment. We either @@ -678,6 +683,13 @@ unwind_regs | GLOBALREG '=' expr_or_unknown { do e <- $3; return [($1, e)] } +-- | A memory ordering +mem_ordering :: { CmmParse MemoryOrdering } +mem_ordering + : 'release' { do return MemOrderRelease } + | 'acquire' { do return MemOrderAcquire } + | 'seq_cst' { do return MemOrderSeqCst } + -- | Used by unwind to indicate unknown unwinding values. expr_or_unknown :: { CmmParse (Maybe CmmExpr) } @@ -953,6 +965,7 @@ exprMacros profile align_check = listToUFM [ platform = profilePlatform profile -- we understand a subset of C-- primitives: +machOps :: UniqFM FastString (Width -> MachOp) machOps = listToUFM $ map (\(x, y) -> (mkFastString x, y)) [ ( "add", MO_Add ), @@ -1074,37 +1087,31 @@ callishMachOps platform = listToUFM $ ( "suspendThread", (MO_SuspendThread,) ), ( "resumeThread", (MO_ResumeThread,) ), - ("prefetch0", (MO_Prefetch_Data 0,)), - ("prefetch1", (MO_Prefetch_Data 1,)), - ("prefetch2", (MO_Prefetch_Data 2,)), - ("prefetch3", (MO_Prefetch_Data 3,)), - - ( "popcnt8", (MO_PopCnt W8,)), - ( "popcnt16", (MO_PopCnt W16,)), - ( "popcnt32", (MO_PopCnt W32,)), - ( "popcnt64", (MO_PopCnt W64,)), - - ( "pdep8", (MO_Pdep W8,)), - ( "pdep16", (MO_Pdep W16,)), - ( "pdep32", (MO_Pdep W32,)), - ( "pdep64", (MO_Pdep W64,)), - - ( "pext8", (MO_Pext W8,)), - ( "pext16", (MO_Pext W16,)), - ( "pext32", (MO_Pext W32,)), - ( "pext64", (MO_Pext W64,)), - - ( "cmpxchg8", (MO_Cmpxchg W8,)), - ( "cmpxchg16", (MO_Cmpxchg W16,)), - ( "cmpxchg32", (MO_Cmpxchg W32,)), - ( "cmpxchg64", (MO_Cmpxchg W64,)), - - ( "xchg8", (MO_Xchg W8,)), - ( "xchg16", (MO_Xchg W16,)), - ( "xchg32", (MO_Xchg W32,)), - ( "xchg64", (MO_Xchg W64,)) + ( "prefetch0", (MO_Prefetch_Data 0,)), + ( "prefetch1", (MO_Prefetch_Data 1,)), + ( "prefetch2", (MO_Prefetch_Data 2,)), + ( "prefetch3", (MO_Prefetch_Data 3,)) + ] ++ concat + [ allWidths "popcnt" MO_PopCnt + , allWidths "pdep" MO_Pdep + , allWidths "pext" MO_Pext + , allWidths "cmpxchg" MO_Cmpxchg + , allWidths "xchg" MO_Xchg + , allWidths "load_acq" (\w -> MO_AtomicRead w MemOrderAcquire) + , allWidths "load_seqcst" (\w -> MO_AtomicRead w MemOrderSeqCst) + , allWidths "store_rel" (\w -> MO_AtomicWrite w MemOrderRelease) + , allWidths "store_seqcst" (\w -> MO_AtomicWrite w MemOrderSeqCst) ] where + allWidths + :: String + -> (Width -> CallishMachOp) + -> [(FastString, a -> (CallishMachOp, a))] + allWidths name f = + [ (mkFastString $ name ++ show (widthInBits w), (f w,)) + | w <- [W8, W16, W32, W64] + ] + memcpyLikeTweakArgs :: (Int -> CallishMachOp) -> [CmmExpr] -> (CallishMachOp, [CmmExpr]) memcpyLikeTweakArgs op [] = pgmError "memcpy-like function requires at least one argument" memcpyLikeTweakArgs op args@(_:_) = @@ -1348,8 +1355,12 @@ primCall results_code name args_code let (p, args') = f args code (emitPrimCall (map fst results) p args') -doStore :: CmmType -> CmmParse CmmExpr -> CmmParse CmmExpr -> CmmParse () -doStore rep addr_code val_code +doStore :: Maybe MemoryOrdering + -> CmmType + -> CmmParse CmmExpr -- ^ address + -> CmmParse CmmExpr -- ^ value + -> CmmParse () +doStore mem_ord rep addr_code val_code = do platform <- getPlatform addr <- addr_code val <- val_code @@ -1363,7 +1374,7 @@ doStore rep addr_code val_code let coerce_val | val_width /= rep_width = CmmMachOp (MO_UU_Conv val_width rep_width) [val] | otherwise = val - emitStore addr coerce_val + emitStore mem_ord addr coerce_val -- ----------------------------------------------------------------------------- -- If-then-else and boolean expressions ===================================== compiler/GHC/Cmm/Pipeline.hs ===================================== @@ -19,6 +19,7 @@ import GHC.Cmm.LayoutStack import GHC.Cmm.ProcPoint import GHC.Cmm.Sink import GHC.Cmm.Switch.Implement +import GHC.Cmm.ThreadSanitizer import GHC.Types.Unique.Supply @@ -160,6 +161,12 @@ cpsTop logger platform cfg proc = -- See Note [unreachable blocks] dumps Opt_D_dump_cmm_cfg "Post control-flow optimisations" g + g <- {-# SCC "annotateTSAN" #-} return $ + if cmmOptThreadSanitizer cfg + then map (annotateTSAN platform) g + else g + dumps Opt_D_dump_cmm_thread_sanitizer "ThreadSanitizer instrumentation" g -- TODO: flag + return (Left (cafEnv, g)) where dump = dumpGraph logger platform (cmmDoLinting cfg) ===================================== compiler/GHC/Cmm/ThreadSanitizer.hs ===================================== @@ -0,0 +1,109 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE RankNTypes #-} + +-- | Annotate a CmmGraph with ThreadSanitizer instrumentation calls. +module GHC.Cmm.ThreadSanitizer (annotateTSAN) where + +import GHC.Prelude + +import GHC.Platform +import GHC.Cmm +import GHC.Cmm.Utils +import GHC.Cmm.CLabel +import GHC.Cmm.Dataflow +import GHC.Cmm.Dataflow.Block +import GHC.Cmm.Dataflow.Graph +import GHC.Data.FastString +import GHC.Types.Basic +import GHC.Types.ForeignCall + +annotateTSAN :: Platform -> CmmDecl -> CmmDecl +annotateTSAN platform (CmmProc hdr lbl regs g) = + CmmProc hdr lbl regs (annotateGraph platform g) +annotateTSAN _platform decl = decl + +annotateGraph :: Platform -> CmmGraph -> CmmGraph +annotateGraph _platform graph = + modifyGraph (mapGraphBlocks annotateBlock) graph + +mapBlockList :: (forall e' x'. n e' x' -> Block n e' x') + -> Block n e x -> Block n e x +mapBlockList f (BlockCO n rest ) = f n `blockAppend` mapBlockList f rest +mapBlockList f (BlockCC n rest m) = f n `blockAppend` mapBlockList f rest `blockAppend` f m +mapBlockList f (BlockOC rest m) = mapBlockList f rest `blockAppend` f m +mapBlockList _ BNil = BNil +mapBlockList f (BMiddle blk) = f blk +mapBlockList f (BCat a b) = mapBlockList f a `blockAppend` mapBlockList f b +mapBlockList f (BSnoc a n) = mapBlockList f a `blockAppend` f n +mapBlockList f (BCons n a) = f n `blockAppend` mapBlockList f a + +annotateBlock :: Block CmmNode e x -> Block CmmNode e x +annotateBlock = mapBlockList annotateNode + +annotateNode :: CmmNode e x -> Block CmmNode e x +annotateNode node@(CmmEntry{}) = BlockCO node BNil +annotateNode node@(CmmComment{}) = BMiddle node +annotateNode node@(CmmTick{}) = BMiddle node +annotateNode node@(CmmUnwind{}) = BMiddle node +annotateNode node@(CmmAssign{}) = annotateNodeOO node +annotateNode node@(CmmStore dest _ty _align) = + blockFromList (map tsanLoad (collectLoadsNode node) ++ [tsanStore dest]) `blockSnoc` node +annotateNode node@(CmmUnsafeForeignCall (PrimTarget op) _formals args) = + blockFromList (annotatePrim op args ++ foldMap annotateExpr args) `blockSnoc` node +annotateNode node@(CmmUnsafeForeignCall{}) = annotateNodeOO node +annotateNode node@(CmmBranch{}) = annotateNodeOC node +annotateNode node@(CmmCondBranch{}) = annotateNodeOC node +annotateNode node@(CmmSwitch{}) = annotateNodeOC node +annotateNode node@(CmmCall{}) = annotateNodeOC node +annotateNode node@(CmmForeignCall{}) = annotateNodeOC node + +annotateNodeOO :: CmmNode O O -> Block CmmNode O O +annotateNodeOO node = + blockFromList (map tsanLoad (collectLoadsNode node)) `blockSnoc` node + +annotateNodeOC :: CmmNode O C -> Block CmmNode O C +annotateNodeOC node = + blockFromList (map tsanLoad (collectLoadsNode node)) `blockJoinTail` node + +annotateExpr :: CmmExpr -> [CmmNode O O] +annotateExpr expr = + map tsanLoad (collectExprLoads expr) + +annotatePrim :: CallishMachOp -> [CmmActual] -> [CmmNode O O] +annotatePrim MO_ReadBarrier _args = [] -- TODO +annotatePrim MO_WriteBarrier _args = [] -- TODO +annotatePrim (MO_AtomicRMW _w _op) _args = [] -- TODO +annotatePrim (MO_AtomicRead _w _) _args = [] -- TODO +annotatePrim (MO_AtomicWrite _w _) _args = [] -- TODO +annotatePrim (MO_Cmpxchg _w) _args = [] -- TODO +annotatePrim (MO_Xchg _w) _args = [] -- TODO +annotatePrim _ _ = [] + +collectLoadsNode :: CmmNode e x -> [CmmExpr] +collectLoadsNode node = + foldExp (\exp rest -> collectExprLoads exp ++ rest) node [] + +-- | Collect all of the memory locations loaded from by a 'CmmExpr'. +collectExprLoads :: CmmExpr -> [CmmExpr] +collectExprLoads (CmmLit _) = [] +collectExprLoads (CmmLoad e _ty _align) = [e] +collectExprLoads (CmmReg _) = [] +collectExprLoads (CmmMachOp _op args) = foldMap collectExprLoads args -- TODO +collectExprLoads (CmmStackSlot _ _) = [] +collectExprLoads (CmmRegOff _ _) = [] + +tsanStore :: CmmExpr -> CmmNode O O +tsanStore dest = + CmmUnsafeForeignCall ftarget [] [dest] + where + ftarget = ForeignTarget (CmmLit (CmmLabel lbl)) conv + conv = ForeignConvention CCallConv [AddrHint] [] CmmMayReturn + lbl = mkForeignLabel (fsLit "__tsan_write8") Nothing ForeignLabelInExternalPackage IsFunction + +tsanLoad :: CmmExpr -> CmmNode O O +tsanLoad dest = + CmmUnsafeForeignCall ftarget [] [dest] + where + ftarget = ForeignTarget (CmmLit (CmmLabel lbl)) conv + conv = ForeignConvention CCallConv [AddrHint] [] CmmMayReturn + lbl = mkForeignLabel (fsLit "__tsan_read8") Nothing ForeignLabelInExternalPackage IsFunction ===================================== compiler/GHC/CmmToAsm/AArch64/CodeGen.hs ===================================== @@ -1537,8 +1537,8 @@ genCCall target dest_regs arg_regs bid = do -- -- Atomic read-modify-write. MO_AtomicRMW w amop -> mkCCall (atomicRMWLabel w amop) - MO_AtomicRead w -> mkCCall (atomicReadLabel w) - MO_AtomicWrite w -> mkCCall (atomicWriteLabel w) + MO_AtomicRead w _ -> mkCCall (atomicReadLabel w) + MO_AtomicWrite w _ -> mkCCall (atomicWriteLabel w) MO_Cmpxchg w -> mkCCall (cmpxchgLabel w) -- -- Should be an AtomicRMW variant eventually. -- -- Sequential consistent. ===================================== compiler/GHC/CmmToAsm/PPC/CodeGen.hs ===================================== @@ -1173,7 +1173,7 @@ genCCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n] (n_reg, n_code) <- getSomeReg n return (op dst dst (RIReg n_reg), n_code) -genCCall (PrimTarget (MO_AtomicRead width)) [dst] [addr] +genCCall (PrimTarget (MO_AtomicRead width _)) [dst] [addr] = do let fmt = intFormat width reg_dst = getLocalRegReg dst form = if widthInBits width == 64 then DS else D @@ -1200,7 +1200,7 @@ genCCall (PrimTarget (MO_AtomicRead width)) [dst] [addr] -- This is also what gcc does. -genCCall (PrimTarget (MO_AtomicWrite width)) [] [addr, val] = do +genCCall (PrimTarget (MO_AtomicWrite width _)) [] [addr, val] = do code <- assignMem_IntCode (intFormat width) addr val return $ unitOL HWSYNC `appOL` code @@ -2067,8 +2067,8 @@ genCCall' config gcp target dest_regs args MO_AtomicRMW {} -> unsupported MO_Cmpxchg w -> (cmpxchgLabel w, False) MO_Xchg w -> (xchgLabel w, False) - MO_AtomicRead _ -> unsupported - MO_AtomicWrite _ -> unsupported + MO_AtomicRead _ _ -> unsupported + MO_AtomicWrite _ _ -> unsupported MO_S_Mul2 {} -> unsupported MO_S_QuotRem {} -> unsupported ===================================== compiler/GHC/CmmToAsm/X86/CodeGen.hs ===================================== @@ -2203,8 +2203,8 @@ genSimplePrim bid (MO_Pdep width) [dst] [src,mask] = genPdep bid widt genSimplePrim bid (MO_Pext width) [dst] [src,mask] = genPext bid width dst src mask genSimplePrim bid (MO_Clz width) [dst] [src] = genClz bid width dst src genSimplePrim bid (MO_UF_Conv width) [dst] [src] = genWordToFloat bid width dst src -genSimplePrim _ (MO_AtomicRead w) [dst] [addr] = genAtomicRead w dst addr -genSimplePrim _ (MO_AtomicWrite w) [] [addr,val] = genAtomicWrite w addr val +genSimplePrim _ (MO_AtomicRead w _) [dst] [addr] = genAtomicRead w dst addr +genSimplePrim _ (MO_AtomicWrite w _) [] [addr,val] = genAtomicWrite w addr val genSimplePrim bid (MO_Cmpxchg width) [dst] [addr,old,new] = genCmpXchg bid width dst addr old new genSimplePrim _ (MO_Xchg width) [dst] [addr, value] = genXchg width dst addr value genSimplePrim _ (MO_AddWordC w) [r,c] [x,y] = genAddSubRetCarry w ADD_CC (const Nothing) CARRY r c x y ===================================== compiler/GHC/CmmToC.hs ===================================== @@ -950,8 +950,9 @@ pprCallishMachOp_for_C mop MO_AtomicRMW w amop -> ftext (atomicRMWLabel w amop) MO_Cmpxchg w -> ftext (cmpxchgLabel w) MO_Xchg w -> ftext (xchgLabel w) - MO_AtomicRead w -> ftext (atomicReadLabel w) - MO_AtomicWrite w -> ftext (atomicWriteLabel w) + -- TODO: handle orderings + MO_AtomicRead w _ -> ftext (atomicReadLabel w) + MO_AtomicWrite w _ -> ftext (atomicWriteLabel w) MO_UF_Conv w -> ftext (word2FloatLabel w) MO_S_Mul2 {} -> unsupported ===================================== compiler/GHC/CmmToLlvm/CodeGen.hs ===================================== @@ -45,7 +45,7 @@ import qualified Data.Semigroup as Semigroup import Data.List ( nub ) import Data.Maybe ( catMaybes ) -type Atomic = Bool +type Atomic = Maybe MemoryOrdering type LlvmStatements = OrdList LlvmStatement data Signage = Signed | Unsigned deriving (Eq, Show) @@ -265,9 +265,9 @@ genCall (PrimTarget (MO_AtomicRMW width amop)) [dst] [addr, n] = runStmtsDecls $ retVar <- doExprW targetTy $ AtomicRMW op ptrVar nVar SyncSeqCst statement $ Store retVar dstVar Nothing -genCall (PrimTarget (MO_AtomicRead _)) [dst] [addr] = runStmtsDecls $ do +genCall (PrimTarget (MO_AtomicRead _ mem_ord)) [dst] [addr] = runStmtsDecls $ do dstV <- getCmmRegW (CmmLocal dst) - v1 <- genLoadW True addr (localRegType dst) NaturallyAligned + v1 <- genLoadW (Just mem_ord) addr (localRegType dst) NaturallyAligned statement $ Store v1 dstV Nothing genCall (PrimTarget (MO_Cmpxchg _width)) @@ -294,13 +294,14 @@ genCall (PrimTarget (MO_Xchg _width)) [dst] [addr, val] = runStmtsDecls $ do resVar <- doExprW (getVarType valVar) (AtomicRMW LAO_Xchg ptrVar valVar SyncSeqCst) statement $ Store resVar dstV Nothing -genCall (PrimTarget (MO_AtomicWrite _width)) [] [addr, val] = runStmtsDecls $ do +genCall (PrimTarget (MO_AtomicWrite _width mem_ord)) [] [addr, val] = runStmtsDecls $ do addrVar <- exprToVarW addr valVar <- exprToVarW val let ptrTy = pLift $ getVarType valVar ptrExpr = Cast LM_Inttoptr addrVar ptrTy ptrVar <- doExprW ptrTy ptrExpr - statement $ Expr $ AtomicRMW LAO_Xchg ptrVar valVar SyncSeqCst + let ordering = convertMemoryOrdering mem_ord + statement $ Expr $ AtomicRMW LAO_Xchg ptrVar valVar ordering -- Handle memcpy function specifically since llvm's intrinsic version takes -- some extra parameters. @@ -1012,11 +1013,11 @@ cmmPrimOpFunctions mop = do MO_Touch -> unsupported MO_UF_Conv _ -> unsupported - MO_AtomicRead _ -> unsupported - MO_AtomicRMW _ _ -> unsupported - MO_AtomicWrite _ -> unsupported - MO_Cmpxchg _ -> unsupported - MO_Xchg _ -> unsupported + MO_AtomicRead _ _ -> unsupported + MO_AtomicRMW _ _ -> unsupported + MO_AtomicWrite _ _ -> unsupported + MO_Cmpxchg _ -> unsupported + MO_Xchg _ -> unsupported MO_I64_ToI -> dontReach64 MO_I64_FromI -> dontReach64 @@ -1368,7 +1369,7 @@ exprToVarOpt opt e = case e of -> genLit opt lit CmmLoad e' ty align - -> genLoad False e' ty align + -> genLoad Nothing e' ty align -- Cmmreg in expression is the value, so must load. If you want actual -- reg pointer, call getCmmReg directly. @@ -1893,7 +1894,8 @@ case we will need a more granular way of specifying alignment. mkLoad :: Atomic -> LlvmVar -> AlignmentSpec -> LlvmExpression mkLoad atomic vptr alignment - | atomic = ALoad SyncSeqCst False vptr + | Just mem_ord <- atomic + = ALoad (convertMemoryOrdering mem_ord) False vptr | otherwise = Load vptr align where ty = pLower (getVarType vptr) @@ -2030,6 +2032,11 @@ genLit _ CmmHighStackMark -- * Misc -- +convertMemoryOrdering :: MemoryOrdering -> LlvmSyncOrdering +convertMemoryOrdering MemOrderAcquire = SyncAcquire +convertMemoryOrdering MemOrderRelease = SyncRelease +convertMemoryOrdering MemOrderSeqCst = SyncSeqCst + -- | Find CmmRegs that get assigned and allocate them on the stack -- -- Any register that gets written needs to be allocated on the ===================================== compiler/GHC/Driver/Config/Cmm.hs ===================================== @@ -18,6 +18,7 @@ initCmmConfig dflags = CmmConfig , cmmDoLinting = gopt Opt_DoCmmLinting dflags , cmmOptElimCommonBlks = gopt Opt_CmmElimCommonBlocks dflags , cmmOptSink = gopt Opt_CmmSink dflags + , cmmOptThreadSanitizer = gopt Opt_CmmThreadSanitizer dflags , cmmGenStackUnwindInstr = debugLevel dflags > 0 , cmmExternalDynamicRefs = gopt Opt_ExternalDynamicRefs dflags , cmmDoCmmSwitchPlans = not . backendHasNativeSwitch . backend $ dflags ===================================== compiler/GHC/Driver/Flags.hs ===================================== @@ -66,6 +66,7 @@ data DumpFlag | Opt_D_dump_cmm_split | Opt_D_dump_cmm_info | Opt_D_dump_cmm_cps + | Opt_D_dump_cmm_thread_sanitizer -- end cmm subflags | Opt_D_dump_cfg_weights -- ^ Dump the cfg used for block layout. | Opt_D_dump_asm @@ -352,6 +353,7 @@ data GeneralFlag | Opt_Ticky_Dyn_Thunk | Opt_Ticky_Tag | Opt_Ticky_AP -- ^ Use regular thunks even when we could use std ap thunks in order to get entry counts + | Opt_CmmThreadSanitizer | Opt_RPath | Opt_RelativeDynlibPaths | Opt_CompactUnwind -- ^ @-fcompact-unwind@ ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -2436,6 +2436,8 @@ dynamic_flags_deps = [ (setDumpFlag Opt_D_dump_cmm_cps) , make_ord_flag defGhcFlag "ddump-cmm-opt" (setDumpFlag Opt_D_dump_opt_cmm) + , make_ord_flag defGhcFlag "ddump-cmm-thread-sanitizer" + (setDumpFlag Opt_D_dump_cmm_thread_sanitizer) , make_ord_flag defGhcFlag "ddump-cfg-weights" (setDumpFlag Opt_D_dump_cfg_weights) , make_ord_flag defGhcFlag "ddump-core-stats" @@ -3509,8 +3511,8 @@ fFlagsDeps = [ unless (platformOS (targetPlatform dflags) == OSDarwin && turn_on) (addWarn "-compact-unwind is only implemented by the darwin platform. Ignoring.") return dflags)), - flagSpec "show-error-context" Opt_ShowErrorContext - + flagSpec "show-error-context" Opt_ShowErrorContext, + flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer ] ++ fHoleFlags ===================================== compiler/GHC/StgToCmm/ExtCode.hs ===================================== @@ -231,8 +231,12 @@ emitLabel = code . F.emitLabel emitAssign :: CmmReg -> CmmExpr -> CmmParse () emitAssign l r = code (F.emitAssign l r) -emitStore :: CmmExpr -> CmmExpr -> CmmParse () -emitStore l r = code (F.emitStore l r) +emitStore :: Maybe MemoryOrdering -> CmmExpr -> CmmExpr -> CmmParse () +emitStore (Just mem_ord) l r = do + platform <- getPlatform + let w = typeWidth $ cmmExprType platform r + emit $ mkUnsafeCall (PrimTarget $ MO_AtomicWrite w mem_ord) [] [l,r] +emitStore Nothing l r = code (F.emitStore l r) getCode :: CmmParse a -> CmmParse CmmAGraph getCode (EC ec) = EC $ \c e s -> do ===================================== compiler/GHC/StgToCmm/Prim.hs ===================================== @@ -3011,7 +3011,7 @@ doAtomicReadAddr doAtomicReadAddr res addr ty = emitPrimCall [ res ] - (MO_AtomicRead (typeWidth ty)) + (MO_AtomicRead (typeWidth ty) MemOrderSeqCst) [ addr ] -- | Emit an atomic write to a byte array that acts as a memory barrier. @@ -3039,7 +3039,7 @@ doAtomicWriteAddr doAtomicWriteAddr addr ty val = emitPrimCall [ {- no results -} ] - (MO_AtomicWrite (typeWidth ty)) + (MO_AtomicWrite (typeWidth ty) MemOrderSeqCst) [ addr, val ] doCasByteArray ===================================== compiler/ghc.cabal.in ===================================== @@ -213,6 +213,7 @@ Library GHC.Cmm.Sink GHC.Cmm.Switch GHC.Cmm.Switch.Implement + GHC.Cmm.ThreadSanitizer GHC.CmmToAsm GHC.Cmm.LRegSet GHC.CmmToAsm.AArch64 ===================================== docs/users_guide/debugging.rst ===================================== @@ -551,6 +551,13 @@ These flags dump various phases of GHC's C-\\- pipeline. Dump the results of the C-\\- control flow optimisation pass. +.. ghc-flag:: -ddump-cmm-thread-sanitizer + :shortdesc: Dump the results of the C-\\- ThreadSanitizer elaboration pass. + :type: dynamic + + Dump the results of the C-\\- pass responsible for adding instrumentation + added by :ghc-flag:`-fcmm-thread-sanitizer`. + .. ghc-flag:: -ddump-cmm-cbe :shortdesc: Dump the results of common block elimination :type: dynamic @@ -1059,6 +1066,15 @@ Checking for consistency Note that this is only intended to be used as a debugging measure, not as the primary means of catching out-of-bounds accesses. +.. ghc-flag:: -fcmm-thread-sanitizer + :shortdesc: Enable ThreadSanitizer instrumentation of memory accesses. + :type: dynamic + + This enables generation of `ThreadSanitizer + ` + instrumentation of memory accesses. Requires use of ``-fsanitize=thread`` + or similar when compiling and linking. + .. _checking-determinism: Checking for determinism View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fd980dd8a676d2e6dae77de5ed90d401650fac5...43509a9f2d745dd4fcc7be52ce24defa5b5df99b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3fd980dd8a676d2e6dae77de5ed90d401650fac5...43509a9f2d745dd4fcc7be52ce24defa5b5df99b You're receiving 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 Nov 6 13:15:30 2022 From: gitlab at gitlab.haskell.org (Cheng Shao (@TerrorJack)) Date: Sun, 06 Nov 2022 08:15:30 -0500 Subject: [Git][ghc/ghc][wip/bump-boot-libraries] 3 commits: Bump ci-images revision Message-ID: <6367b372a1ef6_11c7e23c9bc670571910@gitlab.mail> Cheng Shao pushed to branch wip/bump-boot-libraries at Glasgow Haskell Compiler / GHC Commits: e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 3 changed files: - .gitlab-ci.yml - libraries/ghc-bignum/gmp/gmp-tarballs - libraries/haskeline 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: 9e4c540d9e4972a36291dfdf81f079f37d748890 + DOCKER_REV: 205afce5c7ebdb8666b96638f6758fe527f40a7f # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. ===================================== libraries/ghc-bignum/gmp/gmp-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 31f9909680ba8fe00d27fd8a6f5d198a0a96c1ac +Subproject commit 6bbea995472b6f4db172c3cd50aa3f515ddd221c ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit aae0bfeec7ae767e3c30844ca2f99b6825185467 +Subproject commit d4f343509e905a717ea463ad84462c126d8990d8 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/13fc972ca15e3f929c3fd95656da6e18f87d9cb0...69427ce964758b325abd881b4b3db8d59fecc878 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/13fc972ca15e3f929c3fd95656da6e18f87d9cb0...69427ce964758b325abd881b4b3db8d59fecc878 You're receiving 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 Nov 6 18:36:48 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Sun, 06 Nov 2022 13:36:48 -0500 Subject: [Git][ghc/ghc][ghc-9.2] ncg/aarch64: Don't use x18 register on AArch64/Darwin Message-ID: <6367fec0b026c_11c7e23f3396885858b8@gitlab.mail> Zubin pushed to branch ghc-9.2 at Glasgow Haskell Compiler / GHC Commits: 74ca6191 by normalcoder at 2022-11-07T00:06:37+05:30 ncg/aarch64: Don't use x18 register on AArch64/Darwin Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms (cherry picked from commit 67575f2004340564d6e52af055ed6fb43d3f9711) - - - - - 2 changed files: - docs/users_guide/9.2.5-notes.rst - includes/CodeGen.Platform.hs Changes: ===================================== docs/users_guide/9.2.5-notes.rst ===================================== @@ -21,6 +21,8 @@ Compiler - Fix a code generation panic when using SIMD types with unboxed sums (:ghc-ticket:`22187`). +- Fix a code generation bug with the native code generator on aarch64 darwin leading to runtime segmentation faults due to an incorrect ABI (:ghc-ticket:`21964`) + Runtime system -------------- ===================================== includes/CodeGen.Platform.hs ===================================== @@ -1028,6 +1028,14 @@ freeReg 29 = False -- ip0 -- used for spill offset computations freeReg 16 = False +#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) +-- x18 is reserved by the platform on Darwin/iOS, and can not be used +-- More about ARM64 ABI that Apple platforms support: +-- https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms +-- https://github.com/Siguza/ios-resources/blob/master/bits/arm64.md +freeReg 18 = False +#endif + # if defined(REG_Base) freeReg REG_Base = False # endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74ca6191fa0dbbe8cee3dc53741b8d59fbf16b09 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/74ca6191fa0dbbe8cee3dc53741b8d59fbf16b09 You're receiving 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 Nov 7 08:15:03 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Mon, 07 Nov 2022 03:15:03 -0500 Subject: [Git][ghc/ghc] Pushed new tag ghc-9.2.5-release Message-ID: <6368be8776dff_11c7e23c9bc6706583bf@gitlab.mail> Zubin pushed new tag ghc-9.2.5-release at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/ghc-9.2.5-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 Mon Nov 7 09:45:36 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 07 Nov 2022 04:45:36 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <6368d3c017a60_11c7e23f3396606838f@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: 6024df44 by Sebastian Graf at 2022-11-07T10:44:41+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Type.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -1771,10 +1771,17 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers!), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1802,18 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} +unariseArity :: Type -> Arity +unariseArity ty + | Just reps <- isFixedArityUnboxedTupleType_maybe ty = length reps + | otherwise = 1 + data Budgets = MkB Arity Budgets -- An infinite list of arity budgets -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +earnTopBudget :: Arity -> Budgets -> Budgets +earnTopBudget m (MkB n bg) = MkB (n+m) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1816,6 +1831,7 @@ finaliseArgBoxities env fn arity rhs div -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) -- , text "dmds after: " <+> ppr arg_dmds' ]) $ + assert (arity == count isId bndrs) $ Just (arg_dmds', add_demands arg_dmds' rhs) -- add_demands: we must attach the final boxities to the lambda-binders -- of the function, both because that's kosher, and because CPR analysis @@ -1823,7 +1839,8 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity -- See Note [Worker argument budget] -- This is the key line, which uses almost-circular programming @@ -1868,22 +1885,28 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) + DoUnbox triples + -> (spendTopBudget width (MkB bg_top final_bg_inner), final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + (bg_inner', dmds') = go_args (earnTopBudget width bg_inner) triples + -- earnTopBudget: give back the width of the arg we are + -- unboxing, because that is about how many registers are + -- freed by unboxing. dmd' = n :* (mkProd Unboxed $! dmds') (final_bg_inner, final_dmd) | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) where - decremented_bg = MkB (bg_top-1) bg_inner + width = unariseArity ty + retain_budget = spendTopBudget width bg + -- spendTopBudget: spend from our budget the width of the + -- arg we are retaining. add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -127,7 +127,8 @@ module GHC.Core.Type ( isLiftedRuntimeRep, isUnliftedRuntimeRep, runtimeRepLevity_maybe, isBoxedRuntimeRep, isLiftedLevity, isUnliftedLevity, - isUnliftedType, isBoxedType, isUnboxedTupleType, isUnboxedSumType, + isUnliftedType, isBoxedType, + isUnboxedTupleType, isFixedArityUnboxedTupleType_maybe, isUnboxedSumType, kindBoxedRepLevity_maybe, mightBeLiftedType, mightBeUnliftedType, isAlgType, isDataFamilyAppType, @@ -2564,6 +2565,21 @@ isUnboxedTupleType ty -- NB: Do not use typePrimRep, as that can't tell the difference between -- unboxed tuples and unboxed sums +isFixedArityUnboxedTupleType_maybe :: Type -> Maybe [RuntimeRepType] +isFixedArityUnboxedTupleType_maybe ty + | Just rep <- getRuntimeRep_maybe ty + , Just (tc, [arg]) <- splitTyConApp_maybe rep + , tc `hasKey` tupleRepDataConKey + = extract_arg_reps (splitTyConApp_maybe arg) + | otherwise + = Nothing + where + extract_arg_reps (Just (tc, tc_args)) + | [_] <- tc_args, tc `hasKey` nilDataConKey + = Just [] + | [_,hd,tl] <- tc_args, tc `hasKey` consDataConKey + = (hd :) <$> extract_arg_reps (splitTyConApp_maybe tl) + extract_arg_reps _ = Nothing isUnboxedSumType :: Type -> Bool isUnboxedSumType ty ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,30 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,21 @@ + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.f: 1 +T21737.no: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6024df448c560dbcdda5ecfdeef362b609a1e398 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6024df448c560dbcdda5ecfdeef362b609a1e398 You're receiving 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 Nov 7 10:57:14 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 05:57:14 -0500 Subject: [Git][ghc/ghc][wip/js-staging] 539 commits: Drop a kludge for binutils<2.17, which is now over 10 years old. Message-ID: <6368e48ab4243_11c7e23f339660701185@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - d09abf1b by Josh Meredith at 2022-11-07T12:00:33+01:00 Add ghcjs changes to deriveConstants: - change String targetOS option in deriveConstants to an enum - separate out getWantedGHSJS, removing generated c file in this path - - - - - 6bd13738 by doyougnu at 2022-11-07T12:00:33+01:00 Add JavaScript code generator Adapt code generator of GHCJS to GHC head. Currently it is only enabled with the hidden -fjavascript flag. It produces .o files that can't be used yet except by GHCJS's linker. Codegen: doc Codegen: correctly return linkable object Now we can build a static library (-staticlib) Codegen: doc genLit Codegen: use assignAll Codegen: introduce TypedExpr Refactor assignAll et al, add documentation Codegen: minor changes Doc - - - - - 738487c4 by doyougnu at 2022-11-07T12:00:33+01:00 Add JS.Rts JS.Rts: compiles reword: progress on RtsTypes StgToJS.Config: add SDoc Context JSRts: move ppr, workaround def type JSRts.Types: compiles JS.Rts: closer to compiling JS.Rts: move jsIdIdent' to StgToJS.Monad JS.Rts: remove unused predicates JS: cleanup, comment sections, math funcs to Make JS.Rts.Types: compiles StgToJS.Expr: fix compilation errors StgToJS.DataCon: move initClosure JS.Rts: remove Alloc module JS.Rts: initalize Rts module, remove redundant fs JS: init Rts.Alloc move initClosure JS.Apply: unwinding combinators in progress JS: add helpers and fixmes JS.Rts.Apply: no more e's, add closure, reg helper StgToJS: add ToStat instance ClosureInfo JS.Rts.Apply: closer to compiling JS.Rts.Apply: more removal of # JS.Rts.Apply: (#) removed JS.Rts.Apply: compiles JS.Rts.Rts: just pretty printing left JS.Rts: Add Notes JS.Rts: add file headers and notes JS.Rts.Rts: fixing stringy issues JS.Rts.Rts: compiles JS.Rts.Rts: fix non-exhaustive patterns warnings - - - - - ecb1dcda by Sylvain Henry at 2022-11-07T12:00:33+01:00 Doc has been moved into GHC.StgToJs top-level module - - - - - a6b52a82 by Sylvain Henry at 2022-11-07T12:00:33+01:00 JS.Rts; refactoring and move to StgToJS * add closure manipulation helpers and use them in Apply * add cache (Array) for pre-generated PAP names * reduce line length: * use BlockArguments instead of parens * remove implicit mconcat in jVar's body Rts: more refactorings Rts: move into StgToJS hierarchy - - - - - 2bff9508 by Sylvain Henry at 2022-11-07T12:00:34+01:00 JS: cleanup, renaming, better module layout Various degrees of cleanup adapting GHCJS to GHC. We move several functions to CoreUtils, remove duplication between the JS.Rts.Apply and Apply module and factor out closure related code into a Closure module for cohesion. Deduplicate code between Rts.Apply and Apply Move might_be_a_function into CoreUtils Factorize closure stuff into Closure module Rename closureExtra into closureField Minor renamings, comments... - - - - - 7c224ad3 by Sylvain Henry at 2022-11-07T12:00:34+01:00 JS.Backend: add FFI code but don't implement yet FFI: don't crash on JavaScript foreign imports Note that they are still not desugared properly!! But the following cmd doesn't crash anymore: ghc -fjavascript Test.hs -fforce-recomp -ddump-tc -fno-code -ddump-ds FFI: adapt GHCJS desugarer FFI: support direct application The following example: foo :: Int# -> Int# foo = add 50000# foreign import javascript "(function(x,y) { return (x + y) })" add :: Int# -> Int# -> Int# is compiled into an application like this: var h$mainZCMzifoozur2_e; h$mainZCMzifoozur2_e = (function() { var h$mainZCMziaddzur1; h$mainZCMziaddzur1 = h$r1.d1; var h$$mainZCMzietazuB0_8KXnScrCjF5; h$$mainZCMzietazuB0_8KXnScrCjF5 = h$r2; h$r3 = h$$mainZCMzietazuB0_8KXnScrCjF5; h$r2 = 50000; h$r1 = h$mainZCMziaddzur1; return h$ap_2_2_fast(); return h$rs(); }); var h$mainZCMziaddzur1_e; h$mainZCMziaddzur1_e = (function() { var h$$mainZCMzidszusAk_236l8r0P8S9; h$$mainZCMzidszusAk_236l8r0P8S9 = h$r2; var h$$mainZCMzids1zusAl_336l8r0P8S9; h$$mainZCMzids1zusAl_336l8r0P8S9 = h$r3; var h$$mainZCM_2; var h$$mainZCMziwildzusAn_536l8r0P8S9; try { h$$mainZCMziwildzusAn_536l8r0P8S9 = (function(x,y) { return (x + y) })(h$$mainZCMzidszusAk_236l8r0P8S9, h$$mainZCMzids1zusAl_336l8r0P8S9) } catch(except) { return h$throwJSException(except) }; var h$$mainZCMzids3zusAp_736l8r0P8S9; h$$mainZCMzids3zusAp_736l8r0P8S9 = h$$mainZCMziwildzusAn_536l8r0P8S9; h$r1 = h$$mainZCMzids3zusAp_736l8r0P8S9; return h$rs(); }); FFI: correctly dispatch for foreign exports too FFI: move C FFI desugaring into its own module FFI: avoid DynFlags in toJsName (copy of toCName) - - - - - 1090c425 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Configure: preliminary support for triple js-unknown-ghcjs - - - - - 7f544810 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Driver: enable JS backend by default for JS arch - - - - - 41c4d8f3 by doyougnu at 2022-11-07T12:00:34+01:00 JS.Backend: Add JS specific Linker JS: initialize Linker, DynamicLinking JS.Printer: adapted to GHC Head JS.Printer: some cleanup and init Printer StgToJS.Printer: Compiles JS.Linker: Add types, expose JS keywords JS.Syntax: add Binary instance on Ident's JS.Linker: Migrate more Types to Data.Binary JS.Linker.Types: compiles and adapted to GHC Head JS.Linker.Types: compiles JS.Linker.Types: add UseBase type JS.Linker: Comments and Cleanup JS.Linker.Types: add TH types, Env type, DepsLoc JS.Linker: more FIXMEs numerous Linker fixes JS.Linker: removed Text references JS.UnitUtils: add package related helper functions JS.Linker: more DynFlags removal JS.Linker: Time for semantic errors JS.Linker: DynFlags finally removed JS.Linker: 107 compile errors to go JS.Linker.Utils: initialized, adapted to GHC Head JS.Linker.Utils: initialize Utils module JS.Linker.Utils: more utils JS.Rts: move rtsText to Rts JS.Linker: linkerStats implemented JS.Compactor: compiles, adapted to GHC Head JS.Compactor: have to retrofit compact for linker JS.Linker.Compactor: unwinding lenses JS.Linker.Compactor: comments over addItem JS.Linker.Compactor: Lenses removed JS.Linker.Compactor: SHA256 removed JS.Linker.Compactor: only missing instances left JS.Linker.Compactor: compiles JS.Linker: compiles, adapted to ghc Head JS.Linker: More progress JS.Linker: link in memory compiles JS.Linker: just shims left JS.Linker.DynamicLinking compiles: adapted to head JS.Linker.DynamicLinking: initialization JS.Linker.DynamicLinking: compiles up to Variants JS.Variants: initialize JS.Linker: numerous and various fixes JS.Linker.DynamicLinking: only small errors left JS.Linker.Archive: compiles, adapted to GHC Head JS.Linker: initialize Archive compat module JS.Linker.Archive: minor fixes JS.Linker.DynamicLinking: compiles JS.Linker: cleanup, remove Variants, add comments fixup: more cleanup JS.Linker: more cleanup and comments - - - - - ccf7a594 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Minor panic fix - - - - - d76a35c4 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Linker: fix stage2 build - - - - - a9365fec by Sylvain Henry at 2022-11-07T12:00:34+01:00 Configure: Add support fo JS as unregistered ABI Configure: detect emscripten tools e.g. on ArchLinux: EMSDK=/usr/lib/emscripten EMSDK_LLVM=/opt/emscripten-llvm ./configure --target=js-unknown-ghcjs Configure: detect nm tool too, required by Hadrian Configure: make StgToJS use non-unregisterised ABI It should probably be a third kind of ABI... - - - - - c3a401e4 by doyougnu at 2022-11-07T12:00:34+01:00 JS.Linker: Hook up to GHC.Driver.Pipeline JS.Linker.Types: Add newGhcjsEnv function JS.UnitUtils: fix encodeModule api JS.Linker: more removal of HscEnv JS.Linker: hooked into GHC.Driver.Pipeline - - - - - 41f8a897 by Sylvain Henry at 2022-11-07T12:00:34+01:00 VERY WIP Hadrian/rts fixes export EMSDK_LLVM=/opt/emscripten-llvm export EMSDK=/usr/lib/emscripten export PATH=./inplace/ghcjs_toolchain/bin:$PATH ./configure --target=js-unknown-ghcjs ./hadrian/build --flavour=quick-js -j --bignum=native --docs=none -V - - - - - 41e1b278 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Force creation of rts library with dummy file - - - - - 0a0946f1 by Sylvain Henry at 2022-11-07T12:00:34+01:00 ghc-prim: avoid building C files - - - - - c55a0a7a by Sylvain Henry at 2022-11-07T12:00:34+01:00 Hadrian: disable -fllvm - - - - - 319ee9dd by Sylvain Henry at 2022-11-07T12:00:34+01:00 JS: fix caches Note that the fact that we need index 0 may hide another issue... - - - - - 456ede77 by Sylvain Henry at 2022-11-07T12:00:34+01:00 codegen: enhance genCon debug message - - - - - a0151e9b by Sylvain Henry at 2022-11-07T12:00:34+01:00 RTS: fix stupid comment - - - - - 105f0af6 by Sylvain Henry at 2022-11-07T12:00:34+01:00 RTS: embed headers - - - - - 1ab421a8 by Sylvain Henry at 2022-11-07T12:00:34+01:00 JS.StgToJS: add documentation header for JS Types - - - - - c51785f0 by Sylvain Henry at 2022-11-07T12:00:34+01:00 CodeGen: refactor ExprCtx code - - - - - c8917cab by Sylvain Henry at 2022-11-07T12:00:34+01:00 CodeGen: cache LNE frame size - - - - - 94bb2bc0 by doyougnu at 2022-11-07T12:00:34+01:00 JS.Types: Add Outputable for TypedExpr - - - - - 7af85c21 by doyougnu at 2022-11-07T12:00:34+01:00 JS.CoreUtils: handle IOPort case - - - - - c5b7b803 by doyougnu at 2022-11-07T12:00:34+01:00 JS.Expr: Fix unhandled datacon for RuntimeRep - - - - - dce84f28 by doyougnu at 2022-11-07T12:00:34+01:00 JS.Literals: Adapt genLit to new Literal domain - - - - - 62358052 by Sylvain Henry at 2022-11-07T12:00:34+01:00 RTS: expose more headers (required to build base) - - - - - 92f2c14c by Sylvain Henry at 2022-11-07T12:00:34+01:00 Base: don't build C and Cmm sources with ghcjs - - - - - 52f6fd8a by Sylvain Henry at 2022-11-07T12:00:34+01:00 Tentatively set NO_REGS for JS platforms - - - - - aa675717 by Sylvain Henry at 2022-11-07T12:00:34+01:00 CodeGen: output LitRubbish as null JS values - - - - - 328a5af7 by Sylvain Henry at 2022-11-07T12:00:34+01:00 base: disable forkOS and bound thread machinery - - - - - 7f0dc7f8 by Sylvain Henry at 2022-11-07T12:00:34+01:00 CodeGen: support StackSnapshot# in primTypeVt - - - - - 2cc5c53a by Sylvain Henry at 2022-11-07T12:00:34+01:00 CodeGen: better debug message for assignCoerce1 - - - - - 5611fe97 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Misc: enable HasDebugCallStack for zipWithEqual* - - - - - 66db7f4a by Sylvain Henry at 2022-11-07T12:00:34+01:00 CodeGen: remove useless imports - - - - - 46824950 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Stg: expose pprStgAlt - - - - - 4232738c by Sylvain Henry at 2022-11-07T12:00:34+01:00 CodeGen: restore assignAll (instead of assignAllEqual) - - - - - 6d43e44f by Sylvain Henry at 2022-11-07T12:00:34+01:00 CodeGen: handle proxy# - - - - - 500c9f71 by doyougnu at 2022-11-07T12:00:34+01:00 ghc-heap: Don't compile Cmm file for JS-Backend - - - - - 72e9c191 by doyougnu at 2022-11-07T12:00:34+01:00 Driver.Main: minor refactor do_code_gen To clearly separate the JS-Backend from any other backend - - - - - 9820844f by Sylvain Henry at 2022-11-07T12:00:34+01:00 Configure: fix echo on Mac, add ghcjs target OS - - - - - 9fe96eb3 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Configure: fix previous commit - - - - - ecfe62e6 by Luite Stegeman at 2022-11-07T12:00:34+01:00 fix package name in module name field of system dependencies - - - - - 73db9c90 by Luite Stegeman at 2022-11-07T12:00:34+01:00 fix duplicate module name in symbols - - - - - 855cb3ab by doyougnu at 2022-11-07T12:00:34+01:00 GHCi.FFI: ignore ffi.h and friends for js-backend - - - - - ea8432b0 by Sylvain Henry at 2022-11-07T12:00:34+01:00 RTS: fix build of native rts - - - - - 0a17a844 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Remove temporary -fjavascript flag - - - - - deb4af70 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Codegen: fix symbol names ppr - - - - - ecc896fa by Sylvain Henry at 2022-11-07T12:00:34+01:00 Outputable: add ShortText instance - - - - - ab0d86b6 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Linker: enhance debugging message - - - - - 58e37190 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Remove unused ghcjs unit related code - - - - - e1b058cc by Sylvain Henry at 2022-11-07T12:00:34+01:00 ghci: Avoid unused-xyz warnings - - - - - 9525bf65 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Linker: remove wiring of ghcjs-prim and ghcjs-th They will be replaced by ghc-prim, base, template-haskell, etc. - - - - - 8024bf44 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Add outputable instance for Deps - - - - - f4dbff31 by doyougnu at 2022-11-07T12:00:34+01:00 Docs: JS.Syntax, JS.Make docs done JS-backend: Add documentation headers Docs: JS.Syntax done Docs: JS.Make done Docs: JS.Make JS.Syntax refined a bit - - - - - 22e86d56 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Rename u_env into unit_env (more common) - - - - - 6a9c4029 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Linker: deduplication + fixes - deduplicate code that was copied from old GHC - explicitly add preloadUnits to the link - avoid calling getShims - - - - - 5470aec3 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Linker: reenable packStrings (not yet implemented though) - - - - - b166da7a by Sylvain Henry at 2022-11-07T12:00:34+01:00 ShortText: add singleton - - - - - d47c2700 by Sylvain Henry at 2022-11-07T12:00:34+01:00 Linker: force less efficient (but working) static encoding - - - - - 1db40200 by Luite Stegeman at 2022-11-07T12:00:34+01:00 add GHCJS modules to base package - - - - - 6feddcce by Sylvain Henry at 2022-11-07T12:00:34+01:00 Linker: remove JS Shims,tiny GHC.Linker refactor - - - - - a983f726 by doyougnu at 2022-11-07T12:00:34+01:00 Hadrian: QuickJS ways [] --> Set - - - - - 8d5f1d95 by doyougnu at 2022-11-07T12:00:34+01:00 JS-Backend: rebased to master 468f919b First rebase of the JS-Backend. This rebase includes the JS backend combined with !7442 (new backend design). Unfortunately we have to short circuit the new backend design because the JS backend takes over after STG and not after StgToCmm. What's working: - hadrian builds JS backend - JS backend outputs .js files and "links" them What still has to be done: - JS backend is missing core js libraries as we add these we discover bugs in the linker and js rts. - - - - - 8019ccc7 by doyougnu at 2022-11-07T12:00:34+01:00 JS: silence haddock warnings JS Backend: remove misc. warnings - - - - - 4c313565 by doyougnu at 2022-11-07T12:00:35+01:00 JS Backend: ghcjs_HOST_OS --> js_HOST_ARCH - - - - - 47fbb847 by Sylvain Henry at 2022-11-07T12:00:35+01:00 JS.Linker: add shims GHCJS uses JS files for primitive things like the GC and RTS. We call these JS files "shims". This sequence of commits adds shims from JS and includes them for linking. In addition the shim directory is controlled via an evironment variable JS_RTS_PATH...at least for now. Linker: implement tryReadShimFile Linker: link with shims provided via an env variable Use JS_RTS_PATH to provide a directory into which .js and .js.pp files will be linked into rts.js JS.Linker: add js dir at root, fix js cpp includes JS.gc.pp: remove variadic macro JS.RTS: add rts JS shims files, remove shim CPP RTS: remove the need for rts.h and add rts JS files rts.h only contained a few constants duplicated in the codegen. Let's use the Haskell version as the single source of truth and pass defined values explicitly to cpp command line ("-DXYZ=abc" arguments). Also switch from "raw" (use_cpp_and_not_cc_dash_E = True) to the opposite: in both case we call "cc -E" (meh), but with False the preprocessor doesn't choke one varargs in macros. RTS: remove integer.js.pp We use the native ghc-bignum backend, so we don't need the GMP compatible JS code. In addition, this code was failing to run as it requires the JSBN (https://www.npmjs.com/package/jsbn) "Javascript big number" library, which we don't necessarily have installed. RTS: fix typo in field name RTS: generate CPP macros in Haskell RTS: share common CPP def into CAFs - - - - - e47325bf by Sylvain Henry at 2022-11-07T12:00:35+01:00 Linker: add more types Some cleanup Enhance and fix LinkerStats Document and refactor renderLinker Split collectDeps Fix collectDeps Fix linker stats rendering Remove unused seqListSpine It isn't used in ghcjs either - - - - - 635ed794 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Add some missing primops (Word32,Int32) Also fix the rendering of missing primops (they must be z-encoded to avoid having a "#" in their JS name) - - - - - f7c77613 by Sylvain Henry at 2022-11-07T12:00:35+01:00 FFI: desugar every foreign import/export in JS with JS backend It means we also desugar CApi calls into JS. It's probably wrong but instead of generating invalid JS we will only get the failure at runtime when we will use the function. fixup - - - - - 977fd807 by doyougnu at 2022-11-07T12:00:35+01:00 JS.Linker: remove dflags includePath workaround. We implemented a workaround for shims that modified the dynflags includePaths so that the JS backend would find the rts.h file during CPP of shims. Since aebcca98 this is no longer required because we've removed the need for rts.h completely. Thus, this commit reverts that modification. - - - - - e1c37437 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Temporarily wire-in base's shim Use JS_BASE_PATH env var to set base's shim directory (js_base for now) Also minor other changes base: fix encoding for JS arch - - - - - 3459b38e by Sylvain Henry at 2022-11-07T12:00:35+01:00 Add primops Add primop - - - - - 3140788f by doyougnu at 2022-11-07T12:00:35+01:00 Make Shims type, refactor JS Linker This commit: - Adds a proper Shim type and associated utilities. These utitlies are purposefully limited to ensure the ShimLbl tag is preserved thus guarenteeing shim ordering at link time. - Refactors the JS backend linker to use this ordering and Shim API. The ordering is not correct (yet!) but with this API its much easier to triage, experiment and diagnose link time issues. Refactor linker to compile time shim ordering - - - - - b8645824 by doyougnu at 2022-11-07T12:00:35+01:00 Base: Adapt primitives to JS backend, add base.js - - - - - 92367ef7 by doyougnu at 2022-11-07T12:00:35+01:00 Base: Remove binding forms in JS ffi - - - - - 3597662f by Josh Meredith at 2022-11-07T12:00:35+01:00 Replace GHCJS Objectable with GHC Binary - - - - - bf69529f by Sylvain Henry at 2022-11-07T12:00:35+01:00 Binary: remove unused Map instance - - - - - 921f9de8 by Sylvain Henry at 2022-11-07T12:00:35+01:00 CodeGen: Add export list - - - - - ed2093b7 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primops: add some Int64/Word64 primops - - - - - 0c2bebfb by Sylvain Henry at 2022-11-07T12:00:35+01:00 base: fix one ffi import - - - - - 56d76aad by doyougnu at 2022-11-07T12:00:35+01:00 base: CPP for JS-backend, adapt write in base shim This commit ports over each CPP directive from GHCJS to base. In addition, it adds struct.js.pp to Base shim directory and modifies h$base_write to always take 6 arguments. Thereby avoiding errors such as "c(bytesWritten) is not a function". The missing parameter was the file descriptor object, fdo, which was looked up in the function itself and is now passed through to comport with the FFI expectations. - - - - - cba6fd53 by doyougnu at 2022-11-07T12:00:35+01:00 fixup: remove redundant struct.js.pp in js_base - - - - - 465e6c0f by doyougnu at 2022-11-07T12:00:35+01:00 JS.Linker: enable linker RTS symbols - - - - - b8938f1a by doyougnu at 2022-11-07T12:00:35+01:00 base.GHCJS: adapt Prim to direct call FFI format - - - - - 15dd0d20 by doyougnu at 2022-11-07T12:00:35+01:00 Linker: Load JSVal from base not ghc-prim - - - - - ba8a8326 by doyougnu at 2022-11-07T12:00:35+01:00 fixup: caught one more reference to JSVal in prim - - - - - f2c8bf6b by Sylvain Henry at 2022-11-07T12:00:35+01:00 base: match on js arch , not ghcjs os - - - - - da615501 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Fix MK_JSVAL - - - - - 9bc62456 by doyougnu at 2022-11-07T12:00:35+01:00 Prim: cleanup comments - - - - - 773d24b0 by doyougnu at 2022-11-07T12:00:35+01:00 JS.Prim: add Int64 PrimOps - - - - - c7129b71 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Vendor MD5 lib - - - - - 5a9e1448 by Sylvain Henry at 2022-11-07T12:00:35+01:00 More 64-bit primops - - - - - 682a7fe2 by Sylvain Henry at 2022-11-07T12:00:35+01:00 CodeGen: use if10 helper - - - - - e84fe34e by Sylvain Henry at 2022-11-07T12:00:35+01:00 Ppr: fix selector to avoid adding a newline - - - - - d7814295 by doyougnu at 2022-11-07T12:00:35+01:00 base: GHCJS.Prim make ffi imports use anon funcs - - - - - ba7fea58 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Linker: disable invalid constructors again - - - - - 71ca2fe3 by Sylvain Henry at 2022-11-07T12:00:35+01:00 More 64-bits primops - - - - - 32b6329f by Sylvain Henry at 2022-11-07T12:00:35+01:00 Fix base_write function - - - - - 6d1fc260 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Fix base_write for 32-bit size_t - - - - - 992fcdf4 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Configure: fix detection of the target toolchain - - - - - 4f7a2db8 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Remove js_base directory - - - - - 871ca41c by Sylvain Henry at 2022-11-07T12:00:35+01:00 Kill Node when the main loop reports an unhandled exception - - - - - 4a7b2a4c by Sylvain Henry at 2022-11-07T12:00:35+01:00 CodeGen: preparation to make match on primops complete - - - - - 2d4badb4 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primops: fix Compact primops - - - - - 26207ba1 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Ignore result arity for some exception primops - - - - - 75f2c996 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Fix more primops. Bump array submodule! - - - - - f9b397ef by Sylvain Henry at 2022-11-07T12:00:35+01:00 Compact: fix return of 3 values - - - - - 1db3bace by Sylvain Henry at 2022-11-07T12:00:35+01:00 Configure: switch to absolute path - - - - - 593008fc by Sylvain Henry at 2022-11-07T12:00:35+01:00 Add a few primops - - - - - 30d50c45 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primop: implement WordAdd2 - - - - - 617c747c by Luite Stegeman at 2022-11-07T12:00:35+01:00 quick fix for uTypeVt and typePrimRep panics this may cause other panics, a full fix will require a bit more rework and probably removal of VarType - - - - - 3b18df0f by Josh Meredith at 2022-11-07T12:00:35+01:00 Replace ShortText with (Lexical)FastString in GHCJS backend - - - - - 2400d26d by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primops: add arithmetic ops Primops: add decodeDoubleInt64 back Primop: added timesInt2# Primop: add mulWord32 and mul2Word32 - - - - - ad4ee81a by Sylvain Henry at 2022-11-07T12:00:35+01:00 Reduce dependency on goog - - - - - 21735096 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primop: implement quotWord32, remWord32, and quotRemWord32 - - - - - 2edb0b82 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primop: Implement quotRem2Word32, misc fixes Primop: implement quotRem2Word32 Primop: fix timesInt2# Primop: fix some shifting primops - - - - - e20cba3e by Sylvain Henry at 2022-11-07T12:00:35+01:00 Fix bug in upd_frame I've introduced this bug when I've refactored the code to use helpers to assign closures. - - - - - 7f537e7a by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primop: throw an exception for unimplemented primops - - - - - 83dfc076 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primop: fix remWord32 - - - - - f42159b3 by Josh Meredith at 2022-11-07T12:00:35+01:00 Configure: add EMSDK_BIN, match emsdk expectations Change EMSDK vars to match emscripten/emsdk_env.sh definitions Add EMSDK_BIN environment variable to configure - - - - - 32882e54 by Sylvain Henry at 2022-11-07T12:00:35+01:00 resultSize: correctly handle Void# - - - - - 514e8c14 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Primop: fix Sized test, more shifting fixes Primop: ensure that we return u32 values for word primops Also a refactoring from i3 to i32 for clarity. Primop: add/fix more shifting primops Primops: fix Sized test! - - - - - 88194d7b by Sylvain Henry at 2022-11-07T12:00:35+01:00 StgToJS.Apply: Docs Doc Doc - - - - - c79a0c39 by Josh Meredith at 2022-11-07T12:00:35+01:00 Fix EMSDK configure condition - - - - - f07e1d11 by doyougnu at 2022-11-07T12:00:35+01:00 StgToJS.Arg: Unboxable Literal Optimization note - - - - - e5d6ed21 by Sylvain Henry at 2022-11-07T12:00:35+01:00 Fix Outputable instances for JExpr/JVal - Put orphan instances in JS.Ppr - Also fix some redundant imports - - - - - f1f2d7db by doyougnu at 2022-11-07T12:00:35+01:00 configure: avoid CXX stdlib check for js backend and some cleanup for a previously mis-applied commit during rebasing - - - - - 1a0c333a by doyougnu at 2022-11-07T12:00:35+01:00 fixup: misc. fixes post rebase - - - - - 411d14d6 by Sylvain Henry at 2022-11-07T12:00:35+01:00 PrimOps: add more 64-bit primops PrimOp: implement more 64-bit primops + PM fix Ensure that we cover every primop explicitly - - - - - 94307203 by Sylvain Henry at 2022-11-07T12:00:35+01:00 PrimOp: correclty (un)handle new thread related primops - - - - - 49613364 by Sylvain Henry at 2022-11-07T12:00:35+01:00 PrimOp: disable LabelThreadOp for now - - - - - 79e746f4 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Minor doc/cleanup Fix more redundant imports - - - - - 0f5e2f50 by doyougnu at 2022-11-07T12:00:36+01:00 base: GHCJS.Prim directory --> GHC.JS.Prim - - - - - 14bedc65 by Luite Stegeman at 2022-11-07T12:00:36+01:00 implement KeepAlive primop - - - - - d067de93 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Remove orphan instance for StaticArg - - - - - 86b6b460 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Remove redundant jsIdIdent' function - - - - - 4af84746 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Split StgToJS.Monad into StgToJS.{Monad,Ids,Stack} - - - - - b3081791 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Apply: remove commented case (wasn't optimized either in latest ghcjs) - - - - - fb37ff54 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Doc: Apply Apply: doc and refactoring - use new types instead of Bool/Int - factorize some code - - - - - a640461f by Sylvain Henry at 2022-11-07T12:00:36+01:00 Primop: arith fixes Primop: fix 64-bit shifting primops + add some traces Primop: fix quotRem2Word32 Primop: fix timesInt2. Progress towards passing arith003 PrimOp: fix timesInt32 PrimOp: use mulWord32 when appropriate - - - - - 21c010a3 by doyougnu at 2022-11-07T12:00:36+01:00 Configure: remove EMSDK hacks and wrapper scripts configure JS: remove wrapper scripts Configure: remove EMSDK hacks. Use emconfigure instead emconfigure ./configure --target=js-unknown-ghcjs - - - - - 28cb06be by Sylvain Henry at 2022-11-07T12:00:36+01:00 GHCJS.Prim leftovers - - - - - a93d55fb by Sylvain Henry at 2022-11-07T12:00:36+01:00 Linker: fix linking issue for tuples - - - - - d1c70cc9 by Sylvain Henry at 2022-11-07T12:00:36+01:00 FFI: remove narrowing Fix tests such as cgrun015 (Core lint error) - - - - - ac79e112 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Linker: disable logs with default verbosity - - - - - 90dda4b3 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Append program name in top-level exception handler - - - - - 73ea86c6 by doyougnu at 2022-11-07T12:00:36+01:00 GHC.JS: Remove FIXMEs JS.Syntax: Remove FIXMEs JS.Make: remove FIXMEs JS.Ppr/Transform: Remove FIXMEs - - - - - 07912155 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Primop: fix timesInt2# Pass arith003 test - - - - - 1ec9dedf by doyougnu at 2022-11-07T12:00:36+01:00 JS.Linker.Linker: remove FIXMEs, clean dead code - - - - - a801ff8b by Sylvain Henry at 2022-11-07T12:00:36+01:00 Linker: link platform shim before the others - - - - - 9022e6d8 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Primops: rework 64-bit and Word32 primops - Use BigInt instead of complex and buggy bit twiddling. We'll assess performance later. Let's use a correct and simple implementation for now. - Implement previously missing 64-bit quot and rem - Refactor logical operators and Prim module more generally - - - - - 9710cdb4 by Sylvain Henry at 2022-11-07T12:00:36+01:00 PrimOp: fixup previous commit... - - - - - 0e44482f by Sylvain Henry at 2022-11-07T12:00:36+01:00 Primop: fixup previous commit - - - - - 78fd1d48 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Doc: minor changes - - - - - f3193316 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Add debug option to watch for insertion of undefined/null in the stack - - - - - 6aa1d4f3 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Apply: fix tag generation - - - - - a824adcd by Sylvain Henry at 2022-11-07T12:00:36+01:00 Remove redundant import - - - - - 4fd90a91 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Testsuite: disable Cmm tests with the JS backend - - - - - dc586ea6 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Base: fix c_interruptible_open - - - - - 670ed5de by Sylvain Henry at 2022-11-07T12:00:36+01:00 Base: fix typo in long_from_number - - - - - 8ea599ec by Sylvain Henry at 2022-11-07T12:00:36+01:00 Env: only add program name to errors, not to traces - - - - - 85055571 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Testsuite: disable more Cmm tests - - - - - fee05623 by doyougnu at 2022-11-07T12:00:36+01:00 JS.Linker: removes FIXMEs JS.Linker.Linker: remove FIXMEs, clean dead code StgToJS.Linker.Utils: remove FIXMEs Compactor: Remove FIXMEs StgToJS.Linker.Types: Remove FIXMEs JS.Linker.Archive/Dynamic: remove FIXMEs StgToJS.Linker.Shims: remove FIXMEs - - - - - 1ae2652c by doyougnu at 2022-11-07T12:00:36+01:00 JS RTS: remove FIXMEs StgToJS.Rts.Types: Remove FIXMEs - - - - - 455ad343 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Primop: fix bswap32/64 (cf cgrun072) - - - - - 2cd32988 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Testsuite: normalise ghc program name - - - - - 592f1b1e by doyougnu at 2022-11-07T12:00:36+01:00 JS Backend: Remove FIXMEs StgToJS.Apply: Remove FIXMEs StgToJS.FFI: remove FIXMEs StgToJS.Expr: remove FIXMEs StgToJS: Remove FIXMEs - - - - - 59756089 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Enable RTS args filtering (cf cgrun025) - - - - - f1e20ed0 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Remove trailing whitespaces (whitespace test) - - - - - 6b2bf4d9 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Testsuite: remove platform prefix for unlit tool - - - - - 7c3c35ea by Sylvain Henry at 2022-11-07T12:00:36+01:00 Primop: fix Int64 conversion/negate (integerConversions test) - - - - - 860cf690 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Linker: remove message with default verbosity - - - - - 8c4fd764 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Testsuite: normalise .jsexe suffix - - - - - 873c58e0 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Remove warning about orphan instance - - - - - ec5e00e5 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Compactor: disable dead code - - - - - e0408b46 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Exception: implement raiseUnderflow etc. as primops - - - - - 4bd95a5d by Sylvain Henry at 2022-11-07T12:00:36+01:00 Primop: fix Int8/18 quot/rem - - - - - f1037a99 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Linker: refactor wired-in deps - - - - - d36cb7bd by Sylvain Henry at 2022-11-07T12:00:36+01:00 Ppr: remove useless left padding for functions in JS dumps - - - - - 3f7e9710 by Josh Meredith at 2022-11-07T12:00:36+01:00 Disable llvm ways and ghci for JS backend testsuite - - - - - 83a4e0ec by Sylvain Henry at 2022-11-07T12:00:36+01:00 StaticPtr: don't generate CStubs for the JS backend - - - - - 7d05843b by Sylvain Henry at 2022-11-07T12:00:36+01:00 StaticPtr: fix hs_spt_lookup after upstream change - - - - - a052cc3b by Sylvain Henry at 2022-11-07T12:00:36+01:00 Testsuite: fix normalisation for unlit T8430 shows: `js-unknown-ghcjs-unlit' failed in phase `Literate pre-processor'. (Exit code: 1) Notice the quote around the program name. So I've made the regex match more cases (i.e. not only lines starting with the program name). - - - - - f068ae8a by Sylvain Henry at 2022-11-07T12:00:36+01:00 Codegen: fix codegen of string literals Due to FastString change: Before: Text.pack . BSC.unpack After: mkFastString . BSC.unpack It seems that Text handles buggy multi-byte codepoints split into several String Chars. - - - - - bb3d939d by Sylvain Henry at 2022-11-07T12:00:36+01:00 CPP: fix LINE markers. Only disable them for JS - - - - - 659b8316 by Luite Stegeman at 2022-11-07T12:00:36+01:00 add JavaScript files listed in js-sources to package archives - - - - - f422b281 by Luite Stegeman at 2022-11-07T12:00:36+01:00 update rts js files to include recent fixes - - - - - d8809ac7 by Luite Stegeman at 2022-11-07T12:00:36+01:00 fix definitions in js/rts.h - - - - - e443281b by Josh Meredith at 2022-11-07T12:00:36+01:00 stopgap fix for missing ghc-pkg in cross-compiler tests - - - - - a560846a by Sylvain Henry at 2022-11-07T12:00:36+01:00 Testsuite: better fix for finding prefixed tools - - - - - 5fea1a4e by Sylvain Henry at 2022-11-07T12:00:36+01:00 Ppr: add hangBrace helper - - - - - eae7dc20 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Only declare ccs var in profiling mode - - - - - f96e1da6 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Don't consider recursive bindings as inline nor as evaluated Fix mdo001 - - - - - cc310b0c by Sylvain Henry at 2022-11-07T12:00:36+01:00 Hadrian: disable shared libs for JS target - - - - - c48164a4 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Support -ddump-stg-final with the JS backend - - - - - 52030443 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Add ticky_ghc0 flavour transformer to ticky stage1 - - - - - 2f868b0a by Sylvain Henry at 2022-11-07T12:00:36+01:00 Don't read object file when -ddump-js isn't passed - - - - - 4c65eb04 by Sylvain Henry at 2022-11-07T12:00:36+01:00 Object: remove dead code + renaming - - - - - 0d2de45b by Sylvain Henry at 2022-11-07T12:00:36+01:00 Object: replace SymbolTableR with Dictionary - - - - - 08132415 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Object: refactoring - - - - - 81efb4f1 by Sylvain Henry at 2022-11-07T12:00:37+01:00 RTS: link platform.js before the others! - - - - - 7c39f216 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Hadrian: treat JS objects similarly to other objects - - - - - 1a79cd03 by Luite Stegeman at 2022-11-07T12:00:37+01:00 fix javascript FFI calls for read and write - - - - - 1e97b82a by doyougnu at 2022-11-07T12:00:37+01:00 propagate ppr code changes to JS backend - - - - - 14d74541 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Switch from Data.Binary and ByteString to BinHandle - - - - - a6ae9a31 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Perf: use Ppr's LeftMode to output JS - - - - - 6a2ce1c4 by doyougnu at 2022-11-07T12:00:37+01:00 Primops: Add {Index,Write,Read}ByteArrayAs ops Still need to check for correctness based on T4442. minor doc fixes fixup: add some Index..As primops fixup missed type signature Primops: Add WriteByteArrayOp_Word8AsFoo ops Primops: {Index,Read,Write}FooAsBar done except Addr's Primops: add {Index,Read,Write}ByteArrayAsAddr ops These will need to be tested for correctness with T4442.hs - - - - - 726d5256 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Move platform.js to base (it must be linked first) - - - - - 5490934d by Sylvain Henry at 2022-11-07T12:00:37+01:00 Remove old shim directory - - - - - f2abfc72 by doyougnu at 2022-11-07T12:00:37+01:00 JS.Prim: more PrimOps {IndexByteArrayAs, CAS} Primop: WriteByteArrayOp_Word8AsChar use setInt8 Primops: remove dv_s_u8 This function is non-sensical. Due to the infelicities of JS as a platform we must use Int8 and friends to write, then coerce to a word, thus dv_s_iN are the only legal calls for a write, and dv_s_uN legal for Index and Reads. Primops: set dv_u8 to correct method call should be getUint8, not getUInt8, of course the naming convention changes ever so slightly for Words. Primops: T4442 finishes ByteArrayAs still fails JS.Prim: More IndexByteAAs primops JS.Prim: Prefetch PrimOps are noOps JS.Primops: Doc explaining lack of vector support JS.Prim: add CAS and Fetch Ops - - - - - 5d58a9d1 by doyougnu at 2022-11-07T12:00:37+01:00 GHC.Utils.Binary: BinDictionary -> FSTable Rename to avoid naming conflict with haddock. - - - - - b8031f53 by Josh Meredith at 2022-11-07T12:00:37+01:00 Adjust derefnull test exit code for ghcjs - - - - - 4db27dfc by doyougnu at 2022-11-07T12:00:37+01:00 Fix Driver missing type signature warnings - - - - - 189380e3 by doyougnu at 2022-11-07T12:00:37+01:00 PipeLine.Execute: silence warnings on JS backend - - - - - f591a4d7 by doyougnu at 2022-11-07T12:00:37+01:00 JS.Primops: Add Bit reverse ops - - - - - 2f0889fc by doyougnu at 2022-11-07T12:00:37+01:00 SysTools.Tasks: quiet non-totality warnings - - - - - c0157c3d by doyougnu at 2022-11-07T12:00:37+01:00 JS.Primops: Add InterlockedExchange Addr Word - - - - - 3a018a93 by Sylvain Henry at 2022-11-07T12:00:37+01:00 base: conditional js-sources - - - - - 88e49b2c by Sylvain Henry at 2022-11-07T12:00:37+01:00 TH: add support for JS files - - - - - 955d2a2d by Sylvain Henry at 2022-11-07T12:00:37+01:00 Linker: fix creation of directories in output paths - - - - - 8c574a21 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Backpack: fix empty stubs - - - - - ea3748c7 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Add encodeDouble/Float RTS functions - - - - - b8054f88 by Sylvain Henry at 2022-11-07T12:00:37+01:00 encodeDouble: correctly handle 0 base - - - - - c643075a by doyougnu at 2022-11-07T12:00:37+01:00 JS.Primops: Add listThreads op - - - - - ae1da364 by doyougnu at 2022-11-07T12:00:37+01:00 JS.Primops: Add Read/WriteAddrOp ops - - - - - 579a5c1e by doyougnu at 2022-11-07T12:00:37+01:00 JS: Linker and Compactor: cleanup and docs Compactor: Cleanup: Remove dead comments JS.Linker.Types: cleanup and document module - - - - - 219b6d2e by doyougnu at 2022-11-07T12:00:37+01:00 StgToJS.Linker: Add docs to utility modules StgToJS.Linker.Utils: more docs StgToJS.Linker.Archive: more docs - - - - - 4d088f80 by doyougnu at 2022-11-07T12:00:37+01:00 StgToJS.Object: Add documentation - - - - - 684f9ddd by Sylvain Henry at 2022-11-07T12:00:37+01:00 Refactor Expr - - - - - 2a49a5cc by Sylvain Henry at 2022-11-07T12:00:37+01:00 Object: reduce pinned allocation. And don't forget to hClose invalid objects - - - - - e1396ff4 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Fix pdep (cgrun075) - - - - - 2257247e by Sylvain Henry at 2022-11-07T12:00:37+01:00 Fix error message (don't mention emscripten) - - - - - 4f190e69 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Add Float/Word casts - - - - - 228ff97e by Sylvain Henry at 2022-11-07T12:00:37+01:00 Disable HPC tests with JS backend - - - - - 8b33c1e4 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Fix encodeDouble/Float - - - - - 41d88112 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Implement putchar (fix cgrun015) - - - - - 705553e1 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Fix decoding of denormalized floats - - - - - 85a94e2e by Sylvain Henry at 2022-11-07T12:00:37+01:00 Fix isFloatDenormalized function - - - - - 8752e19e by Sylvain Henry at 2022-11-07T12:00:37+01:00 Reuse convert buffer - - - - - 30196ab3 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Reuse convert buffer bis - - - - - 6da34166 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Skip some tests that require the dynamic linker - - - - - 84c5818e by Josh Meredith at 2022-11-07T12:00:37+01:00 JavaScript ShrinkSmallMutableArrayOp_Char & GetSizeofSmallMutableArrayOp - - - - - c9f6d0d5 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Disable more linker tests - - - - - 8c708c2f by Sylvain Henry at 2022-11-07T12:00:37+01:00 Testsuite: better normalisation for ghc and ghc-pkg Allow normalisation for ghc and ghc-pkg anywhere in the output, not just at the beginning of the line. Fix T1750 and ghcpkg05 for example - - - - - bef86fbf by Sylvain Henry at 2022-11-07T12:00:37+01:00 Skip T14373 because it requires Cmm - - - - - a691faa9 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Disable cg010 with JS backend - - - - - a2767702 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Testsuite: better normalisation of .jsexe extension - - - - - 09a691c6 by doyougnu at 2022-11-07T12:00:37+01:00 JS: Linker,Rts docs and cleanup JS.Linker: Cleanup: remove unused functions/types JS.Rts.Types: remove dead code, docs StgToJS.RTS: cleanup and more docs - - - - - 62c3eaec by Sylvain Henry at 2022-11-07T12:00:37+01:00 Disable recomp015 - - - - - 1641c066 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Minor refactoring - - - - - 7f6e5d3d by Sylvain Henry at 2022-11-07T12:00:37+01:00 Temporary fix the testsuite bug - - - - - c3bd0af7 by doyougnu at 2022-11-07T12:00:37+01:00 JS.StgToJS.Types: Docs and cleanup - - - - - 7e572323 by Josh Meredith at 2022-11-07T12:00:37+01:00 change JS.Transform.Idents* to use UniqDSet from Set - - - - - a4721344 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Minor Linker cleanup Minor cleanup - - - - - 70f2a1c0 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Linker: load all the dependent units transitively - - - - - 5384d0ce by doyougnu at 2022-11-07T12:00:37+01:00 JS: Add Docs and cleanup StgToJS.{Arg,Ids} JS.Arg: docs and cleanup StgToJS.Arg: add minimal docs StgToJS.Ids: Add header - - - - - dfaa3402 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Implement h$sleep (T5611) - - - - - 8920eb8a by Sylvain Henry at 2022-11-07T12:00:37+01:00 Linker: don't link the same unit twice - - - - - 4f9c2179 by doyougnu at 2022-11-07T12:00:37+01:00 JS: docs, cleanup, StgToJS.{Expr,DataCon,Stack} StgToJS.Deps/Expr: add docs StgToJS.DataCon: add minor docs StgToJS.Stack: Docs and cleanup In particular: -- Removing some single use functions -- Some minor refactors related to these removals StgToJS: comments on static args and optimizeFree - - - - - ca78df0c by Sylvain Henry at 2022-11-07T12:00:37+01:00 Disable compact tests - - - - - dd852a3d by Sylvain Henry at 2022-11-07T12:00:37+01:00 Add support for JS files passed on the command line - - - - - 8b7864b7 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Minor cleanup in compactor - - - - - a462f871 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Fix encoding of unboxed strings (don't pass through FastString/h$str) - - - - - 1036d2af by doyougnu at 2022-11-07T12:00:37+01:00 JS: Misc fixes post Del-Cont rebase - - - - - a5496b85 by Sylvain Henry at 2022-11-07T12:00:37+01:00 Minor cleanup - - - - - e4fe1cbd by Sylvain Henry at 2022-11-07T12:00:38+01:00 Add log1p and expm1 (fix cgrun078) - - - - - 78c372b1 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Assume existence of Math.fround and use it in Float's primops - - - - - dccfcb44 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable "debug" test - - - - - 4175c3b1 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Implement copyMutableArray with overlap support - - - - - c58988e2 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Skip CmmSwitchTests - - - - - c1d25d43 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Fix WordToDouble/WordToFloat (Word2Float32 test) - - - - - 270016d8 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Skip one more test - - - - - 7bf238c6 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Fix after GHC.Tuple to GHC.Tuple.Prim - - - - - 1aeb64e6 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Fix InterlockedExchange primops (cgrun080) - - - - - 8dd6ed0c by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable T12059 - - - - - 0bd26d1d by Sylvain Henry at 2022-11-07T12:00:38+01:00 Implement sqrt/sqrtf (fix T14619) - - - - - 8b83d685 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Skip more tests - - - - - db5551d8 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable conc012 - - - - - 40e2ed98 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable more Cmm tests - - - - - 6fa0cfbe by Sylvain Henry at 2022-11-07T12:00:38+01:00 Fix AtomicPrimops test. Some refactoring in Prim too - - - - - 63c04257 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Use GHCJS's signExtend/narrow - - - - - 2fa81b78 by Josh Meredith at 2022-11-07T12:00:38+01:00 Implement get/set thread label prims - - - - - 197f9006 by doyougnu at 2022-11-07T12:00:38+01:00 JS: remove Linker.Archive module - - - - - 478bde93 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Start disabling tests that use TH/interpreter - - - - - ca3f3882 by Josh Meredith at 2022-11-07T12:00:38+01:00 Add flagged bounds checking to JS primops - - - - - 714f7f30 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable more tests - - - - - ca29997e by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable T1791 - - - - - 68250752 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Raise NonTermination as an async exception - - - - - 97f55fb1 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Expect IOPort test to be broken - - - - - 62eb3fc8 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Implement rts_isThreaded (fix jules_xref2) - - - - - f56f38cd by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable outofmem2 test - - - - - 400be300 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable delimited continuation tests - - - - - 0dc1fa6f by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable native RTS flag tests - - - - - 0c3bd84b by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable more tests - - - - - 0a342243 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable more tests - - - - - 36d633c8 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Skip more tests - - - - - 932c1aed by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable try_putmvar tests that use C files - - - - - edd7dc1b by Sylvain Henry at 2022-11-07T12:00:38+01:00 Disable even more tests - - - - - e00f1aee by Sylvain Henry at 2022-11-07T12:00:38+01:00 Linker: remove dead code (base, compactor) - - - - - 91f002d3 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Better shims linking - - - - - c722dbff by Sylvain Henry at 2022-11-07T12:00:38+01:00 Make isJsFile a bit faster by only reading the header - - - - - 4c3681d5 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Linker: write directly into output file - - - - - 7f91cf40 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Linker: more refactoring - - - - - 2a57288a by Sylvain Henry at 2022-11-07T12:00:38+01:00 Lazy loading of JStat in object code - - - - - 29a55de0 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Use Ppr hack to render directly into a file - - - - - 06f40e79 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Fix backpack dependencies - - - - - e8b9ffdc by doyougnu at 2022-11-07T12:00:38+01:00 testsuite: add js_skip_csources function Used to indicate a test that fails in the JS backend because the JS Backend does not yet support c-sources in cabal files. - - - - - 2e3c8614 by doyougnu at 2022-11-07T12:00:38+01:00 testsuite: JS: skip tests which use c-sources Skip because these tests use c-sources and the JS backend does not yet support including c-sources testsuite: JS backend: skip backpack tests testsuite: JS: skip c-sources ffi tests testsuite: JS: skip multipleHomeUnits_odir testsuite: JS: disable more backpack tests testsuite: JS: disable c-sources rts tests testsuite: JS: skip c-sources codeGen tests testsuite: JS: skip c-sources generics test - - - - - 61c5fd82 by Josh Meredith at 2022-11-07T12:00:38+01:00 use exit code 134 for JS prim bounds checks - - - - - 42665016 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Remove panic in getObject - - - - - b0d4d92b by Sylvain Henry at 2022-11-07T12:00:38+01:00 Add debug and Outputable instances - - - - - 84b4c5e4 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Remove backup file - - - - - 4dc542d4 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Skip overflow tests - - - - - 8f398a1c by Sylvain Henry at 2022-11-07T12:00:38+01:00 Fix RTS includes for native build - - - - - 6bd26bfa by Sylvain Henry at 2022-11-07T12:00:38+01:00 Doc - - - - - b2fe0dd9 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Add perf-js Hadrian flavour - - - - - 95e09b94 by doyougnu at 2022-11-07T12:00:38+01:00 JS.Syntax: fix doc wording - - - - - 34d198d1 by doyougnu at 2022-11-07T12:00:38+01:00 Driver: JS: tweak error message - - - - - 9b7f6b88 by Josh Meredith at 2022-11-07T12:00:38+01:00 Factor JS platform constants and h$programArgs/h$rtsArgs into functions with init - - - - - c9d19eca by Josh Meredith at 2022-11-07T12:00:38+01:00 Fix function name from h$shrinkMutableArray to h$shrinkMutableCharArray - - - - - 3b774187 by Luite Stegeman at 2022-11-07T12:00:38+01:00 allow async exceptions to be thrown from outside a haskell thread - - - - - e7f3a94e by Sylvain Henry at 2022-11-07T12:00:38+01:00 Remove shims and refactor Cpp I've removed the use of js/rts.h and js/constants.h again. We generate their contents at cpp time. Instead of wiring z-encoded strings into these macros, we should derive them from wired-in Names so that they stay correct in the future. Using wired-in Names as single source of truth. - - - - - d061367c by Sylvain Henry at 2022-11-07T12:00:38+01:00 Support RTS globals (used by GHC) and EISDIR Did this while trying to fix CallArity1 (still failing) - - - - - 17cfb76b by Sylvain Henry at 2022-11-07T12:00:38+01:00 Remove JS keywords 1. The list is incomplete 2. We prefix locals with "h$$" so there is no risk of conflict with JS keywords - - - - - 45d221d6 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Remove dead code - - - - - b27e1b3d by Sylvain Henry at 2022-11-07T12:00:38+01:00 Make ident supply strict (no need to make it lazy, list already is) - - - - - 4202be34 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Add optional assign to DeclStat and remove dead code - - - - - d227b7a4 by doyougnu at 2022-11-07T12:00:38+01:00 JS: Note on JS .o file order, fix .o files To be specific: 1. add Note [JS Backend .o file procedure] 2. ensure that .o files are touch'd in JS backend postHsc phase. This fixes "missing object file" errors produced by 'GHC.Driver.Main.checkObjects'. - - - - - a7ab24ca by Luite Stegeman at 2022-11-07T12:00:38+01:00 start a subtransaction in a catchStm block - - - - - b305e965 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Use FastMutInt in G for uniques - - - - - 13e9f0f0 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Compactor: remove dead code - - - - - 358f271f by Sylvain Henry at 2022-11-07T12:00:38+01:00 Compactor: remove more dead code - - - - - f67faf66 by Sylvain Henry at 2022-11-07T12:00:38+01:00 Compactor: remove unused debug code - - - - - 01afaf89 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Compactor: remove unimplemented packStrings - - - - - f2c605ed by Sylvain Henry at 2022-11-07T12:00:39+01:00 RTS: fix query/replace error - - - - - 150931ac by Luite Stegeman at 2022-11-07T12:00:39+01:00 remove unused STM check invariants - - - - - 1d28ba1d by Josh Meredith at 2022-11-07T12:00:39+01:00 Refactor renaming functions from Compactor module into the Linker - - - - - 80d11820 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Linker: refactor and cleanup after compactor removal - - - - - dafdff45 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Filter empty exports to avoid printing a lot of useless newlines - - - - - 68dcc501 by Sylvain Henry at 2022-11-07T12:00:39+01:00 RTS: remove dangling semicolons - - - - - a941cbc5 by Sylvain Henry at 2022-11-07T12:00:39+01:00 RTS: remove more dangling semicolons - - - - - 61df3a90 by Sylvain Henry at 2022-11-07T12:00:39+01:00 RTS: less semicolons - - - - - ba07d4d2 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Only initialize statics once! - - - - - c1989367 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Minor refactoring: avoid unpacking ShortText too soon - - - - - c8230371 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Remove unused derived instances - - - - - 11a08d1d by Sylvain Henry at 2022-11-07T12:00:39+01:00 Use Ident in ClosureInfo instead of FastString - - - - - 9382a927 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Add identFS helper - - - - - 7506fdc3 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Fix liftToGlobal identsS wasn't correctly ported: it has to return all the Ident occurences, not only one. Fixed this and simplified liftToGlobal implementation. Used UniqFM instead of Map forn the global ident cache. - - - - - ddbb22e5 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Refactor symbol generation. Avoid concatenating Strings or FastStrings. Concatenate ByteString instead. - - - - - 42b34b48 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Enhance Label symbol generation - - - - - e339232a by Sylvain Henry at 2022-11-07T12:00:39+01:00 Rename fresh idents with their FastString unique Reduce by 2x the size of the generated file (on Cabal's Setup). - - - - - 15740832 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Disable more tests - - - - - f4ab41da by Sylvain Henry at 2022-11-07T12:00:39+01:00 Disable more tests - - - - - eb2b5359 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Disable ghc-heap tests - - - - - dcef91d6 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Mark flaky test as fragile - - - - - 32d42f3d by Sylvain Henry at 2022-11-07T12:00:39+01:00 Fix bound checking - - - - - 95589287 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Fix note - - - - - 10158c58 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Disable more tests - - - - - 966ce0ec by Sylvain Henry at 2022-11-07T12:00:39+01:00 Disable more tests - - - - - fa470c25 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Disable more tests - - - - - b771cb1f by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: force ghc-pkg to use stage1 - - - - - 0e1a5754 by doyougnu at 2022-11-07T12:00:39+01:00 fix linker errors post rebase Re-add InitFini.c to the rts, it was introduced in 78ab7afe244a7617d600a6180d81d9dec657114d but was somehow removed after a rebase. - - - - - 9300e8ff by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: rts disable rtsflags001 for JS backend - - - - - ab847441 by Josh Meredith at 2022-11-07T12:00:39+01:00 Disable runInteractiveProcess tests for ghcjs - - - - - 3b5e22c8 by Josh Meredith at 2022-11-07T12:00:39+01:00 Disable fed001 test for javascript backend - - - - - d837ccb4 by Josh Meredith at 2022-11-07T12:00:39+01:00 Disable driver tests for JS backend that use foreign exports - - - - - 74300207 by Josh Meredith at 2022-11-07T12:00:39+01:00 Disable ImpSafeOnly01..10 for JavaScript backend - - - - - 52c92f65 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Add missing GHC globals - - - - - 73ea5245 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: disable ffi for JS backend More Specically disable: ffi006 ffi008 ffi011 ffi013 ffi018 ffi019 ffi020 ffi021 ffi023 - - - - - 47b8374b by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: disable ghci linking tests for JS Specifically: ghcilink001 ghcilink003 ghcilink005 ghcilink006 - - - - - 38d2456d by Sylvain Henry at 2022-11-07T12:00:39+01:00 Fix comment - - - - - e72b9d42 by Sylvain Henry at 2022-11-07T12:00:39+01:00 More bound checking - - - - - e8b577fc by Sylvain Henry at 2022-11-07T12:00:39+01:00 Fix some Word reading in Prim - - - - - 81cfb42b by Sylvain Henry at 2022-11-07T12:00:39+01:00 Implement openDir Seems to work (with tracing) but tests still fail with getInt16 index error :'( - - - - - bab97374 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: disable cabal tests for JS backend - - - - - 38a8fb4b by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: disable bkpcabal[01-07] for JS backend - - - - - 55e91980 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: disable tests that cause OOM on JS These tests require the JS Backend to implement GHCJS's compactor, until that happens nodejs throws an exception that variable names are too long, hence we disable them. - - - - - 5c13e13e by Sylvain Henry at 2022-11-07T12:00:39+01:00 Disable HPC tests Bump hpc submodule - - - - - 06ce1fbe by Sylvain Henry at 2022-11-07T12:00:39+01:00 Avoid useless space change - - - - - 2388bff4 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Remove duplicated comment - - - - - efaaeb2f by Sylvain Henry at 2022-11-07T12:00:39+01:00 Readd useless space - - - - - fcb0ff6f by Sylvain Henry at 2022-11-07T12:00:39+01:00 Fix some rts.cabal.in rebase glitches - - - - - 6d61f5c1 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: disable T12233 tests for JS backend - - - - - 45a16ff4 by Sylvain Henry at 2022-11-07T12:00:39+01:00 Fix rts.cabal.in again - - - - - 038a5233 by Luite Stegeman at 2022-11-07T12:00:39+01:00 fix typo in dumpStackTop function - - - - - 46092517 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: remove js_skip_csources, use c_src - - - - - 465a7149 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip recomp4,8 on JS backend - - - - - 19dfe7cb by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip alloccounter1 and T19156 for JS These tests fail due to missing primops - - - - - cf778b07 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip T7773 and topHandler01 for JS - - - - - e431e6f2 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip rdynamic and T2615 for JS Backend - - - - - 81f782da by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip T4012 for JS backend - - - - - 3a4db7bc by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip T15427 for JS backend - - - - - 14b6b49b by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip T19481, T19381, T3474 for JS - - - - - ecdf8ab7 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip stack004 for JS backend - - - - - 326b5d1a by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: JS skip ThreadDelay001 and encoding004 - - - - - 2f52e89d by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: skip openFile003 for JS backend - - - - - b339c300 by doyougnu at 2022-11-07T12:00:39+01:00 testsuite: disable T1959 and capi tests for JS - - - - - 50873e1d by Sylvain Henry at 2022-11-07T12:00:40+01:00 Replace c_src with req_c - - - - - 5c334cbe by Sylvain Henry at 2022-11-07T12:00:40+01:00 Fix testsuite - - - - - 616cbfc4 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: disable CallArity, LintEtaExpand etc These cause a illegal op on directory error. Disable for now: CallArity1 LintEtaExpand T9595 T10942 T18522-dbg-ppr - - - - - 612add89 by Luite Stegeman at 2022-11-07T12:00:40+01:00 fix isJsCore predicates for base package - - - - - 3268f295 by Sylvain Henry at 2022-11-07T12:00:40+01:00 CI: add CI script for the JS backend - - - - - 22529977 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Fix rts.cabal again - - - - - 8cdde421 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Fix invalid use of predStage - - - - - 73f08f68 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Fix hlint errors on CI - - - - - 1228ead8 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: disable that throw out of bounds on JS Specifically: T12733 T1372 T15594 T16219 T18567 T20509 T3007 different-db mhu-closure package-imports-20779 t19518 - - - - - bb140369 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip EventlogOutput{1,2} for JS backend - - - - - 2c39d200 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T1679, T2469, T4038 for JS and also skip UnliftedTVar2 - - - - - f0fbfeb3 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T4891 for JS backend This one throws illegal op on directory similar to T10942 and CallArity1 - - - - - d3c998da by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T8308 for JS JS backend does not have any ticky capability yet, so skip for now - - - - - cbeed236 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T9405 for JS JS backend does not yet support ticky - - - - - 8c1f2d3e by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T14624, T20199 for JS backend - - - - - 8c5e44d7 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T5594 and T5402 for JS - - - - - 26d948da by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip openFile00{5,7} readFile001 for JS - - - - - b957dcfe by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T11004 and T12504 for JS - - - - - 15aac110 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip hGetBuf001, hReady00{1,2} for JS - - - - - 18dadb82 by doyougnu at 2022-11-07T12:00:40+01:00 fixup: missed readwrite002 - - - - - 15197e96 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T18642 for JS - - - - - 9723dbab by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip TargetContents for JS - - - - - 30a07812 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T18481a T10678 and friends - - - - - 8b79fc41 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip RepPolyUnliftedDatatype2 for JS - - - - - 9aebafb0 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip ghci some tests these throw not built for interactive use errors - - - - - 071c0b44 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip DocsInHiFileTH for JS - - - - - db344db8 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T7037, T7702, safePkg01 for JS - - - - - 33abb70c by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip tests that throw gmake error Specifically: T15261a T15261b T16318 T17648 T20214 T21336c rtsopts002 withRtsOpts - - - - - 0436f38d by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T3837, hsc2hs003 typecheck.testeq1 - - - - - b908e590 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip fat005 for JS - - - - - 974b04ca by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip topHandler02,03 for JS - - - - - d83cf0ce by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip tests that unexpected pass/fail - - - - - c1bc5e13 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Try to fix Hadrian for native - - - - - 789afd7c by Luite Stegeman at 2022-11-07T12:00:40+01:00 fix index.html template newlines and use all.js for now (at least it works) - - - - - 98edbc1f by Sylvain Henry at 2022-11-07T12:00:40+01:00 Fix testsuite typo - - - - - bddc2097 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip golden failure tests Specifically: GcStaticPointers T13167 T14452 T16707 T17481 T7160 bkp32 fptr01 - - - - - 4ac46fd6 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T13525 for JS Fails for missing h$base_mkfifo - - - - - c8b9568c by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip tests which timeout on JS Specifically: Timeout001 listThreads mask002 - - - - - df8379e9 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip failing IO tests for JS Specifically: hClose002 hFileSize002 hSetBuffering003 sum_mod - - - - - a00807c8 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip countReaders001 for JS - - - - - f5373bc0 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T10414 for JS backend - - - - - cfacaefc by Luite Stegeman at 2022-11-07T12:00:40+01:00 correct stack offset when restarting an STM transaction - - - - - 4048438a by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T11155 T21336a T21869 for JS - - - - - 153d24c3 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip failing linker and hp2ps tests - - - - - a1c806dd by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip out of memory tests for JS - - - - - 6a5797cb by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip remaining failing tests for JS - - - - - 517c4a60 by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: fix typo - - - - - 1e96c8e7 by doyougnu at 2022-11-07T12:00:40+01:00 hadrian: fix js and native testing - - - - - 65cdc7b3 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Skip one test - - - - - 23871e96 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Skip one more test - - - - - dfbe83b8 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Add missing comma - - - - - 9da8a140 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Only change the test environment for cross - - - - - db4a874c by Sylvain Henry at 2022-11-07T12:00:40+01:00 Force creation of hpc/haddock/runghc programs for cross - - - - - 60742721 by doyougnu at 2022-11-07T12:00:40+01:00 process: skip process tests for JS backend - - - - - 5e0466cf by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip remaining failing tests for JS - - - - - 28be2c3e by doyougnu at 2022-11-07T12:00:40+01:00 process: skip T1780, T8343, T4889 for JS - - - - - 2f6d19dd by doyougnu at 2022-11-07T12:00:40+01:00 testsuite: skip T12852 for JS backend - - - - - 1a4e18f2 by doyougnu at 2022-11-07T12:00:40+01:00 stm: skip failing tests for JS backend - - - - - 968a3047 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Some changes to Binary after reviews - - - - - 06359357 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Rename back defaultUserData into noUserData - - - - - ad072cfc by Sylvain Henry at 2022-11-07T12:00:40+01:00 Revert backpack change - - - - - e8f3f586 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Don't create directory in copyWithHeader - - - - - af2d8122 by Sylvain Henry at 2022-11-07T12:00:40+01:00 Remove now useless changes to Ppr - - - - - ed2ecb11 by Josh Meredith at 2022-11-07T12:00:40+01:00 Change js_skip to js_broken(22350) for ImpSafeOnly01..10 tests - - - - - cf5beb9a by Josh Meredith at 2022-11-07T12:00:40+01:00 Change js_broken(22350) to js_skip for safePkg01 test - - - - - 3f9ec9ae by doyougnu at 2022-11-07T12:00:41+01:00 testsuite: Cabal js_skip -> js_broken(22351) Issue: https://gitlab.haskell.org/ghc/ghc/-/issues/22351 - - - - - 529fddaa by doyougnu at 2022-11-07T12:00:41+01:00 add req_js_compactor, update impacted tests Issue: https://gitlab.haskell.org/ghc/ghc/-/issues/22352 - - - - - 3e94692a by doyougnu at 2022-11-07T12:00:41+01:00 testsuite: mark more tests with req_js_compactor - - - - - 80f6259b by doyougnu at 2022-11-07T12:00:41+01:00 testsuite: js_skip -> js_broken(22355) more tests Specifically: T11004 T12504 T3837 hsc2hs003 T15758 exec_signals hsc2hs001 hsc2hs002 typecheck.testeq1 See tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/22355 - - - - - e9ce532b by doyougnu at 2022-11-07T12:00:41+01:00 testsuite: mark #22356 tests as js_broken Specifically: T12733 T1372 T15594 T16219 T18567 T20509 T3007 different-db mhu-closure package-imports-20779 t19518 - - - - - d9136464 by Josh Meredith at 2022-11-07T12:00:41+01:00 Use js_broken(22349) for releavant base tests - - - - - 854b4a94 by Josh Meredith at 2022-11-07T12:00:41+01:00 Use js_broken(22359) for relevant tests - - - - - 58d04f83 by Josh Meredith at 2022-11-07T12:00:41+01:00 Use js_broken(22360) for releavant tests - - - - - 053e802a by Josh Meredith at 2022-11-07T12:00:41+01:00 Use req_ffi_exports for JS-skipped driver* tests - - - - - b991f95b by Josh Meredith at 2022-11-07T12:00:41+01:00 Use req_c for some JS-skipped tests - - - - - 40eb1e63 by Josh Meredith at 2022-11-07T12:00:41+01:00 Use js_broken(22362) for package.conf.d errored tests - - - - - 62c44bd4 by Josh Meredith at 2022-11-07T12:00:41+01:00 Use req_interp for JS-skipped ghcilink001/3/5/6 - - - - - 11dca8df by Josh Meredith at 2022-11-07T12:00:41+01:00 Use js_broken(22363) for affected ffi000 tests - - - - - cc880888 by Josh Meredith at 2022-11-07T12:00:41+01:00 Use js_broken(22364) for affected tests - - - - - f1fde6ac by doyougnu at 2022-11-07T12:00:41+01:00 testsuite: mark tests as js_broken(22370) Specifically: rtsopts002 T15261a T15261b T16318 T17648 T20214 T21336c withRtsOpts Tracking ticket: #22370 - - - - - 9ddfec50 by Josh Meredith at 2022-11-07T12:00:41+01:00 Use js_broken(22351) for T10955dyn - - - - - 041c15eb by Sylvain Henry at 2022-11-07T12:00:41+01:00 Remove trailing semicolons - - - - - 75a0a2a0 by Sylvain Henry at 2022-11-07T12:00:41+01:00 Minor fixes after rebase - - - - - c33164a6 by doyougnu at 2022-11-07T12:00:41+01:00 test: T23674{w} recomp004 load_short_name -> req_c - - - - - 1baf6791 by Josh Meredith at 2022-11-07T12:00:41+01:00 Upgrade miscellaneous tests from js_skip to js_broken(22261) - - - - - 896e9aca by doyougnu at 2022-11-07T12:00:41+01:00 testsuite mark compactor tests as js_broken(22352) - - - - - 76542403 by doyougnu at 2022-11-07T12:00:41+01:00 testsuite: mark tests js_skip -> js_broken(22374) Specifically: hGetBuf001 T12852 T12903 rdynamic T2615 T4012 T15427 T18642 T19381 T19481 T3474 stack004 encoding004 ThreadDelay001 TargetContents openFile003 T13525 Tracking Ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/22374 - - - - - d41b5d5c by doyougnu at 2022-11-07T12:00:41+01:00 stm: mark tests for JS backend as broken - - - - - d9302c9c by doyougnu at 2022-11-07T12:00:41+01:00 testsuite: mark js_skip -> js_broken(22261) Specifically: DocsInHiFileTH alloccounter1 T19156 rtsflags002 T7773 topHandler01 T1959 T1679 T2469 T4038 UnliftedTVar2 T15136 T8308 T9405 openFile005 openFile007 readFile001 countReaders001 RepPolyUnliftedDatatype2 fat005 topHandler02 topHandler03 T10414 T11760 T12035j T13191 T14075 T16473 T17499 T17720a T17720b T17720c T20030_test1j T3924 T8766 T9839_01 T9848 fptr01 GcStaticPointers T13167 T14452 T17481 T7160 listThreads mask002 Timeout001 hClose002 hFileSize002 hSetBuffering003 sum_mod T11155 T21336a T21869 T15904 MergeObjsMode recomp011 T13914 executablePath rn.prog006 T16916 recomp008 - - - - - 202b3876 by Sylvain Henry at 2022-11-07T12:00:41+01:00 Remove added configure comment - - - - - 1dec7c0c by Sylvain Henry at 2022-11-07T12:00:41+01:00 Fix res_js_compactor leftover - - - - - 96595cec by doyougnu at 2022-11-07T12:00:41+01:00 testsuite: mark more tests as broken for JS Specifically tests which throw reference errors: hReady001 hReady002 readwrite002 fed001 Capi_Ctype_001 Capi_Ctype_002 T7037 Tracking ticket: https://gitlab.haskell.org/ghc/ghc/-/issues/22374 - - - - - 8d3c321d by doyougnu at 2022-11-07T12:00:41+01:00 genToplevelConEntry: Fix for InferTags at Stg - - - - - e07a6848 by Sylvain Henry at 2022-11-07T12:00:41+01:00 Disable SplcieTypes test - - - - - 19acce62 by doyougnu at 2022-11-07T12:00:41+01:00 Hadrian: add no_dynamic_libs transformer - - - - - 0f124b58 by doyougnu at 2022-11-07T12:00:41+01:00 Hadrian: Add releaseJsFlavour - - - - - 61319117 by doyougnu at 2022-11-07T12:00:41+01:00 Hadrian: Add enableO2Stage0 transformer And update release-js build flavour - - - - - 11169529 by Sylvain Henry at 2022-11-07T12:00:41+01:00 Remove redundant import - - - - - 7ed278b3 by Sylvain Henry at 2022-11-07T12:00:41+01:00 Remove unused linker config options - - - - - 0b5078c6 by doyougnu at 2022-11-07T12:00:41+01:00 Hadrian: add useNativeBignum transformer - - - - - 83752133 by doyougnu at 2022-11-07T12:00:41+01:00 Hadrian: add Flavours.JavaScript Better Cohesion. - - - - - 510d240a by doyougnu at 2022-11-07T12:00:41+01:00 fixup: forgot to remove now duplicate flavours - - - - - 81da5e78 by Josh Meredith at 2022-11-07T12:00:41+01:00 Change js_skip to js_broken(22261) in process submodule - - - - - 7c44ab01 by doyougnu at 2022-11-07T12:00:41+01:00 Hadrian: add perf_stage0 transformer - - - - - 2d19cb25 by doyougnu at 2022-11-07T12:00:41+01:00 Hadrian: remove javascript specific flavours - - - - - 146915ec by doyougnu at 2022-11-07T12:00:41+01:00 Hadrian: update docs with new transformers Specifically: - ticky_ghc0 - perf_stage0 - no_dynamic_libs - - - - - a722c1c7 by Sylvain Henry at 2022-11-07T12:00:41+01:00 Enable more tests that were "unexpected passes" - - - - - 12a76e06 by Sylvain Henry at 2022-11-07T12:00:41+01:00 Take cross into account in perf and ticky flavours - - - - - aa2cab6a by Sylvain Henry at 2022-11-07T12:00:41+01:00 Remove PerfJS mention in ci script - - - - - 96859f6a by Sylvain Henry at 2022-11-07T12:00:41+01:00 Make CI script install emscripten - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.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/DmdAnal.hs - compiler/GHC/Core/Opt/OccurAnal.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8467a5284bde461e132812cd40242852e3ff7962...96859f6ac5549e10ab5dbe839c7f3ab0113c4481 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8467a5284bde461e132812cd40242852e3ff7962...96859f6ac5549e10ab5dbe839c7f3ab0113c4481 You're receiving 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 Nov 7 10:59:04 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 05:59:04 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] 3 commits: CI: Allow hadrian-ghc-in-ghci to run in nightlies Message-ID: <6368e4f875e70_11c7e2491e83747013fc@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - 4f1b1000 by Josh Meredith at 2022-11-07T12:02:11+01:00 Add JS backend Bump submodules - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backend/Internal.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/StgToCmm.hs - + compiler/GHC/Driver/Config/StgToJS.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Phases.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a26a8497fd7ff54da4c1fa982666127f5ff4731...4f1b1000c4192daea350f104357630ffd64a44a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5a26a8497fd7ff54da4c1fa982666127f5ff4731...4f1b1000c4192daea350f104357630ffd64a44a5 You're receiving 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 Nov 7 12:42:34 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 07:42:34 -0500 Subject: [Git][ghc/ghc][wip/js-staging] Try to source emscripten correctly Message-ID: <6368fd3aac95b_11c7e23f339660723710@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: fc3b7466 by Sylvain Henry at 2022-11-07T13:46:06+01:00 Try to source emscripten correctly - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -376,7 +376,6 @@ function setup_emscripten() { cd emsdk ./emsdk install latest ./emsdk activate latest - source ./emsdk_env.sh cd .. } @@ -417,6 +416,11 @@ EOF } function configure() { + case $CONFIGURE_WRAPPER in + emconfigure) source emsdk/emsdk_env.sh ;; + *) ;; + esac + if [[ -z "${NO_BOOT:-}" ]]; then start_section "booting" run python3 boot View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc3b74668f886592855f5416cca0124d1a30b5fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc3b74668f886592855f5416cca0124d1a30b5fc You're receiving 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 Nov 7 12:42:48 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 07:42:48 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Try to source emscripten correctly Message-ID: <6368fd48dd2bc_11c7e2505c817c723970@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 01f8ee52 by Sylvain Henry at 2022-11-07T13:46:31+01:00 Try to source emscripten correctly - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -376,7 +376,6 @@ function setup_emscripten() { cd emsdk ./emsdk install latest ./emsdk activate latest - source ./emsdk_env.sh cd .. } @@ -417,6 +416,11 @@ EOF } function configure() { + case $CONFIGURE_WRAPPER in + emconfigure) source emsdk/emsdk_env.sh ;; + *) ;; + esac + if [[ -z "${NO_BOOT:-}" ]]; then start_section "booting" run python3 boot View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/01f8ee5250e84a54e331a1c1c00c5d38b660758a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/01f8ee5250e84a54e331a1c1c00c5d38b660758a You're receiving 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 Nov 7 13:28:59 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 07 Nov 2022 08:28:59 -0500 Subject: [Git][ghc/ghc][wip/T22274] Identify exit cases in OccurAnal Message-ID: <6369081b3536d_11c7e250635c2c7702d5@gitlab.mail> Sebastian Graf pushed to branch wip/T22274 at Glasgow Haskell Compiler / GHC Commits: 89c11517 by Sebastian Graf at 2022-11-07T14:28:26+01:00 Identify exit cases in OccurAnal Also had to mark a few key WordArray functions as INLINE so that they don't allocate a closure for the continuation. - - - - - 3 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Types/Unique/SlimSet.hs - libraries/ghc-bignum/src/GHC/Num/WordArray.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -34,7 +34,7 @@ import GHC.Core.Predicate ( isDictId ) import GHC.Core.Type import GHC.Core.TyCo.FVs ( tyCoVarsOfMCo ) -import GHC.Data.Maybe( isJust, orElse ) +import GHC.Data.Maybe( isJust, orElse, mapMaybe ) import GHC.Data.Graph.Directed ( SCC(..), Node(..) , stronglyConnCompFromEdgedVerticesUniq , stronglyConnCompFromEdgedVerticesUniqR ) @@ -48,6 +48,7 @@ import GHC.Types.Tickish import GHC.Types.Var.Set import GHC.Types.Var.Env import GHC.Types.Var +import GHC.Types.Unique.SlimSet import GHC.Types.Demand ( argOneShots, argsOneShots ) import GHC.Utils.Outputable @@ -59,6 +60,8 @@ import GHC.Utils.Trace import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) +import Data.IntMap.Strict (IntMap) +import qualified Data.IntMap.Strict as IntMap import Data.List (mapAccumL, mapAccumR) import Data.List.NonEmpty (NonEmpty (..), nonEmpty) import qualified Data.List.NonEmpty as NE @@ -831,7 +834,7 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndrs = map fst pairs bndr_set = mkVarSet bndrs - rhs_env = env `addInScope` bndrs + rhs_env = env `addInScope` bndrs `enterLoop` bndrs ----------------------------- @@ -2299,7 +2302,7 @@ occAnalApp env (Var fun_id, args, ticks) !(fun', fun_id') = lookupBndrSwap env fun_id !(WithUsageDetails args_uds app') = occAnalArgs env fun' args one_shots - fun_uds = mkOneOcc fun_id' int_cxt n_args + fun_uds = mkOneOcc env fun_id' int_cxt n_args -- NB: fun_uds is computed for fun_id', not fun_id -- See (BS1) in Note [The binder-swap substitution] @@ -2459,6 +2462,8 @@ scrutinised y). data OccEnv = OccEnv { occ_encl :: !OccEncl -- Enclosing context information , occ_one_shots :: !OneShots -- See Note [OneShots] + , occ_cur_lvl :: !LoopLevel -- ^ Current loop level + , occ_loops :: !(IdEnv LoopLevel) -- ^ The loop levels of enclosing letrec binders , occ_unf_act :: Id -> Bool -- Which Id unfoldings are active , occ_rule_act :: Activation -> Bool -- Which rules are active -- See Note [Finding rule RHS free vars] @@ -2507,6 +2512,8 @@ initOccEnv :: OccEnv initOccEnv = OccEnv { occ_encl = OccVanilla , occ_one_shots = [] + , occ_cur_lvl = 0 + , occ_loops = emptyVarEnv -- To be conservative, we say that all -- inlines and rules are active @@ -2546,6 +2553,11 @@ isRhsEnv (OccEnv { occ_encl = cxt }) = case cxt of OccRhs -> True _ -> False +lookupLoopLevel :: OccEnv -> Id -> Int +lookupLoopLevel (OccEnv { occ_loops = loops }) id + | Just lvl <- lookupVarEnv loops id = lvl + | otherwise = 0 + addOneInScope :: OccEnv -> CoreBndr -> OccEnv addOneInScope env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) bndr | bndr `elemVarSet` rng_vars = env { occ_bs_env = emptyVarEnv, occ_bs_rng = emptyVarSet } @@ -2559,6 +2571,24 @@ addInScope env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) bndrs | any (`elemVarSet` rng_vars) bndrs = env { occ_bs_env = emptyVarEnv, occ_bs_rng = emptyVarSet } | otherwise = env { occ_bs_env = swap_env `delVarEnvList` bndrs } +enterLoop :: OccEnv -> [Var] -> OccEnv +enterLoop env vs + = env { occ_cur_lvl = new_lvl + , occ_loops = extendVarEnvList (occ_loops env) [(v,new_lvl) | v<-vs] } + where + new_lvl = occ_cur_lvl env + 1 + +leaveLoop :: UsageDetails -> UsageDetails +leaveLoop ud = alterLoopLevelInfo ud f + where + f lli + | Just ((lvl, new_max_occs), inv') <- IntMap.maxViewWithKey (lli_inv lli) + = lli { lli_max = lvl + , lli_inv = inv' + , lli_non_max_lvls = nonDetFoldUniqSlimSet (\u nml -> delFromUFM_Directly nml u) (lli_non_max_lvls lli) new_max_occs + } + | otherwise + = emptyLoopLevelInfo -------------------- transClosureFV :: VarEnv VarSet -> VarEnv VarSet @@ -2976,14 +3006,42 @@ info then simply means setting the corresponding zapped set to the whole 'OccInfoEnv', a fast O(1) operation. -} -type OccInfoEnv = IdEnv OccInfo -- A finite map from ids to their usage - -- INVARIANT: never IAmDead - -- (Deadness is signalled by not being in the map at all) +type LoopLevel = Int + +-- | Level 0 is the loop level we never exit. Every letrec binder will have loop +-- level at least 1. +notLooping :: LoopLevel +notLooping = 0 + +type LoopLevelMap = IntMap + +type OccInfoEnv = IdEnv OccInfo + -- ^ A finite map from ids to their usage. + -- INVARIANT: The OccInfo is never IAmDead + -- (Deadness is signalled by not being in the map at all) type ZappedSet = OccInfoEnv -- Values are ignored +-- | Represents an efficient bidirectional mapping between occuring 'Id's +-- and the maximum 'LoopLevel' of the recursive binders with which they +-- co-occur. +data LoopLevelInfo + = LLI { lli_max :: !LoopLevel + -- ^ Maximum loop level of a rec binder occuring in the expression + , lli_non_max_lvls :: !(IdEnv Int) + -- ^ Binders that (are not dead, and) do not occur at loop level + -- 'lli_max' will have their loop-level stated here. + , lli_inv :: !(LoopLevelMap VarSlimSet) + -- ^ Inverse mapping of 'lli_non_max_lvls'. + -- If a binder has max loop level l, it will be regarded as "used on an + -- exit path" wrt. the loop with level l. + -- INVARIANT: The sets for different levels are disjoint + } + + data UsageDetails = UD { ud_env :: !OccInfoEnv + , ud_loop_info :: !LoopLevelInfo , ud_z_many :: !ZappedSet -- apply 'markMany' to these , ud_z_in_lam :: !ZappedSet -- apply 'markInsideLam' to these , ud_z_no_tail :: !ZappedSet } -- apply 'markNonTail' to these @@ -2997,13 +3055,40 @@ instance Outputable UsageDetails where andUDs, orUDs :: UsageDetails -> UsageDetails -> UsageDetails -andUDs = combineUsageDetailsWith addOccInfo -orUDs = combineUsageDetailsWith orOccInfo +andUDs = combineUsageDetailsWith addOccInfo andLoopLevelInfo +orUDs = combineUsageDetailsWith orOccInfo orLoopLevelInfo + +andLoopLevelInfo :: LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo +andLoopLevelInfo lvl _occs lli + | lvl >= lli_max lli = LLI { lli_max = lvl, lli_non_max_lvls = emptyVarEnv, lli_inv = IntMap.empty } + | otherwise = LLI { lli_max = lli_max lli + , lli_non_max_lvls = non_max_lvls' + , lli_inv = inv' + } + where + (lower, mb_exact, higher) = IntMap.splitLookup lvl (lli_inv lli) + raised_vars = IntMap.foldr unionUniqSlimSet (mb_exact `orElse` emptyUniqSlimSet) lower + inv' = IntMap.insert lvl raised_vars higher + non_max_lvls' = nonDetFoldUniqSlimSet (\u lvls -> addToUFM_Directly lvls u lvl) (lli_non_max_lvls lli) raised_vars + +orLoopLevelInfo :: LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo +orLoopLevelInfo lvl occs lli + | lvl <= lli_max lli = lli + | otherwise = LLI { lli_max = lvl + , lli_non_max_lvls = non_max_lvls' + , lli_inv = inv' + } + where + old_max_occs = occs `minusVarEnv` lli_non_max_lvls lli + inv' = IntMap.insert lvl (ufmDom old_max_occs) (lli_inv lli) + non_max_lvls' = mapVarEnv (const lvl) old_max_occs `plusVarEnv` lli_non_max_lvls lli -- NB: plusVarEnv is right-biased -mkOneOcc :: Id -> InterestingCxt -> JoinArity -> UsageDetails -mkOneOcc id int_cxt arity +mkOneOcc :: OccEnv -> Id -> InterestingCxt -> JoinArity -> UsageDetails +mkOneOcc env id int_cxt arity | isLocalId id - = emptyDetails { ud_env = unitVarEnv id occ_info } + , let !lvl = lookupLoopLevel env id + = emptyDetails { ud_env = unitVarEnv id occ_info + , ud_loop_info = emptyLoopLevelInfo { lli_max = lvl } } | otherwise = emptyDetails where @@ -3038,14 +3123,36 @@ addLamCoVarOccs uds bndrs delDetails :: UsageDetails -> Id -> UsageDetails delDetails ud bndr - = ud `alterUsageDetails` (`delVarEnv` bndr) + = ud `alterUsageDetails` (`delVarEnv` bndr) `alterLoopLevelInfo` (`delLoopLevel` bndr) delDetailsList :: UsageDetails -> [Id] -> UsageDetails delDetailsList ud bndrs - = ud `alterUsageDetails` (`delVarEnvList` bndrs) + = ud `alterUsageDetails` (`delVarEnvList` bndrs) `alterLoopLevelInfo` (`delLoopLevelList` bndrs) + +delLoopLevel :: LoopLevelInfo -> Id -> LoopLevelInfo +delLoopLevel lli@(LLI { lli_non_max_lvls = nml, lli_inv = inv }) id + | Just lvl <- lookupVarEnv (lli_non_max_lvls lli) id + = lli { lli_non_max_lvls = delVarEnv nml id + , lli_inv = IntMap.adjust (`delUniqSlimSet` id) lvl inv } + | otherwise + = lli + +delLoopLevelList :: LoopLevelInfo -> [Id] -> LoopLevelInfo +delLoopLevelList lli@(LLI { lli_non_max_lvls = nml, lli_inv = inv }) ids + = lli { lli_non_max_lvls = delVarEnvList nml ids + , lli_inv = foldr (IntMap.adjust (`minusUniqSlimSet` ids_set)) inv lvls } + where + ids_set = mkUniqSlimSet ids + lvls = mapMaybe (lookupVarEnv (lli_non_max_lvls lli)) ids + +emptyLoopLevelInfo :: LoopLevelInfo +emptyLoopLevelInfo = LLI { lli_max = notLooping + , lli_non_max_lvls = emptyVarEnv + , lli_inv = IntMap.empty } emptyDetails :: UsageDetails emptyDetails = UD { ud_env = emptyVarEnv + , ud_loop_info = emptyLoopLevelInfo , ud_z_many = emptyVarEnv , ud_z_in_lam = emptyVarEnv , ud_z_no_tail = emptyVarEnv } @@ -3059,7 +3166,7 @@ markAllMany ud = ud { ud_z_many = ud_env ud } markAllInsideLam ud = ud { ud_z_in_lam = ud_env ud } markAllNonTail ud = ud { ud_z_no_tail = ud_env ud } -markAllInsideLamIf, markAllNonTailIf :: Bool -> UsageDetails -> UsageDetails +markAllInsideLamIf, markMaxLvlInsideLamIf, markAllNonTailIf :: Bool -> UsageDetails -> UsageDetails markAllInsideLamIf True ud = markAllInsideLam ud markAllInsideLamIf False ud = ud @@ -3067,6 +3174,10 @@ markAllInsideLamIf False ud = ud markAllNonTailIf True ud = markAllNonTail ud markAllNonTailIf False ud = ud +markMaxLvlInsideLamIf False ud = ud +markMaxLvlInsideLamIf True ud@(UD{ud_loop_info=LLI{lli_non_max_lvls=nml}}) = + ud { ud_z_in_lam = ud_env ud `minusVarEnv` nml } + markAllManyNonTail = markAllMany . markAllNonTail -- effectively sets to noOccInfo @@ -3090,16 +3201,32 @@ restrictFreeVars bndrs fvs = restrictUniqSetToUFM bndrs fvs -- Auxiliary functions for UsageDetails implementation combineUsageDetailsWith :: (OccInfo -> OccInfo -> OccInfo) + -> (LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo) -> UsageDetails -> UsageDetails -> UsageDetails -combineUsageDetailsWith plus_occ_info ud1 ud2 +combineUsageDetailsWith plus_occ_info bump_loop_info ud1 ud2 | isEmptyDetails ud1 = ud2 | isEmptyDetails ud2 = ud1 | otherwise = UD { ud_env = plusVarEnv_C plus_occ_info (ud_env ud1) (ud_env ud2) + , ud_loop_info = combineLoopLevelInfoWith bump_loop_info (ud_env ud1) (ud_loop_info ud1) (ud_env ud2) (ud_loop_info ud2) , ud_z_many = plusVarEnv (ud_z_many ud1) (ud_z_many ud2) , ud_z_in_lam = plusVarEnv (ud_z_in_lam ud1) (ud_z_in_lam ud2) , ud_z_no_tail = plusVarEnv (ud_z_no_tail ud1) (ud_z_no_tail ud2) } +combineLoopLevelInfoWith :: (LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo) + -> OccInfoEnv -> LoopLevelInfo + -> OccInfoEnv -> LoopLevelInfo + -> LoopLevelInfo +combineLoopLevelInfoWith bump_loop_info u1 lli1 u2 lli2 + = assert (lli_max lli1' == lli_max lli2') $ + LLI { lli_max = lli_max lli1 `max` lli_max lli2 + , lli_non_max_lvls = plusVarEnv_C max (lli_non_max_lvls lli1') (lli_non_max_lvls lli2') + , lli_inv = IntMap.unionWith unionUniqSlimSet (lli_inv lli1') (lli_inv lli2') + } + where + lli1' = bump_loop_info (lli_max lli2) u1 lli1 + lli2' = bump_loop_info (lli_max lli1) u2 lli2 + doZapping :: UsageDetails -> Var -> OccInfo -> OccInfo doZapping ud var occ = doZappingByUnique ud (varUnique var) occ @@ -3119,14 +3246,19 @@ doZappingByUnique (UD { ud_z_many = many alterUsageDetails :: UsageDetails -> (OccInfoEnv -> OccInfoEnv) -> UsageDetails alterUsageDetails !ud f - = UD { ud_env = f (ud_env ud) + = ud { ud_env = f (ud_env ud) , ud_z_many = f (ud_z_many ud) , ud_z_in_lam = f (ud_z_in_lam ud) , ud_z_no_tail = f (ud_z_no_tail ud) } +alterLoopLevelInfo :: UsageDetails -> (LoopLevelInfo -> LoopLevelInfo) -> UsageDetails +alterLoopLevelInfo !ud f + = ud { ud_loop_info = f (ud_loop_info ud) } + flattenUsageDetails :: UsageDetails -> UsageDetails flattenUsageDetails ud@(UD { ud_env = env }) = UD { ud_env = mapUFM_Directly (doZappingByUnique ud) env + , ud_loop_info = ud_loop_info ud , ud_z_many = emptyVarEnv , ud_z_in_lam = emptyVarEnv , ud_z_no_tail = emptyVarEnv } @@ -3139,7 +3271,7 @@ adjustRhsUsage :: Maybe JoinArity -> UsageDetails adjustRhsUsage mb_join_arity rhs usage = -- c.f. occAnal (Lam {}) - markAllInsideLamIf (not one_shot) $ + markMaxLvlInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ usage where @@ -3249,7 +3381,7 @@ tagRecBinders lvl body_uds details_s | bndr <- bndrs ] -- 5. Drop the binders from the adjusted details and return - usage' = adj_uds `delDetailsList` bndrs + usage' = leaveLoop $ adj_uds `delDetailsList` bndrs in (usage', bndrs') ===================================== compiler/GHC/Types/Unique/SlimSet.hs ===================================== @@ -11,7 +11,8 @@ module GHC.Types.Unique.SlimSet ( minusUniqSlimSet, unionUniqSlimSet, unionUniqSlimSets, ufmDom, -- * Querying - isEmptyUniqSlimSet, sizeUniqSlimSet, elemUniqSlimSet + isEmptyUniqSlimSet, sizeUniqSlimSet, elemUniqSlimSet, + nonDetEltsUniqSlimSet, nonDetFoldUniqSlimSet ) where import GHC.Prelude @@ -76,6 +77,12 @@ unionUniqSlimSet (UniqSlimSet set1) (UniqSlimSet set2) = UniqSlimSet (set1 `S.un unionUniqSlimSets :: [UniqSlimSet a] -> UniqSlimSet a unionUniqSlimSets = foldl' (flip unionUniqSlimSet) emptyUniqSlimSet +nonDetEltsUniqSlimSet :: UniqSlimSet a -> [Unique] +nonDetEltsUniqSlimSet (UniqSlimSet s) = map mkUniqueGrimily (S.elems s) + +nonDetFoldUniqSlimSet :: (Unique -> acc -> acc) -> acc -> UniqSlimSet a -> acc +nonDetFoldUniqSlimSet f acc (UniqSlimSet s) = S.foldr (f . mkUniqueGrimily) acc s + instance Outputable (UniqSlimSet a) where ppr (UniqSlimSet s) = braces $ hcat $ punctuate comma [ ppr (getUnique i) | i <- S.toList s] ===================================== libraries/ghc-bignum/src/GHC/Num/WordArray.hs ===================================== @@ -51,6 +51,7 @@ withNewWordArray# sz act = case runRW# io of (# _, a #) -> a case act mwa s of { s -> unsafeFreezeByteArray# mwa s }} +{-# INLINE withNewWordArray# #-} -- | Create two new WordArray# of the given sizes (*in Word#*) and apply the -- action to them before returning them frozen @@ -86,6 +87,7 @@ withNewWordArrayTrimmed# withNewWordArrayTrimmed# sz act = withNewWordArray# sz \mwa s -> case act mwa s of s' -> mwaTrimZeroes# mwa s' +{-# INLINE withNewWordArrayTrimmed# #-} -- | Create two new WordArray# of the given sizes (*in Word#*), apply the action -- to them, trim their most significant zeroes, then return them frozen @@ -101,6 +103,7 @@ withNewWordArray2Trimmed# sz1 sz2 act = withNewWordArray2# sz1 sz2 \mwa1 mwa2 s case act mwa1 mwa2 s of s' -> case mwaTrimZeroes# mwa1 s' of s'' -> mwaTrimZeroes# mwa2 s'' +{-# INLINE withNewWordArray2Trimmed# #-} -- | Create a new WordArray# of the given size (*in Word#*), apply the action to -- it. If the action returns true#, trim its most significant zeroes, then @@ -118,6 +121,7 @@ withNewWordArrayTrimmedMaybe# sz act = case runRW# io of (# _, a #) -> a (# s, _ #) -> case mwaTrimZeroes# mwa s of s -> case unsafeFreezeByteArray# mwa s of (# s, ba #) -> (# s, (# | ba #) #) +{-# INLINE withNewWordArrayTrimmedMaybe# #-} -- | Create a WordArray# from two Word# -- @@ -296,6 +300,7 @@ mwaInitArrayBinOp mwa wa wb op s = go 0# s case indexWordArray# wa i `op` indexWordArray# wb i of v -> case mwaWrite# mwa i v s' of s'' -> go (i +# 1#) s'' +{-# INLINE mwaInitArrayBinOp #-} -- | Write an element of the MutableWordArray mwaWrite# :: MutableWordArray# s -> Int# -> Word# -> State# s -> State# s View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/89c1151745e514c3f200ce322f442f23f2c4ab62 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/89c1151745e514c3f200ce322f442f23f2c4ab62 You're receiving 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 Nov 7 13:38:16 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 07 Nov 2022 08:38:16 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <63690a482b369_11c7e2505c384877456@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: 317fc94a by Sebastian Graf at 2022-11-07T14:37:59+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1771,10 +1772,36 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers!), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +There's a bit of complication as a result of handling unboxed tuples correctly; +Specifically, handling nested unboxed tuples. Consider (#21737) + + yes_nested :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + yes_nested (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Suppose we have -fmax-worker-args=4. Then `yes_nested` will have 5 arguments +at runtime anyway because of the nested unboxed tuple which will be unarised to +4 args. So it's best to leave `(a,b)` boxed (because we already are above our +arg threshold), but unbox `c` through `f` because that doesn't increase the +number of args post unarisation. + +For that to work, our budget calculations must initialise with a budget of 5, +based on the `unariseArity` of each arg (which looks at the number of primreps). +When we encounter an unboxed tuple, we spent budget according to `unariseArity`, +which is 4 for the unboxed pair. In doing so, we have *also* spent the budget +for the nested unboxed triple as well as for the other field! Hence our algo +tracks in a flag whether we are looking at an unboxed field. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1822,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) + data Budgets = MkB Arity Budgets -- An infinite list of arity budgets -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +earnTopBudget :: Arity -> Budgets -> Budgets +earnTopBudget m (MkB n bg) = MkB (n+m) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1845,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,13 +1858,15 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity + unarise_arity = sum [ length (typePrimRep (idType b)) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity -- See Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial -- budget for the next layer down. See Note [Worker argument budget] - (remaining_budget, arg_dmds') = go_args (MkB max_wkr_args remaining_budget) arg_triples + -- False <=> Not trying to unbox a field of an unboxed tuple here + (remaining_budget, arg_dmds') = go_args False (MkB max_wkr_args remaining_budget) arg_triples arg_triples :: [(Type, StrictnessMark, Demand)] arg_triples = take arity $ @@ -1860,30 +1897,43 @@ finaliseArgBoxities env fn arity rhs div -- is_bot_fn: see Note [Boxity for bottoming functions] is_bot_fn = div == botDiv - go_args :: Budgets -> [(Type,StrictnessMark,Demand)] -> (Budgets, [Demand]) - go_args bg triples = mapAccumL go_arg bg triples + -- in_ubx_fld: see Note [Worker argument budget] + go_args :: Bool -> Budgets -> [(Type,StrictnessMark,Demand)] -> (Budgets, [Demand]) + go_args in_ubx_fld bg triples = mapAccumL (go_arg in_ubx_fld) bg triples - go_arg :: Budgets -> (Type,StrictnessMark,Demand) -> (Budgets, Demand) - go_arg bg@(MkB bg_top bg_inner) (ty, str_mark, dmd@(n :* _)) + -- in_ubx_fld: see Note [Worker argument budget] + go_arg :: Bool -> Budgets -> (Type,StrictnessMark,Demand) -> (Budgets, Demand) + go_arg in_ubx_fld bg@(MkB bg_top bg_inner) (ty, str_mark, dmd@(n :* _)) = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) + DoUnbox triples + -> (spendTopBudget cost (MkB bg_top final_bg_inner), final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + (bg_inner', dmds') = go_args (isUnboxedTupleType ty) (earnTopBudget cost bg_inner) triples + -- earnTopBudget: give back the cost of the arg we are + -- unboxing, because that is about how many registers are + -- freed by unboxing. dmd' = n :* (mkProd Unboxed $! dmds') (final_bg_inner, final_dmd) | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) where - decremented_bg = MkB (bg_top-1) bg_inner + -- in_ubx_fld: see Note [Worker argument budget] + -- True <=> we are looking at the field of an unboxed tuple + -- The cost of retaining these fields is 0, because they have already + -- been spent for when deciding to unbox the tuple in the first place. + cost | in_ubx_fld = 0 + | otherwise = unariseArity ty + retain_budget = spendTopBudget cost bg + -- spendTopBudget: spend from our budget the cost of the + -- arg we are retaining. add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,19 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True +-- | WW split not profitable +boringSplit :: Bool +boringSplit = False + +-- | WW split profitable +usefulSplit :: Bool +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -822,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -839,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -851,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -871,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -883,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -891,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -906,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts -> Var -> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -941,8 +946,8 @@ unbox_one_arg opts arg_var ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co -- See Note [Unboxing through unboxed tuples] ; return $ if isUnboxedTupleDataCon dc && not nested_useful - then (badWorker, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) - else (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1210,7 +1215,7 @@ It's entirely pointless to "unbox" the triple because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. Conclusion: Only consider unboxing an unboxed tuple useful when we will -also unbox its components. That is governed by the `goodWorker` mechanism. +also unbox its components. That is governed by the `usefulSplit` mechanism. ************************************************************************ * * @@ -1393,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1415,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1428,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1458,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1486,8 +1491,8 @@ unbox_one_result opts res_bndr -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,37 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +yes_nested :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +yes_nested (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE yes_nested #-} ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,24 @@ + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> +T21737.yes_nested: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> + + + +==================== Cpr signatures ==================== +T21737.f: 1 +T21737.no: 1 +T21737.yes: 1 +T21737.yes_nested: 1 + + + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> +T21737.yes_nested: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/317fc94a26ef189161a22343291830c130374225 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/317fc94a26ef189161a22343291830c130374225 You're receiving 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 Nov 7 14:11:38 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 07 Nov 2022 09:11:38 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Minor refactor around FastStrings Message-ID: <6369121a36df3_11c7e25069b64482417d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 1a55752b by Carter Schonwald at 2022-11-07T09:11:25-05:00 bump llvm upper bound - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/TyCo/Tidy.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/HsToCore/Coverage.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - compiler/GHC/Iface/Recomp.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Expr.hs - compiler/GHC/Runtime/Eval.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Errors/Hole.hs - compiler/GHC/Tc/Gen/Sig.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/TyCl/PatSyn.hs - compiler/GHC/Tc/Utils/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a2febd20ba4843f77b7286c981019b65a3cfe69...1a55752bcdaaa3334085126f28afc021f7da7e79 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8a2febd20ba4843f77b7286c981019b65a3cfe69...1a55752bcdaaa3334085126f28afc021f7da7e79 You're receiving 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 Nov 7 14:20:18 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 09:20:18 -0500 Subject: [Git][ghc/ghc][wip/js-staging] Try to pass dummy CROSS_EMULATOR for CI Message-ID: <63691422ed1b4_11c7e25069bc208387d4@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: f3d760a5 by Sylvain Henry at 2022-11-07T15:24:02+01:00 Try to pass dummy CROSS_EMULATOR for CI - - - - - 2 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -819,7 +819,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static) , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Just "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" Nothing (Just "emconfigure") + , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" (Just "") (Just "emconfigure") ) { bignumBackend = Native , buildFlavour = Release ===================================== .gitlab/jobs.yaml ===================================== @@ -1384,6 +1384,7 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", "XZ_OPT": "-9" @@ -3927,6 +3928,7 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3d760a5df24e0e18e6644781ff799a182a9a9ed -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f3d760a5df24e0e18e6644781ff799a182a9a9ed You're receiving 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 Nov 7 14:20:32 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 09:20:32 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Try to pass dummy CROSS_EMULATOR for CI Message-ID: <6369143066ccd_11c7e25069bc2083896f@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: d4da231c by Sylvain Henry at 2022-11-07T15:24:14+01:00 Try to pass dummy CROSS_EMULATOR for CI - - - - - 2 changed files: - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/gen_ci.hs ===================================== @@ -819,7 +819,7 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static) , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Just "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" Nothing (Just "emconfigure") + , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" (Just "") (Just "emconfigure") ) { bignumBackend = Native , buildFlavour = Release ===================================== .gitlab/jobs.yaml ===================================== @@ -1384,6 +1384,7 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", "XZ_OPT": "-9" @@ -3927,6 +3928,7 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", + "CROSS_EMULATOR": "", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d4da231c71ee0bdd4a1c84cb36c70a3fb7273db7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d4da231c71ee0bdd4a1c84cb36c70a3fb7273db7 You're receiving 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 Nov 7 16:37:11 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 07 Nov 2022 11:37:11 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <636934372f7e5_3cba4d4c57c9614e@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: 9884c306 by Sebastian Graf at 2022-11-07T17:36:48+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1762,7 +1763,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1772,69 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + yes_nested :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + yes_nested (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Suppose we have -fmax-worker-args=4. Then `yes_nested` will have 5 arguments +at runtime anyway because of the nested unboxed tuple which will be unarised to +4 args. So it's best to leave `(a,b)` boxed (because we already are above our +arg threshold), but unbox `c` through `f` because that doesn't increase the +number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +get the following layering of budgets (we write -n~> when we spend budget and ++n~> when we earn budget and start each layer with n ~> and separate unboxed +args with ][): + + 4 ~> ][ (a,b) -3~> ][ (# c, ... #) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (# d, e, f #) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +So we'd unbox `a` through `c`, but not `d` through `f` (because the budget +indicated in {{}} would become negative), which is silly. +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. Of course, for that to work, our budget calculations +must initialise 'max_wkr_args' to 5, based on the 'unariseArity' of each arg: +That would be 1 for the pair and 4 for the unboxed pair. Then when we decide +whether to unbox the unboxed pair, we *directly* recurse into the fields, +spending our budget on retaining `c` and (after recursing once more) `d` through +`f` as arguments, depleting our budget completely in the first layer. +Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) -2~> + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1855,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) + data Budgets = MkB Arity Budgets -- An infinite list of arity budgets -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Budgets -> Budgets +spendTopBudget (MkB n bg) = MkB (n-1) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1878,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1891,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1938,34 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + | otherwise + -> (spendTopBudget (MkB bg_top final_bg_inner), final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) where - decremented_bg = MkB (bg_top-1) bg_inner + retain_budget = spendTopBudget bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,19 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True +-- | WW split not profitable +boringSplit :: Bool +boringSplit = False + +-- | WW split profitable +usefulSplit :: Bool +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -822,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -839,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -851,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -871,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -883,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -891,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -906,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts -> Var -> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -941,8 +946,8 @@ unbox_one_arg opts arg_var ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co -- See Note [Unboxing through unboxed tuples] ; return $ if isUnboxedTupleDataCon dc && not nested_useful - then (badWorker, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) - else (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1210,7 +1215,7 @@ It's entirely pointless to "unbox" the triple because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. Conclusion: Only consider unboxing an unboxed tuple useful when we will -also unbox its components. That is governed by the `goodWorker` mechanism. +also unbox its components. That is governed by the `usefulSplit` mechanism. ************************************************************************ * * @@ -1393,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1415,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1428,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1458,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1486,8 +1491,8 @@ unbox_one_result opts res_bndr -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,37 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +yes_nested :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +yes_nested (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE yes_nested #-} ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,24 @@ + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> +T21737.yes_nested: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> + + + +==================== Cpr signatures ==================== +T21737.f: 1 +T21737.no: 1 +T21737.yes: 1 +T21737.yes_nested: 1 + + + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> +T21737.yes_nested: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9884c306640969d4245d1d782b039309b636e439 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9884c306640969d4245d1d782b039309b636e439 You're receiving 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 Nov 7 16:39:15 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 07 Nov 2022 11:39:15 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <636934b3636ed_3cba4d4c568981b6@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: ead65e01 by Sebastian Graf at 2022-11-07T17:39:08+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1762,7 +1763,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1772,69 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + yes_nested :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + yes_nested (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Suppose we have -fmax-worker-args=4. Then `yes_nested` will have 5 arguments +at runtime anyway because of the nested unboxed tuple which will be unarised to +4 args. So it's best to leave `(a,b)` boxed (because we already are above our +arg threshold), but unbox `c` through `f` because that doesn't increase the +number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +get the following layering of budgets (we write -n~> when we spend budget and ++n~> when we earn budget and start each layer with n ~> and separate unboxed +args with ][): + + 4 ~> ][ (a,b) -3~> ][ (# c, ... #) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (# d, e, f #) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +So we'd unbox `a` through `c`, but not `d` through `f` (because the budget +indicated in {{}} would become negative), which is silly. +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. Of course, for that to work, our budget calculations +must initialise 'max_wkr_args' to 5, based on the 'unariseArity' of each arg: +That would be 1 for the pair and 4 for the unboxed pair. Then when we decide +whether to unbox the unboxed pair, we *directly* recurse into the fields, +spending our budget on retaining `c` and (after recursing once more) `d` through +`f` as arguments, depleting our budget completely in the first layer. +Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1855,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) + data Budgets = MkB Arity Budgets -- An infinite list of arity budgets -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Budgets -> Budgets +spendTopBudget (MkB n bg) = MkB (n-1) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1878,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1891,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1938,34 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + | otherwise + -> (spendTopBudget (MkB bg_top final_bg_inner), final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) where - decremented_bg = MkB (bg_top-1) bg_inner + retain_budget = spendTopBudget bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,19 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True +-- | WW split not profitable +boringSplit :: Bool +boringSplit = False + +-- | WW split profitable +usefulSplit :: Bool +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -822,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -839,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -851,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -871,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -883,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -891,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -906,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts -> Var -> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -941,8 +946,8 @@ unbox_one_arg opts arg_var ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co -- See Note [Unboxing through unboxed tuples] ; return $ if isUnboxedTupleDataCon dc && not nested_useful - then (badWorker, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) - else (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1210,7 +1215,7 @@ It's entirely pointless to "unbox" the triple because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. Conclusion: Only consider unboxing an unboxed tuple useful when we will -also unbox its components. That is governed by the `goodWorker` mechanism. +also unbox its components. That is governed by the `usefulSplit` mechanism. ************************************************************************ * * @@ -1393,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1415,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1428,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1458,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1486,8 +1491,8 @@ unbox_one_result opts res_bndr -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,37 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +yes_nested :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +yes_nested (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE yes_nested #-} ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,24 @@ + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> +T21737.yes_nested: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> + + + +==================== Cpr signatures ==================== +T21737.f: 1 +T21737.no: 1 +T21737.yes: 1 +T21737.yes_nested: 1 + + + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> +T21737.yes_nested: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ead65e01958bdcf1be2c6d1f82e170cf06460747 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ead65e01958bdcf1be2c6d1f82e170cf06460747 You're receiving 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 Nov 7 16:39:33 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 07 Nov 2022 11:39:33 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <636934c5ebca0_3cba4d4c52c98435@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: 0592e4ef by Sebastian Graf at 2022-11-07T17:39:26+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1762,7 +1763,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1772,69 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + yes_nested :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + yes_nested (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Suppose we have -fmax-worker-args=4. Then `yes_nested` will have 5 arguments +at runtime anyway because of the nested unboxed tuple which will be unarised to +4 args. So it's best to leave `(a,b)` boxed (because we already are above our +arg threshold), but unbox `c` through `f` because that doesn't increase the +number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +get the following layering of budgets (we write -n~> when we spend budget and ++n~> when we earn budget and start each layer with n ~> and separate unboxed +args with ][): + + 4 ~> ][ (a,b) -3~> ][ (# c, ... #) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (# d, e, f #) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +So we'd unbox `a` through `c`, but not `d` through `f` (because the budget +indicated in {{}} would become negative), which is silly. +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. Of course, for that to work, our budget calculations +must initialise 'max_wkr_args' to 5, based on the 'unariseArity' of each arg: +That would be 1 for the pair and 4 for the unboxed pair. Then when we decide +whether to unbox the unboxed pair, we *directly* recurse into the fields, +spending our budget on retaining `c` and (after recursing once more) `d` through +`f` as arguments, depleting our budget completely in the first layer. +Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1855,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) + data Budgets = MkB Arity Budgets -- An infinite list of arity budgets -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Budgets -> Budgets +spendTopBudget (MkB n bg) = MkB (n-1) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1878,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1891,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1938,34 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + | otherwise + -> (spendTopBudget (MkB bg_top final_bg_inner), final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) where - decremented_bg = MkB (bg_top-1) bg_inner + retain_budget = spendTopBudget bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,19 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True +-- | WW split not profitable +boringSplit :: Bool +boringSplit = False + +-- | WW split profitable +usefulSplit :: Bool +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -822,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -839,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -851,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -871,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -883,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -891,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -906,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts -> Var -> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -941,8 +946,8 @@ unbox_one_arg opts arg_var ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co -- See Note [Unboxing through unboxed tuples] ; return $ if isUnboxedTupleDataCon dc && not nested_useful - then (badWorker, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) - else (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1210,7 +1215,7 @@ It's entirely pointless to "unbox" the triple because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. Conclusion: Only consider unboxing an unboxed tuple useful when we will -also unbox its components. That is governed by the `goodWorker` mechanism. +also unbox its components. That is governed by the `usefulSplit` mechanism. ************************************************************************ * * @@ -1393,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1415,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1428,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1458,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1486,8 +1491,8 @@ unbox_one_result opts res_bndr -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,37 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +yes_nested :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +yes_nested (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE yes_nested #-} ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,24 @@ + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> +T21737.yes_nested: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> + + + +==================== Cpr signatures ==================== +T21737.f: 1 +T21737.no: 1 +T21737.yes: 1 +T21737.yes_nested: 1 + + + +==================== Strictness signatures ==================== +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> +T21737.yes_nested: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0592e4ef6b742d4b37c5269e505c3b90e9296a2d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0592e4ef6b742d4b37c5269e505c3b90e9296a2d You're receiving 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 Nov 7 17:22:18 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 12:22:18 -0500 Subject: [Git][ghc/ghc][wip/js-staging] Try to fix CI, take N Message-ID: <63693ecaa4b19_3cba4d4c540100677@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 484fe97f by Sylvain Henry at 2022-11-07T18:25:49+01:00 Try to fix CI, take N - - - - - 3 changed files: - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/ci.sh ===================================== @@ -594,20 +594,18 @@ function test_hadrian() { fi - if [ -n "${CROSS_TARGET:-}" ]; then - if [ -n "${CROSS_EMULATOR:-}" ]; then - local instdir="$TOP/_build/install" - local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" - install_bindist _build/bindist/ghc-*/ "$instdir" - echo 'main = putStrLn "hello world"' > hello.hs - echo "hello world" > expected - run "$test_compiler" hello.hs - $CROSS_EMULATOR ./hello > actual - run diff expected actual - else - info "Cannot test cross-compiled build without CROSS_EMULATOR being set." - return - fi + if [[ "${CROSS_EMULATOR:-}" == "NOT_SET" ]]; then + info "Cannot test cross-compiled build without CROSS_EMULATOR being set." + return + elif[[ "${CROSS_EMULATOR:-}" != "NOT_NEEDED" ]]; then + local instdir="$TOP/_build/install" + local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" + install_bindist _build/bindist/ghc-*/ "$instdir" + echo 'main = putStrLn "hello world"' > hello.hs + echo "hello world" > expected + run "$test_compiler" hello.hs + $CROSS_EMULATOR ./hello > actual + run diff expected actual elif [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian \ test \ ===================================== .gitlab/gen_ci.hs ===================================== @@ -109,6 +109,11 @@ bignumString :: BignumBackend -> String bignumString Gmp = "gmp" bignumString Native = "native" +data CrossEmulator + = NoEmulator + | NoEmulatorNeeded + | Emulator String + -- | A BuildConfig records all the options which can be modified to affect the -- bindists produced by the compiler. data BuildConfig @@ -120,7 +125,7 @@ data BuildConfig , withAssertions :: Bool , withNuma :: Bool , crossTarget :: Maybe String - , crossEmulator :: Maybe String + , crossEmulator :: CrossEmulator , configureWrapper :: Maybe String , fullyStatic :: Bool , tablesNextToCode :: Bool @@ -164,7 +169,7 @@ vanilla = BuildConfig , withAssertions = False , withNuma = False , crossTarget = Nothing - , crossEmulator = Nothing + , crossEmulator = NoEmulator , configureWrapper = Nothing , fullyStatic = False , tablesNextToCode = True @@ -197,7 +202,7 @@ staticNativeInt :: BuildConfig staticNativeInt = static { bignumBackend = Native } crossConfig :: String -- ^ target triple - -> Maybe String -- ^ emulator for testing + -> CrossEmulator -- ^ emulator for testing -> Maybe String -- ^ Configure wrapper -> BuildConfig crossConfig triple emulator configure_wrapper = @@ -642,7 +647,12 @@ job arch opsys buildConfig = (jobName, Job {..}) , "CONFIGURE_ARGS" =: configureArgsStr buildConfig , maybe mempty ("CONFIGURE_WRAPPER" =:) (configureWrapper buildConfig) , maybe mempty ("CROSS_TARGET" =:) (crossTarget buildConfig) - , maybe mempty ("CROSS_EMULATOR" =:) (crossEmulator buildConfig) + , case crossEmulator buildConfig of + NoEmulator -> case crossTarget buildConfig of + Nothing -> mempty + Just _ -> "CROSS_EMULATOR" =: "NOT_SET" -- we need an emulator but it isn't set. Won't run the testsuite + Emulator s -> "CROSS_EMULATOR" =: s + NoEmulatorNeeded -> "CROSS_EMULATOR" =: "NOT_NEEDED" , if withNuma buildConfig then "ENABLE_NUMA" =: "1" else mempty ] @@ -818,8 +828,8 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds I386 (Linux Debian9) , allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static) , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Just "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" (Just "") (Just "emconfigure") + , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) + , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ) { bignumBackend = Native , buildFlavour = Release ===================================== .gitlab/jobs.yaml ===================================== @@ -1384,7 +1384,7 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "", + "CROSS_EMULATOR": "NOT_NEEDED", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", "XZ_OPT": "-9" @@ -3928,7 +3928,7 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "", + "CROSS_EMULATOR": "NOT_NEEDED", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/484fe97fb6ebaa73c7f7ab2f3934dc94ab0bfa8b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/484fe97fb6ebaa73c7f7ab2f3934dc94ab0bfa8b You're receiving 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 Nov 7 17:22:31 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 12:22:31 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Try to fix CI, take N Message-ID: <63693ed72fcd3_3cba4d4c4f01008e7@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: e5ab5dc2 by Sylvain Henry at 2022-11-07T18:26:13+01:00 Try to fix CI, take N - - - - - 3 changed files: - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/ci.sh ===================================== @@ -594,20 +594,18 @@ function test_hadrian() { fi - if [ -n "${CROSS_TARGET:-}" ]; then - if [ -n "${CROSS_EMULATOR:-}" ]; then - local instdir="$TOP/_build/install" - local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" - install_bindist _build/bindist/ghc-*/ "$instdir" - echo 'main = putStrLn "hello world"' > hello.hs - echo "hello world" > expected - run "$test_compiler" hello.hs - $CROSS_EMULATOR ./hello > actual - run diff expected actual - else - info "Cannot test cross-compiled build without CROSS_EMULATOR being set." - return - fi + if [[ "${CROSS_EMULATOR:-}" == "NOT_SET" ]]; then + info "Cannot test cross-compiled build without CROSS_EMULATOR being set." + return + elif[[ "${CROSS_EMULATOR:-}" != "NOT_NEEDED" ]]; then + local instdir="$TOP/_build/install" + local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" + install_bindist _build/bindist/ghc-*/ "$instdir" + echo 'main = putStrLn "hello world"' > hello.hs + echo "hello world" > expected + run "$test_compiler" hello.hs + $CROSS_EMULATOR ./hello > actual + run diff expected actual elif [[ -n "${REINSTALL_GHC:-}" ]]; then run_hadrian \ test \ ===================================== .gitlab/gen_ci.hs ===================================== @@ -109,6 +109,11 @@ bignumString :: BignumBackend -> String bignumString Gmp = "gmp" bignumString Native = "native" +data CrossEmulator + = NoEmulator + | NoEmulatorNeeded + | Emulator String + -- | A BuildConfig records all the options which can be modified to affect the -- bindists produced by the compiler. data BuildConfig @@ -120,7 +125,7 @@ data BuildConfig , withAssertions :: Bool , withNuma :: Bool , crossTarget :: Maybe String - , crossEmulator :: Maybe String + , crossEmulator :: CrossEmulator , configureWrapper :: Maybe String , fullyStatic :: Bool , tablesNextToCode :: Bool @@ -164,7 +169,7 @@ vanilla = BuildConfig , withAssertions = False , withNuma = False , crossTarget = Nothing - , crossEmulator = Nothing + , crossEmulator = NoEmulator , configureWrapper = Nothing , fullyStatic = False , tablesNextToCode = True @@ -197,7 +202,7 @@ staticNativeInt :: BuildConfig staticNativeInt = static { bignumBackend = Native } crossConfig :: String -- ^ target triple - -> Maybe String -- ^ emulator for testing + -> CrossEmulator -- ^ emulator for testing -> Maybe String -- ^ Configure wrapper -> BuildConfig crossConfig triple emulator configure_wrapper = @@ -642,7 +647,12 @@ job arch opsys buildConfig = (jobName, Job {..}) , "CONFIGURE_ARGS" =: configureArgsStr buildConfig , maybe mempty ("CONFIGURE_WRAPPER" =:) (configureWrapper buildConfig) , maybe mempty ("CROSS_TARGET" =:) (crossTarget buildConfig) - , maybe mempty ("CROSS_EMULATOR" =:) (crossEmulator buildConfig) + , case crossEmulator buildConfig of + NoEmulator -> case crossTarget buildConfig of + Nothing -> mempty + Just _ -> "CROSS_EMULATOR" =: "NOT_SET" -- we need an emulator but it isn't set. Won't run the testsuite + Emulator s -> "CROSS_EMULATOR" =: s + NoEmulatorNeeded -> "CROSS_EMULATOR" =: "NOT_NEEDED" , if withNuma buildConfig then "ENABLE_NUMA" =: "1" else mempty ] @@ -818,8 +828,8 @@ jobs = Map.fromList $ concatMap flattenJobGroup $ , standardBuilds I386 (Linux Debian9) , allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) static) , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt)) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Just "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) - , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" (Just "") (Just "emconfigure") + , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing) + , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure") ) { bignumBackend = Native , buildFlavour = Release ===================================== .gitlab/jobs.yaml ===================================== @@ -1384,7 +1384,7 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "", + "CROSS_EMULATOR": "NOT_NEEDED", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", "XZ_OPT": "-9" @@ -3928,7 +3928,7 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "", + "CROSS_EMULATOR": "NOT_NEEDED", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5ab5dc2c379ff0c8cefb2c0b34409c5a46e1848 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5ab5dc2c379ff0c8cefb2c0b34409c5a46e1848 You're receiving 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 Nov 7 17:34:08 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 12:34:08 -0500 Subject: [Git][ghc/ghc][wip/js-staging] Take N+1 Message-ID: <63694190de24d_3cba4d4c5681023a0@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 67f6ca0c by Sylvain Henry at 2022-11-07T18:37:48+01:00 Take N+1 - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -597,7 +597,7 @@ function test_hadrian() { if [[ "${CROSS_EMULATOR:-}" == "NOT_SET" ]]; then info "Cannot test cross-compiled build without CROSS_EMULATOR being set." return - elif[[ "${CROSS_EMULATOR:-}" != "NOT_NEEDED" ]]; then + elif [[ "${CROSS_EMULATOR:-}" != "NOT_NEEDED" ]]; then local instdir="$TOP/_build/install" local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" install_bindist _build/bindist/ghc-*/ "$instdir" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/67f6ca0cb2067e70c2535f20b37ab59f6c444d1c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/67f6ca0cb2067e70c2535f20b37ab59f6c444d1c You're receiving 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 Nov 7 17:34:18 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 07 Nov 2022 12:34:18 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Take N+1 Message-ID: <6369419ad50be_3cba4d4c4f010251e@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: ff82e2a8 by Sylvain Henry at 2022-11-07T18:38:03+01:00 Take N+1 - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -597,7 +597,7 @@ function test_hadrian() { if [[ "${CROSS_EMULATOR:-}" == "NOT_SET" ]]; then info "Cannot test cross-compiled build without CROSS_EMULATOR being set." return - elif[[ "${CROSS_EMULATOR:-}" != "NOT_NEEDED" ]]; then + elif [[ "${CROSS_EMULATOR:-}" != "NOT_NEEDED" ]]; then local instdir="$TOP/_build/install" local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" install_bindist _build/bindist/ghc-*/ "$instdir" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff82e2a8b772e0cb7eda3131f1a503904ea9014e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ff82e2a8b772e0cb7eda3131f1a503904ea9014e You're receiving 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 Nov 7 18:22:03 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 07 Nov 2022 13:22:03 -0500 Subject: [Git][ghc/ghc][master] 5 commits: Bump unix submodule to 2.8.0.0 Message-ID: <63694ccbe6aa2_3cba4d4c50411348b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 11 changed files: - .gitlab-ci.yml - compiler/ghc.cabal.in - ghc/ghc-bin.cabal.in - hadrian/src/Flavour.hs - libraries/Win32 - libraries/base/tests/T7773.hs - libraries/ghc-bignum/gmp/gmp-tarballs - libraries/ghc-boot/ghc-boot.cabal.in - libraries/haskeline - libraries/process - libraries/unix 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: 9e4c540d9e4972a36291dfdf81f079f37d748890 + DOCKER_REV: 205afce5c7ebdb8666b96638f6758fe527f40a7f # Sequential version number of all cached things. # Bump to invalidate GitLab CI cache. ===================================== compiler/ghc.cabal.in ===================================== @@ -96,7 +96,7 @@ Library ghci == @ProjectVersionMunged@ if os(windows) - Build-Depends: Win32 >= 2.3 && < 2.13 + Build-Depends: Win32 >= 2.3 && < 2.14 else if flag(terminfo) Build-Depends: terminfo == 0.4.* ===================================== ghc/ghc-bin.cabal.in ===================================== @@ -43,7 +43,7 @@ Executable ghc ghc == @ProjectVersionMunged@ if os(windows) - Build-Depends: Win32 >= 2.3 && < 2.13 + Build-Depends: Win32 >= 2.3 && < 2.14 else Build-Depends: unix >= 2.7 && < 2.9 ===================================== hadrian/src/Flavour.hs ===================================== @@ -33,6 +33,7 @@ import Text.Parsec.Combinator as P import Text.Parsec.Char as P import Control.Monad.Except import UserSettings +import Oracles.Flag import Oracles.Setting @@ -106,8 +107,13 @@ addArgs args' fl = fl { args = args fl <> args' } -- | Turn on -Werror for packages built with the stage1 compiler. -- It mimics the CI settings so is useful to turn on when developing. + +-- TODO: the -Wwarn flags are added to make validation flavour works +-- for cross-compiling unix-2.8.0.0. There needs to be further fixes +-- in unix and/or hsc2hs to make cross-compiling unix completely free +-- from warnings. werror :: Flavour -> Flavour -werror = addArgs (builder Ghc ? notStage0 ? arg "-Werror") +werror = addArgs (builder Ghc ? notStage0 ? mconcat [arg "-Werror", flag CrossCompiling ? mconcat [arg "-Wwarn=unused-imports", arg "-Wwarn=unused-top-binds"]]) -- | Build C and Haskell objects with debugging information. enableDebugInfo :: Flavour -> Flavour ===================================== libraries/Win32 ===================================== @@ -1 +1 @@ -Subproject commit e6c0c0f44f6dfc2f8255fc4a5017f4ab67cd0242 +Subproject commit 931497f7052f63cb5cfd4494a94e572c5c570642 ===================================== libraries/base/tests/T7773.hs ===================================== @@ -3,7 +3,6 @@ import System.Posix.IO main = do putStrLn "hello" - fd <- openFd "/dev/random" ReadOnly Nothing defaultFileFlags + fd <- openFd "/dev/random" ReadOnly defaultFileFlags threadWaitRead fd putStrLn "goodbye" - ===================================== libraries/ghc-bignum/gmp/gmp-tarballs ===================================== @@ -1 +1 @@ -Subproject commit 31f9909680ba8fe00d27fd8a6f5d198a0a96c1ac +Subproject commit 6bbea995472b6f4db172c3cd50aa3f515ddd221c ===================================== libraries/ghc-boot/ghc-boot.cabal.in ===================================== @@ -80,4 +80,4 @@ Library ghc-boot-th == @ProjectVersionMunged@ if !os(windows) build-depends: - unix >= 2.7 && < 2.8 + unix >= 2.7 && < 2.9 ===================================== libraries/haskeline ===================================== @@ -1 +1 @@ -Subproject commit aae0bfeec7ae767e3c30844ca2f99b6825185467 +Subproject commit d4f343509e905a717ea463ad84462c126d8990d8 ===================================== libraries/process ===================================== @@ -1 +1 @@ -Subproject commit 2ac3ff366631a36d84101000045abbefa4415b15 +Subproject commit cb89d5079d29c38683bcb6feec7dc53ad3836ed0 ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 2a6079a2b76adf29d3e3ff213dffe66cabcb76c3 +Subproject commit 3be0223cee7395410915a127eba3acae5ff0b2f2 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c0e379322965aa87b14923f6d8e1ef5cd677925...69427ce964758b325abd881b4b3db8d59fecc878 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3c0e379322965aa87b14923f6d8e1ef5cd677925...69427ce964758b325abd881b4b3db8d59fecc878 You're receiving 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 Nov 7 18:22:30 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 07 Nov 2022 13:22:30 -0500 Subject: [Git][ghc/ghc][master] bump llvm upper bound Message-ID: <63694ce624f90_3cba4d51ab81170c2@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 1 changed file: - configure.ac Changes: ===================================== configure.ac ===================================== @@ -555,7 +555,7 @@ AC_SUBST(InstallNameToolCmd) # versions of LLVM simultaneously, but that stopped working around # 3.5/3.6 release of LLVM. LlvmMinVersion=10 # inclusive -LlvmMaxVersion=14 # not inclusive +LlvmMaxVersion=15 # not inclusive AC_SUBST([LlvmMinVersion]) AC_SUBST([LlvmMaxVersion]) sUPPORTED_LLVM_VERSION_MIN=$(echo \($LlvmMinVersion\) | sed 's/\./,/') View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5fe11fe612e1881bd4d1b9d5950d0d801e08e159 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5fe11fe612e1881bd4d1b9d5950d0d801e08e159 You're receiving 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 Nov 7 21:08:46 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 07 Nov 2022 16:08:46 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: bump llvm upper bound Message-ID: <636973deb60a6_10da05526c0382dd@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - f5f9fbb5 by M Farkas-Dyck at 2022-11-07T16:08:25-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - 5ad4cead by Jade Lovelace at 2022-11-07T16:08:29-05:00 Clarify msum/asum documentation - - - - - 95d4df24 by Jade Lovelace at 2022-11-07T16:08:29-05:00 Add example for (<$) - - - - - e730c3c5 by Jade Lovelace at 2022-11-07T16:08:29-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 25 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Reduction.hs - compiler/GHC/Core/Unify.hs - + compiler/GHC/Data/List/Infinite.hs - compiler/GHC/HsToCore/Pmc/Ppr.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Rewrite.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - configure.ac - libraries/base/Data/Foldable.hs - libraries/base/GHC/Base.hs - libraries/base/GHC/Conc/Sync.hs - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout - + testsuite/tests/perf/compiler/InfiniteListFusion.hs - + testsuite/tests/perf/compiler/InfiniteListFusion.stdout - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -119,7 +119,6 @@ in GHC.Builtin.Types. -} {-# LANGUAGE CPP #-} -{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} module GHC.Builtin.Names ( Unique, Uniquable(..), hasKey, -- Re-exported for convenience @@ -143,6 +142,8 @@ import GHC.Builtin.Uniques import GHC.Types.Name import GHC.Types.SrcLoc import GHC.Data.FastString +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import Language.Haskell.Syntax.Module.Name @@ -154,9 +155,13 @@ import Language.Haskell.Syntax.Module.Name ************************************************************************ -} -allNameStrings :: [String] +allNameStrings :: Infinite String -- Infinite list of a,b,c...z, aa, ab, ac, ... etc -allNameStrings = [ c:cs | cs <- "" : allNameStrings, c <- ['a'..'z'] ] +allNameStrings = Inf.allListsOf ['a'..'z'] + +allNameStringList :: [String] +-- Infinite list of a,b,c...z, aa, ab, ac, ... etc +allNameStringList = Inf.toList allNameStrings {- ************************************************************************ ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -63,6 +63,7 @@ module GHC.Core.Coercion ( splitForAllCo_ty_maybe, splitForAllCo_co_maybe, nthRole, tyConRolesX, tyConRolesRepresentational, setNominalRole_maybe, + tyConRoleListX, tyConRoleListRepresentational, pickLR, @@ -154,6 +155,8 @@ import GHC.Builtin.Types.Prim import GHC.Data.List.SetOps import GHC.Data.Maybe import GHC.Types.Unique.FM +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import GHC.Utils.Misc import GHC.Utils.Outputable @@ -408,12 +411,10 @@ where co_rep1, co_rep2 are the coercions on the representations. -- -- > decomposeCo 3 c [r1, r2, r3] = [nth r1 0 c, nth r2 1 c, nth r3 2 c] decomposeCo :: Arity -> Coercion - -> [Role] -- the roles of the output coercions - -- this must have at least as many - -- entries as the Arity provided + -> Infinite Role -- the roles of the output coercions -> [Coercion] decomposeCo arity co rs - = [mkNthCo r n co | (n,r) <- [0..(arity-1)] `zip` rs ] + = [mkNthCo r n co | (n,r) <- [0..(arity-1)] `zip` Inf.toList rs ] -- Remember, Nth is zero-indexed decomposeFunCo :: HasDebugCallStack @@ -533,7 +534,7 @@ splitTyConAppCo_maybe :: Coercion -> Maybe (TyCon, [Coercion]) splitTyConAppCo_maybe co | Just (ty, r) <- isReflCo_maybe co = do { (tc, tys) <- splitTyConApp_maybe ty - ; let args = zipWith mkReflCo (tyConRolesX r tc) tys + ; let args = zipWith mkReflCo (tyConRoleListX r tc) tys ; return (tc, args) } splitTyConAppCo_maybe (TyConAppCo _ tc cos) = Just (tc, cos) splitTyConAppCo_maybe (FunCo _ w arg res) = Just (funTyCon, cos) @@ -819,15 +820,14 @@ mkAppCo co arg -- Expand type synonyms; a TyConAppCo can't have a type synonym (#9102) = mkTyConAppCo r tc (zip_roles (tyConRolesX r tc) tys) where - zip_roles (r1:_) [] = [downgradeRole r1 Nominal arg] - zip_roles (r1:rs) (ty1:tys) = mkReflCo r1 ty1 : zip_roles rs tys - zip_roles _ _ = panic "zip_roles" -- but the roles are infinite... + zip_roles (Inf r1 _) [] = [downgradeRole r1 Nominal arg] + zip_roles (Inf r1 rs) (ty1:tys) = mkReflCo r1 ty1 : zip_roles rs tys mkAppCo (TyConAppCo r tc args) arg = case r of Nominal -> mkTyConAppCo Nominal tc (args ++ [arg]) Representational -> mkTyConAppCo Representational tc (args ++ [arg']) - where new_role = (tyConRolesRepresentational tc) !! (length args) + where new_role = tyConRolesRepresentational tc Inf.!! length args arg' = downgradeRole new_role Nominal arg Phantom -> mkTyConAppCo Phantom tc (args ++ [toPhantomCo arg]) mkAppCo co arg = AppCo co arg @@ -1153,10 +1153,7 @@ mkNthCo r n co , tc1 == tc2 = let len1 = length tys1 len2 = length tys2 - good_role = case coercionRole co of - Nominal -> r == Nominal - Representational -> r == (tyConRolesRepresentational tc1 !! n) - Phantom -> r == Phantom + good_role = r == nthRole (coercionRole co) tc1 n in len1 == len2 && n < len1 && good_role | otherwise @@ -1349,7 +1346,7 @@ setNominalRole_maybe r co setNominalRole_maybe_helper co@(Refl _) = Just co setNominalRole_maybe_helper (GRefl _ ty co) = Just $ GRefl Nominal ty co setNominalRole_maybe_helper (TyConAppCo Representational tc cos) - = do { cos' <- zipWithM setNominalRole_maybe (tyConRolesX Representational tc) cos + = do { cos' <- zipWithM setNominalRole_maybe (tyConRoleListX Representational tc) cos ; return $ TyConAppCo Nominal tc cos' } setNominalRole_maybe_helper (FunCo Representational w co1 co2) = do { co1' <- setNominalRole_maybe Representational co1 @@ -1393,27 +1390,33 @@ toPhantomCo co -- Convert args to a TyConAppCo Nominal to the same TyConAppCo Representational applyRoles :: TyCon -> [Coercion] -> [Coercion] -applyRoles tc cos - = zipWith (\r -> downgradeRole r Nominal) (tyConRolesRepresentational tc) cos +applyRoles = zipWith (`downgradeRole` Nominal) . tyConRoleListRepresentational -- the Role parameter is the Role of the TyConAppCo -- defined here because this is intimately concerned with the implementation -- of TyConAppCo -- Always returns an infinite list (with a infinite tail of Nominal) -tyConRolesX :: Role -> TyCon -> [Role] +tyConRolesX :: Role -> TyCon -> Infinite Role tyConRolesX Representational tc = tyConRolesRepresentational tc -tyConRolesX role _ = repeat role +tyConRolesX role _ = Inf.repeat role + +tyConRoleListX :: Role -> TyCon -> [Role] +tyConRoleListX role = Inf.toList . tyConRolesX role + +-- Returns the roles of the parameters of a tycon, with an infinite tail +-- of Nominal +tyConRolesRepresentational :: TyCon -> Infinite Role +tyConRolesRepresentational tc = tyConRoles tc Inf.++ Inf.repeat Nominal -- Returns the roles of the parameters of a tycon, with an infinite tail -- of Nominal -tyConRolesRepresentational :: TyCon -> [Role] -tyConRolesRepresentational tc = tyConRoles tc ++ repeat Nominal +tyConRoleListRepresentational :: TyCon -> [Role] +tyConRoleListRepresentational = Inf.toList . tyConRolesRepresentational nthRole :: Role -> TyCon -> Int -> Role nthRole Nominal _ _ = Nominal nthRole Phantom _ _ = Phantom -nthRole Representational tc n - = (tyConRolesRepresentational tc) `getNth` n +nthRole Representational tc n = tyConRolesRepresentational tc Inf.!! n ltRole :: Role -> Role -> Bool -- Is one role "less" than another? @@ -2034,7 +2037,7 @@ ty_co_subst !lc role ty go r (TyVarTy tv) = expectJust "ty_co_subst bad roles" $ liftCoSubstTyVar lc r tv go r (AppTy ty1 ty2) = mkAppCo (go r ty1) (go Nominal ty2) - go r (TyConApp tc tys) = mkTyConAppCo r tc (zipWith go (tyConRolesX r tc) tys) + go r (TyConApp tc tys) = mkTyConAppCo r tc (zipWith go (tyConRoleListX r tc) tys) go r (FunTy _ w ty1 ty2) = mkFunCo r (go Nominal w) (go r ty1) (go r ty2) go r t@(ForAllTy (Bndr v _) ty) = let (lc', v', h) = liftCoSubstVarBndr lc v ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -245,7 +245,7 @@ opt_co4 env sym rep r g@(TyConAppCo _r tc cos) (True, Nominal) -> mkTyConAppCo Representational tc (zipWith3 (opt_co3 env sym) - (map Just (tyConRolesRepresentational tc)) + (map Just (tyConRoleListRepresentational tc)) (repeat Nominal) cos) (False, Nominal) -> @@ -254,7 +254,7 @@ opt_co4 env sym rep r g@(TyConAppCo _r tc cos) -- must use opt_co2 here, because some roles may be P -- See Note [Optimising coercion optimisation] mkTyConAppCo r tc (zipWith (opt_co2 env sym) - (tyConRolesRepresentational tc) -- the current roles + (tyConRoleListRepresentational tc) -- the current roles cos) (_, Phantom) -> pprPanic "opt_co4 sees a phantom!" (ppr g) @@ -546,7 +546,7 @@ opt_univ env sym prov role oty1 oty2 , equalLength tys1 tys2 -- see Note [Differing kinds] -- NB: prov must not be the two interesting ones (ProofIrrel & Phantom); -- Phantom is already taken care of, and ProofIrrel doesn't relate tyconapps - = let roles = tyConRolesX role tc1 + = let roles = tyConRoleListX role tc1 arg_cos = zipWith3 (mkUnivCo prov') roles tys1 tys2 arg_cos' = zipWith (opt_co4 env sym False) roles arg_cos in ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -63,6 +63,8 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Data.Bag +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf {- ************************************************************************ @@ -1477,7 +1479,7 @@ normalise_type ty Nothing -> do { ArgsReductions redns res_co <- normalise_args (typeKind nfun) - (repeat Nominal) + (Inf.repeat Nominal) arg_tys ; role <- getRole ; return $ @@ -1486,7 +1488,7 @@ normalise_type ty (mkSymMCo res_co) } } normalise_args :: Kind -- of the function - -> [Role] -- roles at which to normalise args + -> Infinite Role -- roles at which to normalise args -> [Type] -- args -> NormM ArgsReductions -- returns ArgsReductions (Reductions cos xis) res_co, @@ -1496,7 +1498,7 @@ normalise_args :: Kind -- of the function -- but the resulting application *will* be well-kinded -- cf. GHC.Tc.Solver.Rewrite.rewrite_args_slow normalise_args fun_ki roles args - = do { normed_args <- zipWithM normalise1 roles args + = do { normed_args <- zipWithM normalise1 (Inf.toList roles) args ; return $ simplifyArgsWorker ki_binders inner_ki fvs roles normed_args } where (ki_binders, inner_ki) = splitPiTys fun_ki ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -2177,7 +2177,7 @@ lintCoercion co@(TyConAppCo r tc cos) ; let (co_kinds, co_roles) = unzip (map coercionKindRole cos') ; lint_co_app co (tyConKind tc) (map pFst co_kinds) ; lint_co_app co (tyConKind tc) (map pSnd co_kinds) - ; zipWithM_ (lintRole co) (tyConRolesX r tc) co_roles + ; zipWithM_ (lintRole co) (tyConRoleListX r tc) co_roles ; return (TyConAppCo r tc cos') } lintCoercion co@(AppCo co1 co2) ===================================== compiler/GHC/Core/Reduction.hs ===================================== @@ -35,6 +35,8 @@ import GHC.Core.TyCon ( TyCon ) import GHC.Core.Type import GHC.Data.Pair ( Pair(Pair) ) +import GHC.Data.List.Infinite ( Infinite (..) ) +import qualified GHC.Data.List.Infinite as Inf import GHC.Types.Var ( setTyVarKind ) import GHC.Types.Var.Env ( mkInScopeSet ) @@ -42,7 +44,7 @@ import GHC.Types.Var.Set ( TyCoVarSet ) import GHC.Utils.Misc ( HasDebugCallStack, equalLength ) import GHC.Utils.Outputable -import GHC.Utils.Panic ( assertPpr, panic ) +import GHC.Utils.Panic ( assertPpr ) {- %************************************************************************ @@ -788,7 +790,7 @@ simplifyArgsWorker :: HasDebugCallStack -- the binders & result kind (not a Π-type) of the function applied to the args -- list of binders can be shorter or longer than the list of args -> TyCoVarSet -- free vars of the args - -> [Role] -- list of roles, r + -> Infinite Role-- list of roles, r -> [Reduction] -- rewritten type arguments, arg_i -- each comes with the coercion used to rewrite it, -- arg_co_i :: ty_i ~ arg_i @@ -809,11 +811,11 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs where orig_lc = emptyLiftingContext $ mkInScopeSet orig_fvs - go :: LiftingContext -- mapping from tyvars to rewriting coercions - -> [TyCoBinder] -- Unsubsted binders of function's kind - -> Kind -- Unsubsted result kind of function (not a Pi-type) - -> [Role] -- Roles at which to rewrite these ... - -> [Reduction] -- rewritten arguments, with their rewriting coercions + go :: LiftingContext -- mapping from tyvars to rewriting coercions + -> [TyCoBinder] -- Unsubsted binders of function's kind + -> Kind -- Unsubsted result kind of function (not a Pi-type) + -> Infinite Role -- Roles at which to rewrite these ... + -> [Reduction] -- rewritten arguments, with their rewriting coercions -> ArgsReductions go !lc binders inner_ki _ [] -- The !lc makes the function strict in the lifting context @@ -826,7 +828,7 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs kind_co | noFreeVarsOfType final_kind = MRefl | otherwise = MCo $ liftCoSubst Nominal lc final_kind - go lc (binder:binders) inner_ki (role:roles) (arg_redn:arg_redns) + go lc (binder:binders) inner_ki (Inf role roles) (arg_redn:arg_redns) = -- We rewrite an argument ty with arg_redn = Reduction arg_co arg -- By Note [Rewriting] in GHC.Tc.Solver.Rewrite invariant (F2), -- tcTypeKind(ty) = tcTypeKind(arg). @@ -859,7 +861,7 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs (arg_cos, res_co) = decomposePiCos co1 co1_kind unrewritten_tys casted_args = assertPpr (equalLength arg_redns arg_cos) (ppr arg_redns $$ ppr arg_cos) - $ zipWith3 mkCoherenceRightRedn roles arg_redns arg_cos + $ zipWith3 mkCoherenceRightRedn (Inf.toList roles) arg_redns arg_cos -- In general decomposePiCos can return fewer cos than tys, -- but not here; because we're well typed, there will be enough -- binders. Note that decomposePiCos does substitutions, so even @@ -874,19 +876,3 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs = go zapped_lc bndrs new_inner roles casted_args in ArgsReductions redns_out (res_co `mkTransMCoR` res_co_out) - - go _ _ _ _ _ = panic - "simplifyArgsWorker wandered into deeper water than usual" - -- This debug information is commented out because leaving it in - -- causes a ~2% increase in allocations in T9872d. - -- That's independent of the analogous case in rewrite_args_fast - -- in GHC.Tc.Solver.Rewrite: - -- each of these causes a 2% increase on its own, so commenting them - -- both out gives a 4% decrease in T9872d. - {- - - (vcat [ppr orig_binders, - ppr orig_inner_ki, - ppr (take 10 orig_roles), -- often infinite! - ppr orig_tys]) - -} ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1742,7 +1742,7 @@ pushRefl co = -> Just (TyConAppCo r funTyCon [ multToCo w, mkReflCo r rep1, mkReflCo r rep2 , mkReflCo r ty1, mkReflCo r ty2 ]) Just (TyConApp tc tys, r) - -> Just (TyConAppCo r tc (zipWith mkReflCo (tyConRolesX r tc) tys)) + -> Just (TyConAppCo r tc (zipWith mkReflCo (tyConRoleListX r tc) tys)) Just (ForAllTy (Bndr tv _) ty, r) -> Just (ForAllCo tv (mkNomReflCo (varType tv)) (mkReflCo r ty)) -- NB: NoRefl variant. Otherwise, we get a loop! ===================================== compiler/GHC/Data/List/Infinite.hs ===================================== @@ -0,0 +1,194 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE RankNTypes #-} + +module GHC.Data.List.Infinite + ( Infinite (..) + , head, tail + , filter + , (++) + , unfoldr + , (!!) + , groupBy + , dropList + , iterate + , concatMap + , allListsOf + , toList + , repeat + ) where + +import Prelude ((-), Applicative (..), Bool (..), Foldable, Functor (..), Int, Maybe (..), Traversable (..), flip, otherwise) +import Control.Category (Category (..)) +import Control.Monad (guard) +import qualified Data.Foldable as F +import Data.List.NonEmpty (NonEmpty (..)) +import qualified GHC.Base as List (build) + +data Infinite a = Inf a (Infinite a) + deriving (Foldable, Functor, Traversable) + +head :: Infinite a -> a +head (Inf a _) = a +{-# NOINLINE [1] head #-} + +tail :: Infinite a -> Infinite a +tail (Inf _ as) = as +{-# NOINLINE [1] tail #-} + +{-# RULES +"head/build" forall (g :: forall b . (a -> b -> b) -> b) . head (build g) = g \ x _ -> x +#-} + +instance Applicative Infinite where + pure = repeat + Inf f fs <*> Inf a as = Inf (f a) (fs <*> as) + +mapMaybe :: (a -> Maybe b) -> Infinite a -> Infinite b +mapMaybe f = go + where + go (Inf a as) = let bs = go as in case f a of + Nothing -> bs + Just b -> Inf b bs +{-# NOINLINE [1] mapMaybe #-} + +{-# RULES +"mapMaybe" [~1] forall f as . mapMaybe f as = build \ c -> foldr (mapMaybeFB c f) as +"mapMaybeList" [1] forall f . foldr (mapMaybeFB Inf f) = mapMaybe f + #-} + +{-# INLINE [0] mapMaybeFB #-} +mapMaybeFB :: (b -> r -> r) -> (a -> Maybe b) -> a -> r -> r +mapMaybeFB cons f a bs = case f a of + Nothing -> bs + Just r -> cons r bs + +filter :: (a -> Bool) -> Infinite a -> Infinite a +filter f = mapMaybe (\ a -> a <$ guard (f a)) +{-# INLINE filter #-} + +infixr 5 ++ +(++) :: Foldable f => f a -> Infinite a -> Infinite a +(++) = flip (F.foldr Inf) + +unfoldr :: (b -> (a, b)) -> b -> Infinite a +unfoldr f b = build \ c -> let go b = case f b of (a, b') -> a `c` go b' in go b +{-# INLINE unfoldr #-} + +(!!) :: Infinite a -> Int -> a +Inf a _ !! 0 = a +Inf _ as !! n = as !! (n-1) + +groupBy :: (a -> a -> Bool) -> Infinite a -> Infinite (NonEmpty a) +groupBy eq = go + where + go (Inf a as) = Inf (a:|bs) (go cs) + where (bs, cs) = span (eq a) as + +span :: (a -> Bool) -> Infinite a -> ([a], Infinite a) +span p = spanJust (\ a -> a <$ guard (p a)) +{-# INLINE span #-} + +spanJust :: (a -> Maybe b) -> Infinite a -> ([b], Infinite a) +spanJust p = go + where + go as@(Inf a as') + | Just b <- p a = let (bs, cs) = go as' in (b:bs, cs) + | otherwise = ([], as) + +iterate :: (a -> a) -> a -> Infinite a +iterate f = go where go a = Inf a (go (f a)) +{-# NOINLINE [1] iterate #-} + +{-# RULES +"iterate" [~1] forall f a . iterate f a = build (\ c -> iterateFB c f a) +"iterateFB" [1] iterateFB Inf = iterate +#-} + +iterateFB :: (a -> b -> b) -> (a -> a) -> a -> b +iterateFB c f a = go a + where go a = a `c` go (f a) +{-# INLINE [0] iterateFB #-} + +concatMap :: Foldable f => (a -> f b) -> Infinite a -> Infinite b +concatMap f = go where go (Inf a as) = f a ++ go as +{-# NOINLINE [1] concatMap #-} + +{-# RULES "concatMap" forall f as . concatMap f as = build \ c -> foldr (\ x b -> F.foldr c b (f x)) as #-} + +{-# SPECIALIZE concatMap :: (a -> [b]) -> Infinite a -> Infinite b #-} + +foldr :: (a -> b -> b) -> Infinite a -> b +foldr f = go where go (Inf a as) = f a (go as) +{-# INLINE [0] foldr #-} + +build :: (forall b . (a -> b -> b) -> b) -> Infinite a +build g = g Inf +{-# INLINE [1] build #-} + +-- Analogous to 'foldr'/'build' fusion for '[]' +{-# RULES +"foldr/build" forall f (g :: forall b . (a -> b -> b) -> b) . foldr f (build g) = g f +"foldr/id" foldr Inf = id + +"foldr/cons/build" forall f a (g :: forall b . (a -> b -> b) -> b) . foldr f (Inf a (build g)) = f a (g f) +#-} + +{-# RULES +"map" [~1] forall f (as :: Infinite a) . fmap f as = build \ c -> foldr (mapFB c f) as +"mapFB" forall c f g . mapFB (mapFB c f) g = mapFB c (f . g) +"mapFB/id" forall c . mapFB c (\ x -> x) = c +#-} + +mapFB :: (b -> c -> c) -> (a -> b) -> a -> c -> c +mapFB c f = \ x ys -> c (f x) ys +{-# INLINE [0] mapFB #-} + +dropList :: [a] -> Infinite b -> Infinite b +dropList [] bs = bs +dropList (_:as) (Inf _ bs) = dropList as bs + +-- | Compute all lists of the given alphabet. +-- For example: @'allListsOf' "ab" = ["a", "b", "aa", "ba", "ab", "bb", "aaa", "baa", "aba", ...]@ +allListsOf :: [a] -> Infinite [a] +allListsOf as = concatMap (\ bs -> [a:bs | a <- as]) ([] `Inf` allListsOf as) + +-- See Note [Fusion for `Infinite` lists]. +toList :: Infinite a -> [a] +toList = \ as -> List.build (\ c _ -> foldr c as) +{-# INLINE toList #-} + +repeat :: a -> Infinite a +repeat a = as where as = Inf a as +{-# INLINE [0] repeat #-} + +repeatFB :: (a -> b -> b) -> a -> b +repeatFB c x = xs where xs = c x xs +{-# INLINE [0] repeatFB #-} + +{-# RULES +"repeat" [~1] forall a . repeat a = build \ c -> repeatFB c a +"repeatFB" [1] repeatFB Inf = repeat +#-} + +{- +Note [Fusion for `Infinite` lists] +~~~~~~~~~~~~~~~~~~~~ +We use RULES to support foldr/build fusion for Infinite lists, analogously to the RULES in +GHC.Base to support fusion for regular lists. In particular, we define the following: +• `build :: (forall b . (a -> b -> b) -> b) -> Infinite a` +• `foldr :: (a -> b -> b) -> Infinite a -> b` +• A RULE `foldr f (build g) = g f` +• `Infinite`-producing functions in terms of `build`, and `Infinite`-consuming functions in + terms of `foldr` + +This can work across data types. For example, consider `toList :: Infinite a -> [a]`. +We want 'toList' to be both a good consumer (of 'Infinite' lists) and a good producer (of '[]'). +Ergo, we define it in terms of 'Infinite.foldr' and `List.build`. + +For a bigger example, consider `List.map f (toList (Infinite.map g as))` + +We want to fuse away the intermediate `Infinite` structure between `Infnite.map` and `toList`, +and the list structure between `toList` and `List.map`. And indeed we do: see test +"InfiniteListFusion". +-} ===================================== compiler/GHC/HsToCore/Pmc/Ppr.hs ===================================== @@ -1,6 +1,5 @@ -{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -- | Provides facilities for pretty-printing 'Nabla's in a way appropriate for -- user facing pattern match warnings. @@ -10,6 +9,8 @@ module GHC.HsToCore.Pmc.Ppr ( import GHC.Prelude +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import GHC.Types.Basic import GHC.Types.Id import GHC.Types.Var.Env @@ -101,12 +102,11 @@ prettifyRefuts nabla = listToUDFM_Directly . map attach_refuts . udfmToList attach_refuts (u, (x, sdoc)) = (u, (sdoc, lookupRefuts nabla x)) -type PmPprM a = RWS Nabla () (DIdEnv (Id, SDoc), [SDoc]) a +type PmPprM a = RWS Nabla () (DIdEnv (Id, SDoc), Infinite SDoc) a -- Try nice names p,q,r,s,t before using the (ugly) t_i -nameList :: [SDoc] -nameList = map text ["p","q","r","s","t"] ++ - [ text ('t':show u) | u <- [(0 :: Int)..] ] +nameList :: Infinite SDoc +nameList = map text ["p","q","r","s","t"] Inf.++ flip Inf.unfoldr (0 :: Int) (\ u -> (text ('t':show u), u+1)) runPmPpr :: Nabla -> PmPprM a -> (a, DIdEnv (Id, SDoc)) runPmPpr nabla m = case runRWS m nabla (emptyDVarEnv, nameList) of @@ -117,7 +117,7 @@ runPmPpr nabla m = case runRWS m nabla (emptyDVarEnv, nameList) of getCleanName :: Id -> PmPprM SDoc getCleanName x = do (renamings, name_supply) <- get - let (clean_name:name_supply') = name_supply + let Inf clean_name name_supply' = name_supply case lookupDVarEnv renamings x of Just (_, nm) -> pure nm Nothing -> do ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -31,7 +31,7 @@ import GHC.Data.FastString import GHC.Data.Maybe (catMaybes) import GHC.Hs.Expr (prependQualified, HsExpr(..), LamCaseVariant(..), lamCaseKeyword) import GHC.Hs.Type (pprLHsContext) -import GHC.Builtin.Names (allNameStrings) +import GHC.Builtin.Names (allNameStringList) import GHC.Builtin.Types (filterCTuple) import qualified GHC.LanguageExtensions as LangExt import Data.List.NonEmpty (NonEmpty((:|))) @@ -486,7 +486,7 @@ instance Diagnostic PsMessage where , nest 2 (what <+> tc' - <+> hsep (map text (takeList tparms allNameStrings)) + <+> hsep (map text (takeList tparms allNameStringList)) <+> equals_or_where) ] ] where -- Avoid printing a constraint tuple in the error message. Print ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -173,7 +173,7 @@ normaliseFfiType' env ty0 = runWriterT $ go Representational initRecTc ty0 children_only = do { args <- unzipRedns <$> zipWithM ( \ ty r -> go r rec_nts ty ) - tys (tyConRolesX role tc) + tys (tyConRoleListX role tc) ; return $ mkTyConAppRedn role tc args } nt_co = mkUnbranchedAxInstCo role (newTyConCo tc) tys [] nt_rhs = newTyConInstRhs tc tys ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE MonadComprehensions #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} @@ -125,6 +126,8 @@ import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt import GHC.Data.FastString +import GHC.Data.List.Infinite ( Infinite (..) ) +import qualified GHC.Data.List.Infinite as Inf import GHC.Data.List.SetOps import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -3693,12 +3696,10 @@ splitTyConKind skol_info in_scope avoid_occs kind ; uniqs <- newUniqueSupply ; rdr_env <- getLocalRdrEnv ; lvl <- getTcLevel - ; let new_occs = [ occ - | str <- allNameStrings - , let occ = mkOccName tvName str - , isNothing (lookupLocalRdrOcc rdr_env occ) - -- Note [Avoid name clashes for associated data types] - , not (occ `elem` avoid_occs) ] + ; let new_occs = Inf.filter (\ occ -> + isNothing (lookupLocalRdrOcc rdr_env occ) && + -- Note [Avoid name clashes for associated data types] + not (occ `elem` avoid_occs)) $ mkOccName tvName <$> allNameStrings new_uniqs = uniqsFromSupply uniqs subst = mkEmptySubst in_scope details = SkolemTv skol_info (pushTcLevel lvl) False @@ -3716,8 +3717,8 @@ splitTyConKind skol_info in_scope avoid_occs kind name = mkInternalName uniq occ loc tv = mkTcTyVar name arg' details subst' = extendSubstInScope subst tv - (uniq:uniqs') = uniqs - (occ:occs') = occs + uniq:uniqs' = uniqs + Inf occ occs' = occs Just (Named (Bndr tv vis), kind') -> go occs uniqs subst' (tcb : acc) kind' ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -1914,7 +1914,7 @@ canDecomposableTyConAppOK ev eq_rel tc tys1 tys2 role = eqRelRole eq_rel -- infinite, as tyConRolesX returns an infinite tail of Nominal - tc_roles = tyConRolesX role tc + tc_roles = tyConRoleListX role tc -- Add nuances to the location during decomposition: -- * if the argument is a kind argument, remember this, so that error @@ -3128,7 +3128,7 @@ unifyWanted rewriters loc role orig_ty1 orig_ty2 | tc1 == tc2, tys1 `equalLength` tys2 , isInjectiveTyCon tc1 role -- don't look under newtypes at Rep equality = do { cos <- zipWith3M (unifyWanted rewriters loc) - (tyConRolesX role tc1) tys1 tys2 + (tyConRoleListX role tc1) tys1 tys2 ; return (mkTyConAppCo role tc1 cos) } go ty1@(TyVarTy tv) ty2 ===================================== compiler/GHC/Tc/Solver/Rewrite.hs ===================================== @@ -42,6 +42,8 @@ import Control.Monad import Control.Applicative (liftA3) import GHC.Builtin.Types.Prim (tYPETyCon) import Data.List ( find ) +import GHC.Data.List.Infinite (Infinite) +import qualified GHC.Data.List.Infinite as Inf {- ************************************************************************ @@ -368,7 +370,7 @@ we skip adding to the cache here. {-# INLINE rewrite_args_tc #-} rewrite_args_tc :: TyCon -- T - -> Maybe [Role] -- Nothing: ambient role is Nominal; all args are Nominal + -> Maybe (Infinite Role) -- Nothing: ambient role is Nominal; all args are Nominal -- Otherwise: no assumptions; use roles provided -> [Type] -> RewriteM ArgsReductions -- See the commentary on rewrite_args @@ -392,7 +394,7 @@ rewrite_args_tc tc = rewrite_args all_bndrs any_named_bndrs inner_ki emptyVarSet rewrite_args :: [TyCoBinder] -> Bool -- Binders, and True iff any of them are -- named. -> Kind -> TcTyCoVarSet -- function kind; kind's free vars - -> Maybe [Role] -> [Type] -- these are in 1-to-1 correspondence + -> Maybe (Infinite Role) -> [Type] -- these are in 1-to-1 correspondence -- Nothing: use all Nominal -> RewriteM ArgsReductions -- This function returns ArgsReductions (Reductions cos xis) res_co @@ -413,7 +415,7 @@ rewrite_args orig_binders = case (orig_m_roles, any_named_bndrs) of (Nothing, False) -> rewrite_args_fast orig_tys _ -> rewrite_args_slow orig_binders orig_inner_ki orig_fvs orig_roles orig_tys - where orig_roles = fromMaybe (repeat Nominal) orig_m_roles + where orig_roles = fromMaybe (Inf.repeat Nominal) orig_m_roles {-# INLINE rewrite_args_fast #-} -- | fast path rewrite_args, in which none of the binders are named and @@ -438,10 +440,10 @@ rewrite_args_fast orig_tys -- | Slow path, compared to rewrite_args_fast, because this one must track -- a lifting context. rewrite_args_slow :: [TyCoBinder] -> Kind -> TcTyCoVarSet - -> [Role] -> [Type] + -> Infinite Role -> [Type] -> RewriteM ArgsReductions rewrite_args_slow binders inner_ki fvs roles tys - = do { rewritten_args <- zipWithM rw roles tys + = do { rewritten_args <- zipWithM rw (Inf.toList roles) tys ; return (simplifyArgsWorker binders inner_ki fvs roles rewritten_args) } where {-# INLINE rw #-} @@ -587,7 +589,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys = do { het_redn <- case tcSplitTyConApp_maybe fun_xi of Just (tc, xis) -> do { let tc_roles = tyConRolesRepresentational tc - arg_roles = dropList xis tc_roles + arg_roles = Inf.dropList xis tc_roles ; ArgsReductions (Reductions arg_cos arg_xis) kind_co <- rewrite_vector (tcTypeKind fun_xi) arg_roles arg_tys @@ -608,7 +610,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys ReprEq -> mkAppCos fun_co (map mkNomReflCo arg_tys) `mkTcTransCo` mkTcTyConAppCo Representational tc - (zipWith mkReflCo tc_roles xis ++ arg_cos) + (zipWith mkReflCo (Inf.toList tc_roles) xis ++ arg_cos) ; return $ mkHetReduction @@ -616,7 +618,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys kind_co } Nothing -> do { ArgsReductions redns kind_co - <- rewrite_vector (tcTypeKind fun_xi) (repeat Nominal) arg_tys + <- rewrite_vector (tcTypeKind fun_xi) (Inf.repeat Nominal) arg_tys ; return $ mkHetReduction (mkAppRedns fun_redn redns) kind_co } ; role <- getRole @@ -636,7 +638,7 @@ rewrite_ty_con_app tc tys -- Rewrite a vector (list of arguments). rewrite_vector :: Kind -- of the function being applied to these arguments - -> [Role] -- If we're rewriting w.r.t. ReprEq, what roles do the + -> Infinite Role -- If we're rewriting w.r.t. ReprEq, what roles do the -- args have? -> [Type] -- the args to rewrite -> RewriteM ArgsReductions ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -976,7 +976,7 @@ any_rewritable role tv_pred tc_pred should_expand go_tc NomEq bvs _ tys = any (go NomEq bvs) tys go_tc ReprEq bvs tc tys = any (go_arg bvs) - (tyConRolesRepresentational tc `zip` tys) + (tyConRoleListRepresentational tc `zip` tys) go_arg bvs (Nominal, ty) = go NomEq bvs ty go_arg bvs (Representational, ty) = go ReprEq bvs ty ===================================== compiler/ghc.cabal.in ===================================== @@ -378,6 +378,7 @@ Library GHC.Data.Graph.Ppr GHC.Data.Graph.UnVar GHC.Data.IOEnv + GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== configure.ac ===================================== @@ -555,7 +555,7 @@ AC_SUBST(InstallNameToolCmd) # versions of LLVM simultaneously, but that stopped working around # 3.5/3.6 release of LLVM. LlvmMinVersion=10 # inclusive -LlvmMaxVersion=14 # not inclusive +LlvmMaxVersion=15 # not inclusive AC_SUBST([LlvmMinVersion]) AC_SUBST([LlvmMaxVersion]) sUPPORTED_LLVM_VERSION_MIN=$(echo \($LlvmMinVersion\) | sed 's/\./,/') ===================================== libraries/base/Data/Foldable.hs ===================================== @@ -1175,7 +1175,7 @@ sequence_ = foldr c (return ()) where c m k = m >> k {-# INLINE c #-} --- | The sum of a collection of actions, generalizing 'concat'. +-- | The sum of a collection of actions using '(<|>)', generalizing 'concat'. -- -- 'asum' is just like 'msum', but generalised to 'Alternative'. -- @@ -1189,10 +1189,16 @@ asum :: (Foldable t, Alternative f) => t (f a) -> f a {-# INLINE asum #-} asum = foldr (<|>) empty --- | The sum of a collection of actions, generalizing 'concat'. +-- | The sum of a collection of actions using '(<|>)', generalizing 'concat'. -- -- 'msum' is just like 'asum', but specialised to 'MonadPlus'. -- +-- ==== __Examples__ +-- +-- Basic usage, using the 'MonadPlus' instance for 'Maybe': +-- +-- >>> msum [Just "Hello", Nothing, Just "World"] +-- Just "Hello" msum :: (Foldable t, MonadPlus m) => t (m a) -> m a {-# INLINE msum #-} msum = asum ===================================== libraries/base/GHC/Base.hs ===================================== @@ -599,6 +599,15 @@ class Functor f where -- The default definition is @'fmap' . 'const'@, but this may be -- overridden with a more efficient version. -- + -- ==== __Examples__ + -- + -- Perform a computation with 'Maybe' and replace the result with a + -- constant value if it is 'Just': + -- + -- >>> 'a' <$ Just 2 + -- Just 'a' + -- >>> 'a' <$ Nothing + -- Nothing (<$) :: a -> f b -> f a (<$) = fmap . const @@ -1111,7 +1120,9 @@ class Applicative f => Alternative f where some_v = liftA2 (:) v many_v --- | @since 2.01 +-- | Picks the leftmost 'Just' value, or, alternatively, 'Nothing'. +-- +-- @since 2.01 instance Alternative Maybe where empty = Nothing Nothing <|> r = r @@ -1143,7 +1154,9 @@ class (Alternative m, Monad m) => MonadPlus m where mplus :: m a -> m a -> m a mplus = (<|>) --- | @since 2.01 +-- | Picks the leftmost 'Just' value, or, alternatively, 'Nothing'. +-- +-- @since 2.01 instance MonadPlus Maybe --------------------------------------------- @@ -1205,12 +1218,16 @@ instance Monad [] where {-# INLINE (>>) #-} (>>) = (*>) --- | @since 2.01 +-- | Combines lists by concatenation, starting from the empty list. +-- +-- @since 2.01 instance Alternative [] where empty = [] (<|>) = (++) --- | @since 2.01 +-- | Combines lists by concatenation, starting from the empty list. +-- +-- @since 2.01 instance MonadPlus [] {- @@ -1593,12 +1610,18 @@ instance Monad IO where (>>) = (*>) (>>=) = bindIO --- | @since 4.9.0.0 +-- | Takes the first non-throwing 'IO' action\'s result. +-- 'empty' throws an exception. +-- +-- @since 4.9.0.0 instance Alternative IO where empty = failIO "mzero" (<|>) = mplusIO --- | @since 4.9.0.0 +-- | Takes the first non-throwing 'IO' action\'s result. +-- 'mzero' throws an exception. +-- +-- @since 4.9.0.0 instance MonadPlus IO returnIO :: a -> IO a ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -733,12 +733,16 @@ thenSTM (STM m) k = STM ( \s -> returnSTM :: a -> STM a returnSTM x = STM (\s -> (# s, x #)) --- | @since 4.8.0.0 +-- | Takes the first non-'retry'ing 'STM' action. +-- +-- @since 4.8.0.0 instance Alternative STM where empty = retry (<|>) = orElse --- | @since 4.3.0.0 +-- | Takes the first non-'retry'ing 'STM' action. +-- +-- @since 4.3.0.0 instance MonadPlus STM -- | Unsafely performs IO in the STM monad. Beware: this is a highly ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -87,6 +87,7 @@ GHC.Data.FiniteMap GHC.Data.Graph.Directed GHC.Data.Graph.UnVar GHC.Data.IOEnv +GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -87,6 +87,7 @@ GHC.Data.FiniteMap GHC.Data.Graph.Directed GHC.Data.Graph.UnVar GHC.Data.IOEnv +GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== testsuite/tests/perf/compiler/InfiniteListFusion.hs ===================================== @@ -0,0 +1,9 @@ +module Main where + +import qualified GHC.Data.List.Infinite as Inf + +main :: IO () +main = print $ sum $ take (2^16) $ Inf.toList $ Inf.filter isEven $ Inf.iterate succ (0 :: Int) + +isEven :: Integral a => a -> Bool +isEven n = 0 == mod n 2 ===================================== testsuite/tests/perf/compiler/InfiniteListFusion.stdout ===================================== @@ -0,0 +1 @@ +4294901760 ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -649,4 +649,9 @@ test('T21839c', [ collect_compiler_stats('all', 1), only_ways(['normal'])], compile, - ['-O']) \ No newline at end of file + ['-O']) + +test ('InfiniteListFusion', + [collect_stats('bytes allocated',2), when(arch('i386'), skip)], + compile_and_run, + ['-O2 -package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1a55752bcdaaa3334085126f28afc021f7da7e79...e730c3c5d20c31477076c36de18be1efd6b1f76f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1a55752bcdaaa3334085126f28afc021f7da7e79...e730c3c5d20c31477076c36de18be1efd6b1f76f You're receiving 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 Nov 8 09:08:44 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 08 Nov 2022 04:08:44 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/fix-cabal-reinstall Message-ID: <636a1c9c934b8_10da0554a241102da@gitlab.mail> Zubin pushed new branch wip/fix-cabal-reinstall at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/fix-cabal-reinstall You're receiving 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 Nov 8 09:08:53 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 08 Nov 2022 04:08:53 -0500 Subject: [Git][ghc/ghc][wip/fix-cabal-reinstall] Fix cabal reinstall (#22344) Message-ID: <636a1ca5839c6_10da053ed19f0110468@gitlab.mail> Zubin pushed to branch wip/fix-cabal-reinstall at Glasgow Haskell Compiler / GHC Commits: dc08a3b1 by Zubin Duggal at 2022-11-08T14:38:46+05:30 Fix cabal reinstall (#22344) As a result of filepath 1.4.100 acquiring new dependencies on bytestring and exceptions, the bytestring, exceptions, mtl and transformers packages can no longer be reinstalled. - - - - - 1 changed file: - cabal.project-reinstall Changes: ===================================== cabal.project-reinstall ===================================== @@ -5,13 +5,13 @@ packages: ./compiler -- ./libraries/array -- ./libraries/base ./libraries/binary - ./libraries/bytestring + -- ./libraries/bytestring ./libraries/Cabal/Cabal ./libraries/Cabal/Cabal-syntax ./libraries/containers/containers/ -- ./libraries/deepseq/ ./libraries/directory/ - ./libraries/exceptions/ + -- ./libraries/exceptions/ -- ./libraries/filepath/ -- ./libraries/ghc-bignum/ ./libraries/ghc-boot/ @@ -25,16 +25,16 @@ packages: ./compiler ./libraries/hpc -- ./libraries/integer-gmp ./libraries/libiserv/ - ./libraries/mtl/ + -- ./libraries/mtl/ ./libraries/parsec/ -- ./libraries/pretty/ ./libraries/process/ - ./libraries/stm + -- ./libraries/stm -- ./libraries/template-haskell/ ./libraries/terminfo/ ./libraries/text ./libraries/time - ./libraries/transformers/ + -- ./libraries/transformers/ ./libraries/unix/ ./libraries/Win32/ ./libraries/xhtml/ @@ -56,6 +56,11 @@ constraints: ghc +internal-interpreter +dynamic-system-linke +terminfo, any.base installed, any.deepseq installed, any.filepath installed, + any.bytestring installed, + any.exceptions installed, + any.stm installed, + any.transformers installed, + any.mtl installed, any.ghc-bignum installed, any.ghc-boot-th installed, any.integer-gmp installed, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc08a3b1d27f4a32fee2ee7ed7030f87038663eb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dc08a3b1d27f4a32fee2ee7ed7030f87038663eb You're receiving 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 Nov 8 09:11:53 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 08 Nov 2022 04:11:53 -0500 Subject: [Git][ghc/ghc][wip/fix-cabal-reinstall] Fix cabal reinstall (#22344) Message-ID: <636a1d5910338_10da055ac8adc112519@gitlab.mail> Zubin pushed to branch wip/fix-cabal-reinstall at Glasgow Haskell Compiler / GHC Commits: b64f88cd by Zubin Duggal at 2022-11-08T14:41:19+05:30 Fix cabal reinstall (#22344) Since filepath 1.4.100 template haskell no longer depends on filepath, so we can reinstall it. - - - - - 1 changed file: - cabal.project-reinstall Changes: ===================================== cabal.project-reinstall ===================================== @@ -12,7 +12,7 @@ packages: ./compiler -- ./libraries/deepseq/ ./libraries/directory/ ./libraries/exceptions/ - -- ./libraries/filepath/ + ./libraries/filepath/ -- ./libraries/ghc-bignum/ ./libraries/ghc-boot/ -- ./libraries/ghc-boot-th/ @@ -55,7 +55,6 @@ constraints: ghc +internal-interpreter +dynamic-system-linke +terminfo, any.array installed, any.base installed, any.deepseq installed, - any.filepath installed, any.ghc-bignum installed, any.ghc-boot-th installed, any.integer-gmp installed, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b64f88cd0705b176f353fe1d3a84146cc8b52ec8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b64f88cd0705b176f353fe1d3a84146cc8b52ec8 You're receiving 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 Nov 8 09:13:12 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 08 Nov 2022 04:13:12 -0500 Subject: [Git][ghc/ghc][wip/fix-cabal-reinstall] Add test-reinstall label Message-ID: <636a1da8a2271_10da0552b5c1130a@gitlab.mail> Zubin pushed to branch wip/fix-cabal-reinstall at Glasgow Haskell Compiler / GHC Commits: 96178415 by Zubin Duggal at 2022-11-08T14:43:05+05:30 Add test-reinstall label - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -401,6 +401,7 @@ test-cabal-reinstall-x86_64-linux-deb10: TEST_ENV: "x86_64-linux-deb10-cabal-install" rules: - if: $NIGHTLY + - if: '$CI_MERGE_REQUEST_LABELS =~ /.*test-reinstall.*/' ############################################################ # Packaging View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96178415c5e4ca57dc394c05f21e7bfb4c3b8b96 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/96178415c5e4ca57dc394c05f21e7bfb4c3b8b96 You're receiving 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 Nov 8 09:51:54 2022 From: gitlab at gitlab.haskell.org (Zubin (@wz1000)) Date: Tue, 08 Nov 2022 04:51:54 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/llvm-configure-message Message-ID: <636a26ba4a80_10da054796c981233c8@gitlab.mail> Zubin pushed new branch wip/llvm-configure-message at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/llvm-configure-message You're receiving 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 Nov 8 09:53:31 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 04:53:31 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Define `Infinite` list and use where appropriate. Message-ID: <636a271be4a46_10da0554a10129698@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d87ad571 by M Farkas-Dyck at 2022-11-08T04:53:12-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - 87937ed8 by Jade Lovelace at 2022-11-08T04:53:16-05:00 Clarify msum/asum documentation - - - - - 6a9decf1 by Jade Lovelace at 2022-11-08T04:53:16-05:00 Add example for (<$) - - - - - d9074bc0 by Jade Lovelace at 2022-11-08T04:53:16-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 24 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Reduction.hs - compiler/GHC/Core/Unify.hs - + compiler/GHC/Data/List/Infinite.hs - compiler/GHC/HsToCore/Pmc/Ppr.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Rewrite.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - libraries/base/Data/Foldable.hs - libraries/base/GHC/Base.hs - libraries/base/GHC/Conc/Sync.hs - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout - + testsuite/tests/perf/compiler/InfiniteListFusion.hs - + testsuite/tests/perf/compiler/InfiniteListFusion.stdout - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -119,7 +119,6 @@ in GHC.Builtin.Types. -} {-# LANGUAGE CPP #-} -{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} module GHC.Builtin.Names ( Unique, Uniquable(..), hasKey, -- Re-exported for convenience @@ -143,6 +142,8 @@ import GHC.Builtin.Uniques import GHC.Types.Name import GHC.Types.SrcLoc import GHC.Data.FastString +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import Language.Haskell.Syntax.Module.Name @@ -154,9 +155,13 @@ import Language.Haskell.Syntax.Module.Name ************************************************************************ -} -allNameStrings :: [String] +allNameStrings :: Infinite String -- Infinite list of a,b,c...z, aa, ab, ac, ... etc -allNameStrings = [ c:cs | cs <- "" : allNameStrings, c <- ['a'..'z'] ] +allNameStrings = Inf.allListsOf ['a'..'z'] + +allNameStringList :: [String] +-- Infinite list of a,b,c...z, aa, ab, ac, ... etc +allNameStringList = Inf.toList allNameStrings {- ************************************************************************ ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -63,6 +63,7 @@ module GHC.Core.Coercion ( splitForAllCo_ty_maybe, splitForAllCo_co_maybe, nthRole, tyConRolesX, tyConRolesRepresentational, setNominalRole_maybe, + tyConRoleListX, tyConRoleListRepresentational, pickLR, @@ -154,6 +155,8 @@ import GHC.Builtin.Types.Prim import GHC.Data.List.SetOps import GHC.Data.Maybe import GHC.Types.Unique.FM +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import GHC.Utils.Misc import GHC.Utils.Outputable @@ -408,12 +411,10 @@ where co_rep1, co_rep2 are the coercions on the representations. -- -- > decomposeCo 3 c [r1, r2, r3] = [nth r1 0 c, nth r2 1 c, nth r3 2 c] decomposeCo :: Arity -> Coercion - -> [Role] -- the roles of the output coercions - -- this must have at least as many - -- entries as the Arity provided + -> Infinite Role -- the roles of the output coercions -> [Coercion] decomposeCo arity co rs - = [mkNthCo r n co | (n,r) <- [0..(arity-1)] `zip` rs ] + = [mkNthCo r n co | (n,r) <- [0..(arity-1)] `zip` Inf.toList rs ] -- Remember, Nth is zero-indexed decomposeFunCo :: HasDebugCallStack @@ -533,7 +534,7 @@ splitTyConAppCo_maybe :: Coercion -> Maybe (TyCon, [Coercion]) splitTyConAppCo_maybe co | Just (ty, r) <- isReflCo_maybe co = do { (tc, tys) <- splitTyConApp_maybe ty - ; let args = zipWith mkReflCo (tyConRolesX r tc) tys + ; let args = zipWith mkReflCo (tyConRoleListX r tc) tys ; return (tc, args) } splitTyConAppCo_maybe (TyConAppCo _ tc cos) = Just (tc, cos) splitTyConAppCo_maybe (FunCo _ w arg res) = Just (funTyCon, cos) @@ -819,15 +820,14 @@ mkAppCo co arg -- Expand type synonyms; a TyConAppCo can't have a type synonym (#9102) = mkTyConAppCo r tc (zip_roles (tyConRolesX r tc) tys) where - zip_roles (r1:_) [] = [downgradeRole r1 Nominal arg] - zip_roles (r1:rs) (ty1:tys) = mkReflCo r1 ty1 : zip_roles rs tys - zip_roles _ _ = panic "zip_roles" -- but the roles are infinite... + zip_roles (Inf r1 _) [] = [downgradeRole r1 Nominal arg] + zip_roles (Inf r1 rs) (ty1:tys) = mkReflCo r1 ty1 : zip_roles rs tys mkAppCo (TyConAppCo r tc args) arg = case r of Nominal -> mkTyConAppCo Nominal tc (args ++ [arg]) Representational -> mkTyConAppCo Representational tc (args ++ [arg']) - where new_role = (tyConRolesRepresentational tc) !! (length args) + where new_role = tyConRolesRepresentational tc Inf.!! length args arg' = downgradeRole new_role Nominal arg Phantom -> mkTyConAppCo Phantom tc (args ++ [toPhantomCo arg]) mkAppCo co arg = AppCo co arg @@ -1153,10 +1153,7 @@ mkNthCo r n co , tc1 == tc2 = let len1 = length tys1 len2 = length tys2 - good_role = case coercionRole co of - Nominal -> r == Nominal - Representational -> r == (tyConRolesRepresentational tc1 !! n) - Phantom -> r == Phantom + good_role = r == nthRole (coercionRole co) tc1 n in len1 == len2 && n < len1 && good_role | otherwise @@ -1349,7 +1346,7 @@ setNominalRole_maybe r co setNominalRole_maybe_helper co@(Refl _) = Just co setNominalRole_maybe_helper (GRefl _ ty co) = Just $ GRefl Nominal ty co setNominalRole_maybe_helper (TyConAppCo Representational tc cos) - = do { cos' <- zipWithM setNominalRole_maybe (tyConRolesX Representational tc) cos + = do { cos' <- zipWithM setNominalRole_maybe (tyConRoleListX Representational tc) cos ; return $ TyConAppCo Nominal tc cos' } setNominalRole_maybe_helper (FunCo Representational w co1 co2) = do { co1' <- setNominalRole_maybe Representational co1 @@ -1393,27 +1390,33 @@ toPhantomCo co -- Convert args to a TyConAppCo Nominal to the same TyConAppCo Representational applyRoles :: TyCon -> [Coercion] -> [Coercion] -applyRoles tc cos - = zipWith (\r -> downgradeRole r Nominal) (tyConRolesRepresentational tc) cos +applyRoles = zipWith (`downgradeRole` Nominal) . tyConRoleListRepresentational -- the Role parameter is the Role of the TyConAppCo -- defined here because this is intimately concerned with the implementation -- of TyConAppCo -- Always returns an infinite list (with a infinite tail of Nominal) -tyConRolesX :: Role -> TyCon -> [Role] +tyConRolesX :: Role -> TyCon -> Infinite Role tyConRolesX Representational tc = tyConRolesRepresentational tc -tyConRolesX role _ = repeat role +tyConRolesX role _ = Inf.repeat role + +tyConRoleListX :: Role -> TyCon -> [Role] +tyConRoleListX role = Inf.toList . tyConRolesX role + +-- Returns the roles of the parameters of a tycon, with an infinite tail +-- of Nominal +tyConRolesRepresentational :: TyCon -> Infinite Role +tyConRolesRepresentational tc = tyConRoles tc Inf.++ Inf.repeat Nominal -- Returns the roles of the parameters of a tycon, with an infinite tail -- of Nominal -tyConRolesRepresentational :: TyCon -> [Role] -tyConRolesRepresentational tc = tyConRoles tc ++ repeat Nominal +tyConRoleListRepresentational :: TyCon -> [Role] +tyConRoleListRepresentational = Inf.toList . tyConRolesRepresentational nthRole :: Role -> TyCon -> Int -> Role nthRole Nominal _ _ = Nominal nthRole Phantom _ _ = Phantom -nthRole Representational tc n - = (tyConRolesRepresentational tc) `getNth` n +nthRole Representational tc n = tyConRolesRepresentational tc Inf.!! n ltRole :: Role -> Role -> Bool -- Is one role "less" than another? @@ -2034,7 +2037,7 @@ ty_co_subst !lc role ty go r (TyVarTy tv) = expectJust "ty_co_subst bad roles" $ liftCoSubstTyVar lc r tv go r (AppTy ty1 ty2) = mkAppCo (go r ty1) (go Nominal ty2) - go r (TyConApp tc tys) = mkTyConAppCo r tc (zipWith go (tyConRolesX r tc) tys) + go r (TyConApp tc tys) = mkTyConAppCo r tc (zipWith go (tyConRoleListX r tc) tys) go r (FunTy _ w ty1 ty2) = mkFunCo r (go Nominal w) (go r ty1) (go r ty2) go r t@(ForAllTy (Bndr v _) ty) = let (lc', v', h) = liftCoSubstVarBndr lc v ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -245,7 +245,7 @@ opt_co4 env sym rep r g@(TyConAppCo _r tc cos) (True, Nominal) -> mkTyConAppCo Representational tc (zipWith3 (opt_co3 env sym) - (map Just (tyConRolesRepresentational tc)) + (map Just (tyConRoleListRepresentational tc)) (repeat Nominal) cos) (False, Nominal) -> @@ -254,7 +254,7 @@ opt_co4 env sym rep r g@(TyConAppCo _r tc cos) -- must use opt_co2 here, because some roles may be P -- See Note [Optimising coercion optimisation] mkTyConAppCo r tc (zipWith (opt_co2 env sym) - (tyConRolesRepresentational tc) -- the current roles + (tyConRoleListRepresentational tc) -- the current roles cos) (_, Phantom) -> pprPanic "opt_co4 sees a phantom!" (ppr g) @@ -546,7 +546,7 @@ opt_univ env sym prov role oty1 oty2 , equalLength tys1 tys2 -- see Note [Differing kinds] -- NB: prov must not be the two interesting ones (ProofIrrel & Phantom); -- Phantom is already taken care of, and ProofIrrel doesn't relate tyconapps - = let roles = tyConRolesX role tc1 + = let roles = tyConRoleListX role tc1 arg_cos = zipWith3 (mkUnivCo prov') roles tys1 tys2 arg_cos' = zipWith (opt_co4 env sym False) roles arg_cos in ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -63,6 +63,8 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Data.Bag +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf {- ************************************************************************ @@ -1477,7 +1479,7 @@ normalise_type ty Nothing -> do { ArgsReductions redns res_co <- normalise_args (typeKind nfun) - (repeat Nominal) + (Inf.repeat Nominal) arg_tys ; role <- getRole ; return $ @@ -1486,7 +1488,7 @@ normalise_type ty (mkSymMCo res_co) } } normalise_args :: Kind -- of the function - -> [Role] -- roles at which to normalise args + -> Infinite Role -- roles at which to normalise args -> [Type] -- args -> NormM ArgsReductions -- returns ArgsReductions (Reductions cos xis) res_co, @@ -1496,7 +1498,7 @@ normalise_args :: Kind -- of the function -- but the resulting application *will* be well-kinded -- cf. GHC.Tc.Solver.Rewrite.rewrite_args_slow normalise_args fun_ki roles args - = do { normed_args <- zipWithM normalise1 roles args + = do { normed_args <- zipWithM normalise1 (Inf.toList roles) args ; return $ simplifyArgsWorker ki_binders inner_ki fvs roles normed_args } where (ki_binders, inner_ki) = splitPiTys fun_ki ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -2177,7 +2177,7 @@ lintCoercion co@(TyConAppCo r tc cos) ; let (co_kinds, co_roles) = unzip (map coercionKindRole cos') ; lint_co_app co (tyConKind tc) (map pFst co_kinds) ; lint_co_app co (tyConKind tc) (map pSnd co_kinds) - ; zipWithM_ (lintRole co) (tyConRolesX r tc) co_roles + ; zipWithM_ (lintRole co) (tyConRoleListX r tc) co_roles ; return (TyConAppCo r tc cos') } lintCoercion co@(AppCo co1 co2) ===================================== compiler/GHC/Core/Reduction.hs ===================================== @@ -35,6 +35,8 @@ import GHC.Core.TyCon ( TyCon ) import GHC.Core.Type import GHC.Data.Pair ( Pair(Pair) ) +import GHC.Data.List.Infinite ( Infinite (..) ) +import qualified GHC.Data.List.Infinite as Inf import GHC.Types.Var ( setTyVarKind ) import GHC.Types.Var.Env ( mkInScopeSet ) @@ -42,7 +44,7 @@ import GHC.Types.Var.Set ( TyCoVarSet ) import GHC.Utils.Misc ( HasDebugCallStack, equalLength ) import GHC.Utils.Outputable -import GHC.Utils.Panic ( assertPpr, panic ) +import GHC.Utils.Panic ( assertPpr ) {- %************************************************************************ @@ -788,7 +790,7 @@ simplifyArgsWorker :: HasDebugCallStack -- the binders & result kind (not a Π-type) of the function applied to the args -- list of binders can be shorter or longer than the list of args -> TyCoVarSet -- free vars of the args - -> [Role] -- list of roles, r + -> Infinite Role-- list of roles, r -> [Reduction] -- rewritten type arguments, arg_i -- each comes with the coercion used to rewrite it, -- arg_co_i :: ty_i ~ arg_i @@ -809,11 +811,11 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs where orig_lc = emptyLiftingContext $ mkInScopeSet orig_fvs - go :: LiftingContext -- mapping from tyvars to rewriting coercions - -> [TyCoBinder] -- Unsubsted binders of function's kind - -> Kind -- Unsubsted result kind of function (not a Pi-type) - -> [Role] -- Roles at which to rewrite these ... - -> [Reduction] -- rewritten arguments, with their rewriting coercions + go :: LiftingContext -- mapping from tyvars to rewriting coercions + -> [TyCoBinder] -- Unsubsted binders of function's kind + -> Kind -- Unsubsted result kind of function (not a Pi-type) + -> Infinite Role -- Roles at which to rewrite these ... + -> [Reduction] -- rewritten arguments, with their rewriting coercions -> ArgsReductions go !lc binders inner_ki _ [] -- The !lc makes the function strict in the lifting context @@ -826,7 +828,7 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs kind_co | noFreeVarsOfType final_kind = MRefl | otherwise = MCo $ liftCoSubst Nominal lc final_kind - go lc (binder:binders) inner_ki (role:roles) (arg_redn:arg_redns) + go lc (binder:binders) inner_ki (Inf role roles) (arg_redn:arg_redns) = -- We rewrite an argument ty with arg_redn = Reduction arg_co arg -- By Note [Rewriting] in GHC.Tc.Solver.Rewrite invariant (F2), -- tcTypeKind(ty) = tcTypeKind(arg). @@ -859,7 +861,7 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs (arg_cos, res_co) = decomposePiCos co1 co1_kind unrewritten_tys casted_args = assertPpr (equalLength arg_redns arg_cos) (ppr arg_redns $$ ppr arg_cos) - $ zipWith3 mkCoherenceRightRedn roles arg_redns arg_cos + $ zipWith3 mkCoherenceRightRedn (Inf.toList roles) arg_redns arg_cos -- In general decomposePiCos can return fewer cos than tys, -- but not here; because we're well typed, there will be enough -- binders. Note that decomposePiCos does substitutions, so even @@ -874,19 +876,3 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs = go zapped_lc bndrs new_inner roles casted_args in ArgsReductions redns_out (res_co `mkTransMCoR` res_co_out) - - go _ _ _ _ _ = panic - "simplifyArgsWorker wandered into deeper water than usual" - -- This debug information is commented out because leaving it in - -- causes a ~2% increase in allocations in T9872d. - -- That's independent of the analogous case in rewrite_args_fast - -- in GHC.Tc.Solver.Rewrite: - -- each of these causes a 2% increase on its own, so commenting them - -- both out gives a 4% decrease in T9872d. - {- - - (vcat [ppr orig_binders, - ppr orig_inner_ki, - ppr (take 10 orig_roles), -- often infinite! - ppr orig_tys]) - -} ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1742,7 +1742,7 @@ pushRefl co = -> Just (TyConAppCo r funTyCon [ multToCo w, mkReflCo r rep1, mkReflCo r rep2 , mkReflCo r ty1, mkReflCo r ty2 ]) Just (TyConApp tc tys, r) - -> Just (TyConAppCo r tc (zipWith mkReflCo (tyConRolesX r tc) tys)) + -> Just (TyConAppCo r tc (zipWith mkReflCo (tyConRoleListX r tc) tys)) Just (ForAllTy (Bndr tv _) ty, r) -> Just (ForAllCo tv (mkNomReflCo (varType tv)) (mkReflCo r ty)) -- NB: NoRefl variant. Otherwise, we get a loop! ===================================== compiler/GHC/Data/List/Infinite.hs ===================================== @@ -0,0 +1,194 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE RankNTypes #-} + +module GHC.Data.List.Infinite + ( Infinite (..) + , head, tail + , filter + , (++) + , unfoldr + , (!!) + , groupBy + , dropList + , iterate + , concatMap + , allListsOf + , toList + , repeat + ) where + +import Prelude ((-), Applicative (..), Bool (..), Foldable, Functor (..), Int, Maybe (..), Traversable (..), flip, otherwise) +import Control.Category (Category (..)) +import Control.Monad (guard) +import qualified Data.Foldable as F +import Data.List.NonEmpty (NonEmpty (..)) +import qualified GHC.Base as List (build) + +data Infinite a = Inf a (Infinite a) + deriving (Foldable, Functor, Traversable) + +head :: Infinite a -> a +head (Inf a _) = a +{-# NOINLINE [1] head #-} + +tail :: Infinite a -> Infinite a +tail (Inf _ as) = as +{-# NOINLINE [1] tail #-} + +{-# RULES +"head/build" forall (g :: forall b . (a -> b -> b) -> b) . head (build g) = g \ x _ -> x +#-} + +instance Applicative Infinite where + pure = repeat + Inf f fs <*> Inf a as = Inf (f a) (fs <*> as) + +mapMaybe :: (a -> Maybe b) -> Infinite a -> Infinite b +mapMaybe f = go + where + go (Inf a as) = let bs = go as in case f a of + Nothing -> bs + Just b -> Inf b bs +{-# NOINLINE [1] mapMaybe #-} + +{-# RULES +"mapMaybe" [~1] forall f as . mapMaybe f as = build \ c -> foldr (mapMaybeFB c f) as +"mapMaybeList" [1] forall f . foldr (mapMaybeFB Inf f) = mapMaybe f + #-} + +{-# INLINE [0] mapMaybeFB #-} +mapMaybeFB :: (b -> r -> r) -> (a -> Maybe b) -> a -> r -> r +mapMaybeFB cons f a bs = case f a of + Nothing -> bs + Just r -> cons r bs + +filter :: (a -> Bool) -> Infinite a -> Infinite a +filter f = mapMaybe (\ a -> a <$ guard (f a)) +{-# INLINE filter #-} + +infixr 5 ++ +(++) :: Foldable f => f a -> Infinite a -> Infinite a +(++) = flip (F.foldr Inf) + +unfoldr :: (b -> (a, b)) -> b -> Infinite a +unfoldr f b = build \ c -> let go b = case f b of (a, b') -> a `c` go b' in go b +{-# INLINE unfoldr #-} + +(!!) :: Infinite a -> Int -> a +Inf a _ !! 0 = a +Inf _ as !! n = as !! (n-1) + +groupBy :: (a -> a -> Bool) -> Infinite a -> Infinite (NonEmpty a) +groupBy eq = go + where + go (Inf a as) = Inf (a:|bs) (go cs) + where (bs, cs) = span (eq a) as + +span :: (a -> Bool) -> Infinite a -> ([a], Infinite a) +span p = spanJust (\ a -> a <$ guard (p a)) +{-# INLINE span #-} + +spanJust :: (a -> Maybe b) -> Infinite a -> ([b], Infinite a) +spanJust p = go + where + go as@(Inf a as') + | Just b <- p a = let (bs, cs) = go as' in (b:bs, cs) + | otherwise = ([], as) + +iterate :: (a -> a) -> a -> Infinite a +iterate f = go where go a = Inf a (go (f a)) +{-# NOINLINE [1] iterate #-} + +{-# RULES +"iterate" [~1] forall f a . iterate f a = build (\ c -> iterateFB c f a) +"iterateFB" [1] iterateFB Inf = iterate +#-} + +iterateFB :: (a -> b -> b) -> (a -> a) -> a -> b +iterateFB c f a = go a + where go a = a `c` go (f a) +{-# INLINE [0] iterateFB #-} + +concatMap :: Foldable f => (a -> f b) -> Infinite a -> Infinite b +concatMap f = go where go (Inf a as) = f a ++ go as +{-# NOINLINE [1] concatMap #-} + +{-# RULES "concatMap" forall f as . concatMap f as = build \ c -> foldr (\ x b -> F.foldr c b (f x)) as #-} + +{-# SPECIALIZE concatMap :: (a -> [b]) -> Infinite a -> Infinite b #-} + +foldr :: (a -> b -> b) -> Infinite a -> b +foldr f = go where go (Inf a as) = f a (go as) +{-# INLINE [0] foldr #-} + +build :: (forall b . (a -> b -> b) -> b) -> Infinite a +build g = g Inf +{-# INLINE [1] build #-} + +-- Analogous to 'foldr'/'build' fusion for '[]' +{-# RULES +"foldr/build" forall f (g :: forall b . (a -> b -> b) -> b) . foldr f (build g) = g f +"foldr/id" foldr Inf = id + +"foldr/cons/build" forall f a (g :: forall b . (a -> b -> b) -> b) . foldr f (Inf a (build g)) = f a (g f) +#-} + +{-# RULES +"map" [~1] forall f (as :: Infinite a) . fmap f as = build \ c -> foldr (mapFB c f) as +"mapFB" forall c f g . mapFB (mapFB c f) g = mapFB c (f . g) +"mapFB/id" forall c . mapFB c (\ x -> x) = c +#-} + +mapFB :: (b -> c -> c) -> (a -> b) -> a -> c -> c +mapFB c f = \ x ys -> c (f x) ys +{-# INLINE [0] mapFB #-} + +dropList :: [a] -> Infinite b -> Infinite b +dropList [] bs = bs +dropList (_:as) (Inf _ bs) = dropList as bs + +-- | Compute all lists of the given alphabet. +-- For example: @'allListsOf' "ab" = ["a", "b", "aa", "ba", "ab", "bb", "aaa", "baa", "aba", ...]@ +allListsOf :: [a] -> Infinite [a] +allListsOf as = concatMap (\ bs -> [a:bs | a <- as]) ([] `Inf` allListsOf as) + +-- See Note [Fusion for `Infinite` lists]. +toList :: Infinite a -> [a] +toList = \ as -> List.build (\ c _ -> foldr c as) +{-# INLINE toList #-} + +repeat :: a -> Infinite a +repeat a = as where as = Inf a as +{-# INLINE [0] repeat #-} + +repeatFB :: (a -> b -> b) -> a -> b +repeatFB c x = xs where xs = c x xs +{-# INLINE [0] repeatFB #-} + +{-# RULES +"repeat" [~1] forall a . repeat a = build \ c -> repeatFB c a +"repeatFB" [1] repeatFB Inf = repeat +#-} + +{- +Note [Fusion for `Infinite` lists] +~~~~~~~~~~~~~~~~~~~~ +We use RULES to support foldr/build fusion for Infinite lists, analogously to the RULES in +GHC.Base to support fusion for regular lists. In particular, we define the following: +• `build :: (forall b . (a -> b -> b) -> b) -> Infinite a` +• `foldr :: (a -> b -> b) -> Infinite a -> b` +• A RULE `foldr f (build g) = g f` +• `Infinite`-producing functions in terms of `build`, and `Infinite`-consuming functions in + terms of `foldr` + +This can work across data types. For example, consider `toList :: Infinite a -> [a]`. +We want 'toList' to be both a good consumer (of 'Infinite' lists) and a good producer (of '[]'). +Ergo, we define it in terms of 'Infinite.foldr' and `List.build`. + +For a bigger example, consider `List.map f (toList (Infinite.map g as))` + +We want to fuse away the intermediate `Infinite` structure between `Infnite.map` and `toList`, +and the list structure between `toList` and `List.map`. And indeed we do: see test +"InfiniteListFusion". +-} ===================================== compiler/GHC/HsToCore/Pmc/Ppr.hs ===================================== @@ -1,6 +1,5 @@ -{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -- | Provides facilities for pretty-printing 'Nabla's in a way appropriate for -- user facing pattern match warnings. @@ -10,6 +9,8 @@ module GHC.HsToCore.Pmc.Ppr ( import GHC.Prelude +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import GHC.Types.Basic import GHC.Types.Id import GHC.Types.Var.Env @@ -101,12 +102,11 @@ prettifyRefuts nabla = listToUDFM_Directly . map attach_refuts . udfmToList attach_refuts (u, (x, sdoc)) = (u, (sdoc, lookupRefuts nabla x)) -type PmPprM a = RWS Nabla () (DIdEnv (Id, SDoc), [SDoc]) a +type PmPprM a = RWS Nabla () (DIdEnv (Id, SDoc), Infinite SDoc) a -- Try nice names p,q,r,s,t before using the (ugly) t_i -nameList :: [SDoc] -nameList = map text ["p","q","r","s","t"] ++ - [ text ('t':show u) | u <- [(0 :: Int)..] ] +nameList :: Infinite SDoc +nameList = map text ["p","q","r","s","t"] Inf.++ flip Inf.unfoldr (0 :: Int) (\ u -> (text ('t':show u), u+1)) runPmPpr :: Nabla -> PmPprM a -> (a, DIdEnv (Id, SDoc)) runPmPpr nabla m = case runRWS m nabla (emptyDVarEnv, nameList) of @@ -117,7 +117,7 @@ runPmPpr nabla m = case runRWS m nabla (emptyDVarEnv, nameList) of getCleanName :: Id -> PmPprM SDoc getCleanName x = do (renamings, name_supply) <- get - let (clean_name:name_supply') = name_supply + let Inf clean_name name_supply' = name_supply case lookupDVarEnv renamings x of Just (_, nm) -> pure nm Nothing -> do ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -31,7 +31,7 @@ import GHC.Data.FastString import GHC.Data.Maybe (catMaybes) import GHC.Hs.Expr (prependQualified, HsExpr(..), LamCaseVariant(..), lamCaseKeyword) import GHC.Hs.Type (pprLHsContext) -import GHC.Builtin.Names (allNameStrings) +import GHC.Builtin.Names (allNameStringList) import GHC.Builtin.Types (filterCTuple) import qualified GHC.LanguageExtensions as LangExt import Data.List.NonEmpty (NonEmpty((:|))) @@ -486,7 +486,7 @@ instance Diagnostic PsMessage where , nest 2 (what <+> tc' - <+> hsep (map text (takeList tparms allNameStrings)) + <+> hsep (map text (takeList tparms allNameStringList)) <+> equals_or_where) ] ] where -- Avoid printing a constraint tuple in the error message. Print ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -173,7 +173,7 @@ normaliseFfiType' env ty0 = runWriterT $ go Representational initRecTc ty0 children_only = do { args <- unzipRedns <$> zipWithM ( \ ty r -> go r rec_nts ty ) - tys (tyConRolesX role tc) + tys (tyConRoleListX role tc) ; return $ mkTyConAppRedn role tc args } nt_co = mkUnbranchedAxInstCo role (newTyConCo tc) tys [] nt_rhs = newTyConInstRhs tc tys ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE MonadComprehensions #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} @@ -125,6 +126,8 @@ import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt import GHC.Data.FastString +import GHC.Data.List.Infinite ( Infinite (..) ) +import qualified GHC.Data.List.Infinite as Inf import GHC.Data.List.SetOps import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -3693,12 +3696,10 @@ splitTyConKind skol_info in_scope avoid_occs kind ; uniqs <- newUniqueSupply ; rdr_env <- getLocalRdrEnv ; lvl <- getTcLevel - ; let new_occs = [ occ - | str <- allNameStrings - , let occ = mkOccName tvName str - , isNothing (lookupLocalRdrOcc rdr_env occ) - -- Note [Avoid name clashes for associated data types] - , not (occ `elem` avoid_occs) ] + ; let new_occs = Inf.filter (\ occ -> + isNothing (lookupLocalRdrOcc rdr_env occ) && + -- Note [Avoid name clashes for associated data types] + not (occ `elem` avoid_occs)) $ mkOccName tvName <$> allNameStrings new_uniqs = uniqsFromSupply uniqs subst = mkEmptySubst in_scope details = SkolemTv skol_info (pushTcLevel lvl) False @@ -3716,8 +3717,8 @@ splitTyConKind skol_info in_scope avoid_occs kind name = mkInternalName uniq occ loc tv = mkTcTyVar name arg' details subst' = extendSubstInScope subst tv - (uniq:uniqs') = uniqs - (occ:occs') = occs + uniq:uniqs' = uniqs + Inf occ occs' = occs Just (Named (Bndr tv vis), kind') -> go occs uniqs subst' (tcb : acc) kind' ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -1914,7 +1914,7 @@ canDecomposableTyConAppOK ev eq_rel tc tys1 tys2 role = eqRelRole eq_rel -- infinite, as tyConRolesX returns an infinite tail of Nominal - tc_roles = tyConRolesX role tc + tc_roles = tyConRoleListX role tc -- Add nuances to the location during decomposition: -- * if the argument is a kind argument, remember this, so that error @@ -3128,7 +3128,7 @@ unifyWanted rewriters loc role orig_ty1 orig_ty2 | tc1 == tc2, tys1 `equalLength` tys2 , isInjectiveTyCon tc1 role -- don't look under newtypes at Rep equality = do { cos <- zipWith3M (unifyWanted rewriters loc) - (tyConRolesX role tc1) tys1 tys2 + (tyConRoleListX role tc1) tys1 tys2 ; return (mkTyConAppCo role tc1 cos) } go ty1@(TyVarTy tv) ty2 ===================================== compiler/GHC/Tc/Solver/Rewrite.hs ===================================== @@ -42,6 +42,8 @@ import Control.Monad import Control.Applicative (liftA3) import GHC.Builtin.Types.Prim (tYPETyCon) import Data.List ( find ) +import GHC.Data.List.Infinite (Infinite) +import qualified GHC.Data.List.Infinite as Inf {- ************************************************************************ @@ -368,7 +370,7 @@ we skip adding to the cache here. {-# INLINE rewrite_args_tc #-} rewrite_args_tc :: TyCon -- T - -> Maybe [Role] -- Nothing: ambient role is Nominal; all args are Nominal + -> Maybe (Infinite Role) -- Nothing: ambient role is Nominal; all args are Nominal -- Otherwise: no assumptions; use roles provided -> [Type] -> RewriteM ArgsReductions -- See the commentary on rewrite_args @@ -392,7 +394,7 @@ rewrite_args_tc tc = rewrite_args all_bndrs any_named_bndrs inner_ki emptyVarSet rewrite_args :: [TyCoBinder] -> Bool -- Binders, and True iff any of them are -- named. -> Kind -> TcTyCoVarSet -- function kind; kind's free vars - -> Maybe [Role] -> [Type] -- these are in 1-to-1 correspondence + -> Maybe (Infinite Role) -> [Type] -- these are in 1-to-1 correspondence -- Nothing: use all Nominal -> RewriteM ArgsReductions -- This function returns ArgsReductions (Reductions cos xis) res_co @@ -413,7 +415,7 @@ rewrite_args orig_binders = case (orig_m_roles, any_named_bndrs) of (Nothing, False) -> rewrite_args_fast orig_tys _ -> rewrite_args_slow orig_binders orig_inner_ki orig_fvs orig_roles orig_tys - where orig_roles = fromMaybe (repeat Nominal) orig_m_roles + where orig_roles = fromMaybe (Inf.repeat Nominal) orig_m_roles {-# INLINE rewrite_args_fast #-} -- | fast path rewrite_args, in which none of the binders are named and @@ -438,10 +440,10 @@ rewrite_args_fast orig_tys -- | Slow path, compared to rewrite_args_fast, because this one must track -- a lifting context. rewrite_args_slow :: [TyCoBinder] -> Kind -> TcTyCoVarSet - -> [Role] -> [Type] + -> Infinite Role -> [Type] -> RewriteM ArgsReductions rewrite_args_slow binders inner_ki fvs roles tys - = do { rewritten_args <- zipWithM rw roles tys + = do { rewritten_args <- zipWithM rw (Inf.toList roles) tys ; return (simplifyArgsWorker binders inner_ki fvs roles rewritten_args) } where {-# INLINE rw #-} @@ -587,7 +589,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys = do { het_redn <- case tcSplitTyConApp_maybe fun_xi of Just (tc, xis) -> do { let tc_roles = tyConRolesRepresentational tc - arg_roles = dropList xis tc_roles + arg_roles = Inf.dropList xis tc_roles ; ArgsReductions (Reductions arg_cos arg_xis) kind_co <- rewrite_vector (tcTypeKind fun_xi) arg_roles arg_tys @@ -608,7 +610,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys ReprEq -> mkAppCos fun_co (map mkNomReflCo arg_tys) `mkTcTransCo` mkTcTyConAppCo Representational tc - (zipWith mkReflCo tc_roles xis ++ arg_cos) + (zipWith mkReflCo (Inf.toList tc_roles) xis ++ arg_cos) ; return $ mkHetReduction @@ -616,7 +618,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys kind_co } Nothing -> do { ArgsReductions redns kind_co - <- rewrite_vector (tcTypeKind fun_xi) (repeat Nominal) arg_tys + <- rewrite_vector (tcTypeKind fun_xi) (Inf.repeat Nominal) arg_tys ; return $ mkHetReduction (mkAppRedns fun_redn redns) kind_co } ; role <- getRole @@ -636,7 +638,7 @@ rewrite_ty_con_app tc tys -- Rewrite a vector (list of arguments). rewrite_vector :: Kind -- of the function being applied to these arguments - -> [Role] -- If we're rewriting w.r.t. ReprEq, what roles do the + -> Infinite Role -- If we're rewriting w.r.t. ReprEq, what roles do the -- args have? -> [Type] -- the args to rewrite -> RewriteM ArgsReductions ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -976,7 +976,7 @@ any_rewritable role tv_pred tc_pred should_expand go_tc NomEq bvs _ tys = any (go NomEq bvs) tys go_tc ReprEq bvs tc tys = any (go_arg bvs) - (tyConRolesRepresentational tc `zip` tys) + (tyConRoleListRepresentational tc `zip` tys) go_arg bvs (Nominal, ty) = go NomEq bvs ty go_arg bvs (Representational, ty) = go ReprEq bvs ty ===================================== compiler/ghc.cabal.in ===================================== @@ -378,6 +378,7 @@ Library GHC.Data.Graph.Ppr GHC.Data.Graph.UnVar GHC.Data.IOEnv + GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== libraries/base/Data/Foldable.hs ===================================== @@ -1175,7 +1175,7 @@ sequence_ = foldr c (return ()) where c m k = m >> k {-# INLINE c #-} --- | The sum of a collection of actions, generalizing 'concat'. +-- | The sum of a collection of actions using '(<|>)', generalizing 'concat'. -- -- 'asum' is just like 'msum', but generalised to 'Alternative'. -- @@ -1189,10 +1189,16 @@ asum :: (Foldable t, Alternative f) => t (f a) -> f a {-# INLINE asum #-} asum = foldr (<|>) empty --- | The sum of a collection of actions, generalizing 'concat'. +-- | The sum of a collection of actions using '(<|>)', generalizing 'concat'. -- -- 'msum' is just like 'asum', but specialised to 'MonadPlus'. -- +-- ==== __Examples__ +-- +-- Basic usage, using the 'MonadPlus' instance for 'Maybe': +-- +-- >>> msum [Just "Hello", Nothing, Just "World"] +-- Just "Hello" msum :: (Foldable t, MonadPlus m) => t (m a) -> m a {-# INLINE msum #-} msum = asum ===================================== libraries/base/GHC/Base.hs ===================================== @@ -599,6 +599,15 @@ class Functor f where -- The default definition is @'fmap' . 'const'@, but this may be -- overridden with a more efficient version. -- + -- ==== __Examples__ + -- + -- Perform a computation with 'Maybe' and replace the result with a + -- constant value if it is 'Just': + -- + -- >>> 'a' <$ Just 2 + -- Just 'a' + -- >>> 'a' <$ Nothing + -- Nothing (<$) :: a -> f b -> f a (<$) = fmap . const @@ -1111,7 +1120,9 @@ class Applicative f => Alternative f where some_v = liftA2 (:) v many_v --- | @since 2.01 +-- | Picks the leftmost 'Just' value, or, alternatively, 'Nothing'. +-- +-- @since 2.01 instance Alternative Maybe where empty = Nothing Nothing <|> r = r @@ -1143,7 +1154,9 @@ class (Alternative m, Monad m) => MonadPlus m where mplus :: m a -> m a -> m a mplus = (<|>) --- | @since 2.01 +-- | Picks the leftmost 'Just' value, or, alternatively, 'Nothing'. +-- +-- @since 2.01 instance MonadPlus Maybe --------------------------------------------- @@ -1205,12 +1218,16 @@ instance Monad [] where {-# INLINE (>>) #-} (>>) = (*>) --- | @since 2.01 +-- | Combines lists by concatenation, starting from the empty list. +-- +-- @since 2.01 instance Alternative [] where empty = [] (<|>) = (++) --- | @since 2.01 +-- | Combines lists by concatenation, starting from the empty list. +-- +-- @since 2.01 instance MonadPlus [] {- @@ -1593,12 +1610,18 @@ instance Monad IO where (>>) = (*>) (>>=) = bindIO --- | @since 4.9.0.0 +-- | Takes the first non-throwing 'IO' action\'s result. +-- 'empty' throws an exception. +-- +-- @since 4.9.0.0 instance Alternative IO where empty = failIO "mzero" (<|>) = mplusIO --- | @since 4.9.0.0 +-- | Takes the first non-throwing 'IO' action\'s result. +-- 'mzero' throws an exception. +-- +-- @since 4.9.0.0 instance MonadPlus IO returnIO :: a -> IO a ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -733,12 +733,16 @@ thenSTM (STM m) k = STM ( \s -> returnSTM :: a -> STM a returnSTM x = STM (\s -> (# s, x #)) --- | @since 4.8.0.0 +-- | Takes the first non-'retry'ing 'STM' action. +-- +-- @since 4.8.0.0 instance Alternative STM where empty = retry (<|>) = orElse --- | @since 4.3.0.0 +-- | Takes the first non-'retry'ing 'STM' action. +-- +-- @since 4.3.0.0 instance MonadPlus STM -- | Unsafely performs IO in the STM monad. Beware: this is a highly ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -87,6 +87,7 @@ GHC.Data.FiniteMap GHC.Data.Graph.Directed GHC.Data.Graph.UnVar GHC.Data.IOEnv +GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -87,6 +87,7 @@ GHC.Data.FiniteMap GHC.Data.Graph.Directed GHC.Data.Graph.UnVar GHC.Data.IOEnv +GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== testsuite/tests/perf/compiler/InfiniteListFusion.hs ===================================== @@ -0,0 +1,9 @@ +module Main where + +import qualified GHC.Data.List.Infinite as Inf + +main :: IO () +main = print $ sum $ take (2^16) $ Inf.toList $ Inf.filter isEven $ Inf.iterate succ (0 :: Int) + +isEven :: Integral a => a -> Bool +isEven n = 0 == mod n 2 ===================================== testsuite/tests/perf/compiler/InfiniteListFusion.stdout ===================================== @@ -0,0 +1 @@ +4294901760 ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -649,4 +649,9 @@ test('T21839c', [ collect_compiler_stats('all', 1), only_ways(['normal'])], compile, - ['-O']) \ No newline at end of file + ['-O']) + +test ('InfiniteListFusion', + [collect_stats('bytes allocated',2), when(arch('i386'), skip)], + compile_and_run, + ['-O2 -package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e730c3c5d20c31477076c36de18be1efd6b1f76f...d9074bc005c39420b9dd2e4c6c2b7d95335c67e8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e730c3c5d20c31477076c36de18be1efd6b1f76f...d9074bc005c39420b9dd2e4c6c2b7d95335c67e8 You're receiving 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 Nov 8 11:01:34 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 08 Nov 2022 06:01:34 -0500 Subject: [Git][ghc/ghc][wip/js-staging] CI take N+2 Message-ID: <636a370e60f0_10da0554a2414598f@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: e3d13211 by Sylvain Henry at 2022-11-08T12:05:08+01:00 CI take N+2 - - - - - 3 changed files: - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/ci.sh ===================================== @@ -597,7 +597,7 @@ function test_hadrian() { if [[ "${CROSS_EMULATOR:-}" == "NOT_SET" ]]; then info "Cannot test cross-compiled build without CROSS_EMULATOR being set." return - elif [[ "${CROSS_EMULATOR:-}" != "NOT_NEEDED" ]]; then + elif [ -n "${CROSS_EMULATOR:-}" ]; then local instdir="$TOP/_build/install" local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" install_bindist _build/bindist/ghc-*/ "$instdir" ===================================== .gitlab/gen_ci.hs ===================================== @@ -652,7 +652,7 @@ job arch opsys buildConfig = (jobName, Job {..}) Nothing -> mempty Just _ -> "CROSS_EMULATOR" =: "NOT_SET" -- we need an emulator but it isn't set. Won't run the testsuite Emulator s -> "CROSS_EMULATOR" =: s - NoEmulatorNeeded -> "CROSS_EMULATOR" =: "NOT_NEEDED" + NoEmulatorNeeded -> mempty , if withNuma buildConfig then "ENABLE_NUMA" =: "1" else mempty ] ===================================== .gitlab/jobs.yaml ===================================== @@ -1384,7 +1384,6 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "NOT_NEEDED", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", "XZ_OPT": "-9" @@ -3928,7 +3927,6 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "NOT_NEEDED", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3d1321184545299a94ad14bff31927b141e90b2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3d1321184545299a94ad14bff31927b141e90b2 You're receiving 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 Nov 8 11:01:45 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 08 Nov 2022 06:01:45 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] CI take N+2 Message-ID: <636a3719c12ed_10da054796c9814612f@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 36d276f8 by Sylvain Henry at 2022-11-08T12:05:27+01:00 CI take N+2 - - - - - 3 changed files: - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml Changes: ===================================== .gitlab/ci.sh ===================================== @@ -597,7 +597,7 @@ function test_hadrian() { if [[ "${CROSS_EMULATOR:-}" == "NOT_SET" ]]; then info "Cannot test cross-compiled build without CROSS_EMULATOR being set." return - elif [[ "${CROSS_EMULATOR:-}" != "NOT_NEEDED" ]]; then + elif [ -n "${CROSS_EMULATOR:-}" ]; then local instdir="$TOP/_build/install" local test_compiler="$instdir/bin/${cross_prefix}ghc$exe" install_bindist _build/bindist/ghc-*/ "$instdir" ===================================== .gitlab/gen_ci.hs ===================================== @@ -652,7 +652,7 @@ job arch opsys buildConfig = (jobName, Job {..}) Nothing -> mempty Just _ -> "CROSS_EMULATOR" =: "NOT_SET" -- we need an emulator but it isn't set. Won't run the testsuite Emulator s -> "CROSS_EMULATOR" =: s - NoEmulatorNeeded -> "CROSS_EMULATOR" =: "NOT_NEEDED" + NoEmulatorNeeded -> mempty , if withNuma buildConfig then "ENABLE_NUMA" =: "1" else mempty ] ===================================== .gitlab/jobs.yaml ===================================== @@ -1384,7 +1384,6 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "NOT_NEEDED", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", "XZ_OPT": "-9" @@ -3928,7 +3927,6 @@ "BUILD_FLAVOUR": "release", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", - "CROSS_EMULATOR": "NOT_NEEDED", "CROSS_TARGET": "js-unknown-ghcjs", "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release" } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36d276f8b40d34a0fca398073033e8642a3f4e55 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/36d276f8b40d34a0fca398073033e8642a3f4e55 You're receiving 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 Nov 8 11:30:40 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 08 Nov 2022 06:30:40 -0500 Subject: [Git][ghc/ghc][wip/js-staging] Take N+3 Message-ID: <636a3de039d7e_10da0554a10151221@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 291ae437 by Sylvain Henry at 2022-11-08T12:34:11+01:00 Take N+3 - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -250,7 +250,7 @@ function setup() { cp -Rf "$CABAL_CACHE"/* "$CABAL_DIR" fi - case $CONFIGURE_WRAPPER in + case "${CONFIGURE_WRAPPER:-}" in emconfigure) time_it "setup" setup_emscripten ;; *) ;; esac @@ -416,7 +416,7 @@ EOF } function configure() { - case $CONFIGURE_WRAPPER in + case "${CONFIGURE_WRAPPER:-}" in emconfigure) source emsdk/emsdk_env.sh ;; *) ;; esac View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/291ae43721c76895f93fc052194dae80eea54585 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/291ae43721c76895f93fc052194dae80eea54585 You're receiving 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 Nov 8 11:31:04 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 08 Nov 2022 06:31:04 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Take N+3 Message-ID: <636a3df884a81_10da0554a241514be@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 46429b72 by Sylvain Henry at 2022-11-08T12:34:47+01:00 Take N+3 - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -250,7 +250,7 @@ function setup() { cp -Rf "$CABAL_CACHE"/* "$CABAL_DIR" fi - case $CONFIGURE_WRAPPER in + case "${CONFIGURE_WRAPPER:-}" in emconfigure) time_it "setup" setup_emscripten ;; *) ;; esac @@ -416,7 +416,7 @@ EOF } function configure() { - case $CONFIGURE_WRAPPER in + case "${CONFIGURE_WRAPPER:-}" in emconfigure) source emsdk/emsdk_env.sh ;; *) ;; esac View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46429b72663df3f7d267b5d350380a80bcc4ec5c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/46429b72663df3f7d267b5d350380a80bcc4ec5c You're receiving 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 Nov 8 12:15:07 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 08 Nov 2022 07:15:07 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <636a484b65d36_10da0554a101651e8@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: f6a8358c by Sebastian Graf at 2022-11-08T13:14:58+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1762,7 +1763,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1772,90 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Here, `unboxed` will have 5 arguments at runtime because of the nested unboxed +tuple, which will be flattened during unarisation to 4 args. So it's best to +leave `(a,b)` boxed (because we already are above our arg threshold), but +unbox `c` through `f` because that doesn't increase the number of args post +unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. Of course, for that to work, our budget calculations +must initialise 'max_wkr_args' to 5, based on the 'unariseArity' of each +Core arg: That would be 1 for the pair and 4 for the unboxed pair. Then when +we decide whether to unbox the unboxed pair, we *directly* recurse into the +fields, spending our budget on retaining `c` and (after recursing once more) `d` +through `f` as arguments, depleting our budget completely in the first layer. +Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1876,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets + +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1899,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1912,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1959,46 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- Unboxed through unboxed sums would be tricky (and we + -- currently don't 'wantToUnboxArg' these). It's impossible + -- to predict the effect of dropping absent fields and + -- unboxing others on the unariseArity of the sum without + -- losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) where - decremented_bg = MkB (bg_top-1) bg_inner + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,19 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False + +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -822,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -839,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -851,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -871,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -883,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -891,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -906,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts -> Var -> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -941,8 +946,8 @@ unbox_one_arg opts arg_var ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co -- See Note [Unboxing through unboxed tuples] ; return $ if isUnboxedTupleDataCon dc && not nested_useful - then (badWorker, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) - else (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1210,7 +1215,7 @@ It's entirely pointless to "unbox" the triple because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. Conclusion: Only consider unboxing an unboxed tuple useful when we will -also unbox its components. That is governed by the `goodWorker` mechanism. +also unbox its components. That is governed by the `usefulSplit` mechanism. ************************************************************************ * * @@ -1393,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1415,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1428,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1458,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1486,8 +1491,8 @@ unbox_one_result opts res_bndr -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,43 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,27 @@ + +==================== Strictness signatures ==================== +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f6a8358c85c5a65688df28bb1596d608891693db -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f6a8358c85c5a65688df28bb1596d608891693db You're receiving 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 Nov 8 12:28:34 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 08 Nov 2022 07:28:34 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <636a4b72eb8b_10da0554a101763a0@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: 5ab91e83 by Sebastian Graf at 2022-11-08T13:28:26+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1762,7 +1763,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1772,91 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Recall that unboxed tuples will be flattened to individual arguments during +unarisation. Here, `unboxed` will have 5 arguments at runtime because of the +nested unboxed tuple, which will be flattened to 4 args. So it's best to leave +`(a,b)` boxed (because we already are above our arg threshold), but unbox `c` +through `f` because that doesn't increase the number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. For example at the top-level, `(# x,y #)` is to be +treated just like two arguments `x` and `y`. +Of course, for that to work, our budget calculations must initialise +'max_wkr_args' to 5, based on the 'unariseArity' of each Core arg: That would be +1 for the pair and 4 for the unboxed pair. Then when we decide whether to unbox +the unboxed pair, we *directly* recurse into the fields, spending our budget +on retaining `c` and (after recursing once more) `d` through `f` as arguments, +depleting our budget completely in the first layer. Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1877,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets + +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1900,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1913,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1960,46 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- Unboxed through unboxed sums would be tricky (and we + -- currently don't 'wantToUnboxArg' these). It's impossible + -- to predict the effect of dropping absent fields and + -- unboxing others on the unariseArity of the sum without + -- losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) where - decremented_bg = MkB (bg_top-1) bg_inner + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,19 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False + +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -822,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -839,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -851,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -871,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -883,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -891,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -906,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts -> Var -> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -941,8 +946,8 @@ unbox_one_arg opts arg_var ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co -- See Note [Unboxing through unboxed tuples] ; return $ if isUnboxedTupleDataCon dc && not nested_useful - then (badWorker, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) - else (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1210,7 +1215,7 @@ It's entirely pointless to "unbox" the triple because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. Conclusion: Only consider unboxing an unboxed tuple useful when we will -also unbox its components. That is governed by the `goodWorker` mechanism. +also unbox its components. That is governed by the `usefulSplit` mechanism. ************************************************************************ * * @@ -1393,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1415,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1428,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1458,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1486,8 +1491,8 @@ unbox_one_result opts res_bndr -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,43 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,27 @@ + +==================== Strictness signatures ==================== +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ab91e836cbe944cf51a3cbaf9d07b0b96d78970 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5ab91e836cbe944cf51a3cbaf9d07b0b96d78970 You're receiving 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 Nov 8 14:53:50 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 09:53:50 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Define `Infinite` list and use where appropriate. Message-ID: <636a6d7e290eb_10da05526ac218317@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: ab0ad7a0 by M Farkas-Dyck at 2022-11-08T09:53:37-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - b8588ec6 by Ross Paterson at 2022-11-08T09:53:40-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - e5069bcf by Jade Lovelace at 2022-11-08T09:53:43-05:00 Clarify msum/asum documentation - - - - - 633cc912 by Jade Lovelace at 2022-11-08T09:53:43-05:00 Add example for (<$) - - - - - dd859669 by Jade Lovelace at 2022-11-08T09:53:43-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/DataCon.hs-boot - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Reduction.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToIface.hs - + compiler/GHC/Data/List/Infinite.hs - compiler/GHC/HsToCore/Pmc/Ppr.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Rewrite.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Types/TyThing.hs - compiler/ghc.cabal.in The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d9074bc005c39420b9dd2e4c6c2b7d95335c67e8...dd859669579a7f1d48f7881c1772df16607562e5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d9074bc005c39420b9dd2e4c6c2b7d95335c67e8...dd859669579a7f1d48f7881c1772df16607562e5 You're receiving 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 Nov 8 15:32:24 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 08 Nov 2022 10:32:24 -0500 Subject: [Git][ghc/ghc][wip/T21623] 37 commits: CI: Allow hadrian-ghc-in-ghci to run in nightlies Message-ID: <636a76886970b_10da055ac8adc2329bb@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 3ad9dfc3 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Start work Not ready for review More progress Wibbles Stage1 compiles More wibbles More wibbles More -- almost working Comments Wibbles Wibbles Wibble inlineId Wibbles Infinite loop somewhere More wibbles. Maybe can build stage2 Make FuNCo a thing by itself Wibble Wibble Wibbles Fix OptCoercion Wibble Wibble to optCoercion Replace SORT with TYPE and CONSTRAINT Wibble Delete unused import Delete TypeOrConstraint from ghc-prim:GHC.Types Move from NthCo to SelCo Wibbles Wibbles in RepType Wibble Add mkWpEta Really add mkWpEta Wibble Typeable binds etc Improve error messages More wibbles, mainly to error messages Wibbles Wibbles to errors Wibbles But especially: treat Constraint as Typeable More wibbles More changes * Move role into SelTyCon * Get rid of mkTcSymCo and friends Unused variable Wibbles Wibble Accept error message changes Refactoring... Remove tc functions like tcKind, tcGetTyVar. Move tyConsOfType, occCheckExpand to TyCo.FVs. Introduce GHC.Core.TyCo.Compare Lots of import changes! Update haddock submodule (I hope) Wibbles (notably: actually add GHC.Core.TyCo.Compare) Wibbles Wibble output of T16575 Wibbles More wibbles Remove infinite loop in T1946 See Note [ForAllTy and type equality] Deal with rejigConRes Needs a Note to be written by Richard Some renaming AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag Update haddock submodule Rename TyCoBinder to ForAllTyBinder Wibbles Update haddock Wibble Update unix submodule I think I accidentally got it out of sync with HEAD; this puts it back. Rename TyCoBinder to PiTyBinder Update Haddock submodule Wrap dictionaries in tuples This fixes the kind bugs in arrow desugaring. Needs some Notes, but I want to try CI. More on boxing data cons Rebase and update GHC.Tc.Errors/GHC.Tc.Errors.Ppr Revert accidental changes in SameOccInfo fixes mod180, tcfail182 Wibbles in error messages ..plus eqType comes from GHC.Core.TyCo.Compare Wibbles More wibbles Reaedy for RAE review Fix fragile rule setup in GHC.Float See Note [realToFrac natural-to-float] Wibbles More wibbles Remove unused import Remove another unused import Wibbles Update haddock submodule Respond to Sam's suggestions Wibbles Wibbles - - - - - d7153729 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Wibbles - - - - - fa1a5b71 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Unused import - - - - - 39566bac by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Better boxingCon_maybe - - - - - 4eb7772c by Richard Eisenberg at 2022-11-08T15:33:50+00:00 Improvements to comments, etc., from Richard - - - - - 9eeba52d by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Respond to Richard - - - - - 0197cf46 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Improve boxing-data-con API - - - - - 9b6ec07a by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Update error messages - - - - - ed38b3aa by Richard Eisenberg at 2022-11-08T15:33:50+00:00 Fix the equality constraint problem - - - - - 74c68aef by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Wibbles - - - - - faf9fc22 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Add isCovertGadtDataCon, fixing build - - - - - c03d6f45 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Wibbles - - - - - 7495d638 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Wibbles - - - - - abe42856 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Move RoughMatch code out of Unify into RoughMatch - - - - - 77b005fb by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Wibble - - - - - c80460c4 by Simon Peyton Jones at 2022-11-08T15:33:50+00:00 Wibbles - - - - - 803b7218 by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Update haddock submodule again - - - - - 9c395bf0 by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Wibbles, esp in RoughMap - - - - - 99ad6f3d by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Upate haddock submodule - - - - - 19be0d96 by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Define eqType using tcEqType A one-line change - - - - - 2b19242e by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Revert "Define eqType using tcEqType" This reverts commit eaf04c17c6a159ddb70eedd6fb8ab0b4fc180b7a. Performance got worse! T18223 was 60% worse T8095 75% T12227 9% T13386 6% T15703 7% T5030 8% - - - - - d0e57145 by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Refactor FunTyFlag Mostly just renaming stuff - - - - - a6700a4b by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Wibbles - - - - - 589e8b72 by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Wibble - - - - - 813ec18a by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Add FunTyFlags to FunCo - - - - - f993a45a by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 More improvements Hopefully perf improves a bit Plus rep-poly/T13105 and rep-poly/T17536b are fixed. - - - - - 56ecd825 by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Add tests for #21530 - - - - - 045ec3ed by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Make the Unique in a TyCon strict This avoids lots of evals when comparing TyCons - - - - - c564cbd6 by Simon Peyton Jones at 2022-11-08T15:33:51+00:00 Improve efficiency in sORTKind_mabye - - - - - 24 changed files: - .gitlab-ci.yml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43ee14d598f1404d92e5ddbbb74ee265aca0733e...c564cbd60c26039277d92dd4484b38acc4b672ba -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43ee14d598f1404d92e5ddbbb74ee265aca0733e...c564cbd60c26039277d92dd4484b38acc4b672ba You're receiving 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 Nov 8 16:27:01 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Tue, 08 Nov 2022 11:27:01 -0500 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] 22 commits: rts: introduce (and use) `STG_NORETURN` Message-ID: <636a835519f28_10da053ed19f0288794@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - f7062d58 by Andreas Klebinger at 2022-11-07T15:51:03+01:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - e3a2867b by Andreas Klebinger at 2022-11-07T16:18:57+01:00 Make mapSumIdBinders take only valid inputs - - - - - 27e4b99e by Andreas Klebinger at 2022-11-08T01:02:45+01:00 Uniques wip - - - - - 35185a3b by Andreas Klebinger at 2022-11-08T17:21:30+01:00 Make sure new vars are unique - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - CODEOWNERS - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.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/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/Iteration.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/4c27146d9485b3b6c4a4630afd3bd8fd2e148ed9...35185a3b87f95378dc07e96e6aef6ee204f99aab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4c27146d9485b3b6c4a4630afd3bd8fd2e148ed9...35185a3b87f95378dc07e96e6aef6ee204f99aab You're receiving 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 Nov 8 17:54:19 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 12:54:19 -0500 Subject: [Git][ghc/ghc][master] Define `Infinite` list and use where appropriate. Message-ID: <636a97cb931d5_10da054796c98329340@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - 21 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Reduction.hs - compiler/GHC/Core/Unify.hs - + compiler/GHC/Data/List/Infinite.hs - compiler/GHC/HsToCore/Pmc/Ppr.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Rewrite.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/ghc.cabal.in - testsuite/tests/count-deps/CountDepsAst.stdout - testsuite/tests/count-deps/CountDepsParser.stdout - + testsuite/tests/perf/compiler/InfiniteListFusion.hs - + testsuite/tests/perf/compiler/InfiniteListFusion.stdout - testsuite/tests/perf/compiler/all.T Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -119,7 +119,6 @@ in GHC.Builtin.Types. -} {-# LANGUAGE CPP #-} -{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} module GHC.Builtin.Names ( Unique, Uniquable(..), hasKey, -- Re-exported for convenience @@ -143,6 +142,8 @@ import GHC.Builtin.Uniques import GHC.Types.Name import GHC.Types.SrcLoc import GHC.Data.FastString +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import Language.Haskell.Syntax.Module.Name @@ -154,9 +155,13 @@ import Language.Haskell.Syntax.Module.Name ************************************************************************ -} -allNameStrings :: [String] +allNameStrings :: Infinite String -- Infinite list of a,b,c...z, aa, ab, ac, ... etc -allNameStrings = [ c:cs | cs <- "" : allNameStrings, c <- ['a'..'z'] ] +allNameStrings = Inf.allListsOf ['a'..'z'] + +allNameStringList :: [String] +-- Infinite list of a,b,c...z, aa, ab, ac, ... etc +allNameStringList = Inf.toList allNameStrings {- ************************************************************************ ===================================== compiler/GHC/Core/Coercion.hs ===================================== @@ -63,6 +63,7 @@ module GHC.Core.Coercion ( splitForAllCo_ty_maybe, splitForAllCo_co_maybe, nthRole, tyConRolesX, tyConRolesRepresentational, setNominalRole_maybe, + tyConRoleListX, tyConRoleListRepresentational, pickLR, @@ -154,6 +155,8 @@ import GHC.Builtin.Types.Prim import GHC.Data.List.SetOps import GHC.Data.Maybe import GHC.Types.Unique.FM +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import GHC.Utils.Misc import GHC.Utils.Outputable @@ -408,12 +411,10 @@ where co_rep1, co_rep2 are the coercions on the representations. -- -- > decomposeCo 3 c [r1, r2, r3] = [nth r1 0 c, nth r2 1 c, nth r3 2 c] decomposeCo :: Arity -> Coercion - -> [Role] -- the roles of the output coercions - -- this must have at least as many - -- entries as the Arity provided + -> Infinite Role -- the roles of the output coercions -> [Coercion] decomposeCo arity co rs - = [mkNthCo r n co | (n,r) <- [0..(arity-1)] `zip` rs ] + = [mkNthCo r n co | (n,r) <- [0..(arity-1)] `zip` Inf.toList rs ] -- Remember, Nth is zero-indexed decomposeFunCo :: HasDebugCallStack @@ -533,7 +534,7 @@ splitTyConAppCo_maybe :: Coercion -> Maybe (TyCon, [Coercion]) splitTyConAppCo_maybe co | Just (ty, r) <- isReflCo_maybe co = do { (tc, tys) <- splitTyConApp_maybe ty - ; let args = zipWith mkReflCo (tyConRolesX r tc) tys + ; let args = zipWith mkReflCo (tyConRoleListX r tc) tys ; return (tc, args) } splitTyConAppCo_maybe (TyConAppCo _ tc cos) = Just (tc, cos) splitTyConAppCo_maybe (FunCo _ w arg res) = Just (funTyCon, cos) @@ -819,15 +820,14 @@ mkAppCo co arg -- Expand type synonyms; a TyConAppCo can't have a type synonym (#9102) = mkTyConAppCo r tc (zip_roles (tyConRolesX r tc) tys) where - zip_roles (r1:_) [] = [downgradeRole r1 Nominal arg] - zip_roles (r1:rs) (ty1:tys) = mkReflCo r1 ty1 : zip_roles rs tys - zip_roles _ _ = panic "zip_roles" -- but the roles are infinite... + zip_roles (Inf r1 _) [] = [downgradeRole r1 Nominal arg] + zip_roles (Inf r1 rs) (ty1:tys) = mkReflCo r1 ty1 : zip_roles rs tys mkAppCo (TyConAppCo r tc args) arg = case r of Nominal -> mkTyConAppCo Nominal tc (args ++ [arg]) Representational -> mkTyConAppCo Representational tc (args ++ [arg']) - where new_role = (tyConRolesRepresentational tc) !! (length args) + where new_role = tyConRolesRepresentational tc Inf.!! length args arg' = downgradeRole new_role Nominal arg Phantom -> mkTyConAppCo Phantom tc (args ++ [toPhantomCo arg]) mkAppCo co arg = AppCo co arg @@ -1153,10 +1153,7 @@ mkNthCo r n co , tc1 == tc2 = let len1 = length tys1 len2 = length tys2 - good_role = case coercionRole co of - Nominal -> r == Nominal - Representational -> r == (tyConRolesRepresentational tc1 !! n) - Phantom -> r == Phantom + good_role = r == nthRole (coercionRole co) tc1 n in len1 == len2 && n < len1 && good_role | otherwise @@ -1349,7 +1346,7 @@ setNominalRole_maybe r co setNominalRole_maybe_helper co@(Refl _) = Just co setNominalRole_maybe_helper (GRefl _ ty co) = Just $ GRefl Nominal ty co setNominalRole_maybe_helper (TyConAppCo Representational tc cos) - = do { cos' <- zipWithM setNominalRole_maybe (tyConRolesX Representational tc) cos + = do { cos' <- zipWithM setNominalRole_maybe (tyConRoleListX Representational tc) cos ; return $ TyConAppCo Nominal tc cos' } setNominalRole_maybe_helper (FunCo Representational w co1 co2) = do { co1' <- setNominalRole_maybe Representational co1 @@ -1393,27 +1390,33 @@ toPhantomCo co -- Convert args to a TyConAppCo Nominal to the same TyConAppCo Representational applyRoles :: TyCon -> [Coercion] -> [Coercion] -applyRoles tc cos - = zipWith (\r -> downgradeRole r Nominal) (tyConRolesRepresentational tc) cos +applyRoles = zipWith (`downgradeRole` Nominal) . tyConRoleListRepresentational -- the Role parameter is the Role of the TyConAppCo -- defined here because this is intimately concerned with the implementation -- of TyConAppCo -- Always returns an infinite list (with a infinite tail of Nominal) -tyConRolesX :: Role -> TyCon -> [Role] +tyConRolesX :: Role -> TyCon -> Infinite Role tyConRolesX Representational tc = tyConRolesRepresentational tc -tyConRolesX role _ = repeat role +tyConRolesX role _ = Inf.repeat role + +tyConRoleListX :: Role -> TyCon -> [Role] +tyConRoleListX role = Inf.toList . tyConRolesX role + +-- Returns the roles of the parameters of a tycon, with an infinite tail +-- of Nominal +tyConRolesRepresentational :: TyCon -> Infinite Role +tyConRolesRepresentational tc = tyConRoles tc Inf.++ Inf.repeat Nominal -- Returns the roles of the parameters of a tycon, with an infinite tail -- of Nominal -tyConRolesRepresentational :: TyCon -> [Role] -tyConRolesRepresentational tc = tyConRoles tc ++ repeat Nominal +tyConRoleListRepresentational :: TyCon -> [Role] +tyConRoleListRepresentational = Inf.toList . tyConRolesRepresentational nthRole :: Role -> TyCon -> Int -> Role nthRole Nominal _ _ = Nominal nthRole Phantom _ _ = Phantom -nthRole Representational tc n - = (tyConRolesRepresentational tc) `getNth` n +nthRole Representational tc n = tyConRolesRepresentational tc Inf.!! n ltRole :: Role -> Role -> Bool -- Is one role "less" than another? @@ -2034,7 +2037,7 @@ ty_co_subst !lc role ty go r (TyVarTy tv) = expectJust "ty_co_subst bad roles" $ liftCoSubstTyVar lc r tv go r (AppTy ty1 ty2) = mkAppCo (go r ty1) (go Nominal ty2) - go r (TyConApp tc tys) = mkTyConAppCo r tc (zipWith go (tyConRolesX r tc) tys) + go r (TyConApp tc tys) = mkTyConAppCo r tc (zipWith go (tyConRoleListX r tc) tys) go r (FunTy _ w ty1 ty2) = mkFunCo r (go Nominal w) (go r ty1) (go r ty2) go r t@(ForAllTy (Bndr v _) ty) = let (lc', v', h) = liftCoSubstVarBndr lc v ===================================== compiler/GHC/Core/Coercion/Opt.hs ===================================== @@ -245,7 +245,7 @@ opt_co4 env sym rep r g@(TyConAppCo _r tc cos) (True, Nominal) -> mkTyConAppCo Representational tc (zipWith3 (opt_co3 env sym) - (map Just (tyConRolesRepresentational tc)) + (map Just (tyConRoleListRepresentational tc)) (repeat Nominal) cos) (False, Nominal) -> @@ -254,7 +254,7 @@ opt_co4 env sym rep r g@(TyConAppCo _r tc cos) -- must use opt_co2 here, because some roles may be P -- See Note [Optimising coercion optimisation] mkTyConAppCo r tc (zipWith (opt_co2 env sym) - (tyConRolesRepresentational tc) -- the current roles + (tyConRoleListRepresentational tc) -- the current roles cos) (_, Phantom) -> pprPanic "opt_co4 sees a phantom!" (ppr g) @@ -546,7 +546,7 @@ opt_univ env sym prov role oty1 oty2 , equalLength tys1 tys2 -- see Note [Differing kinds] -- NB: prov must not be the two interesting ones (ProofIrrel & Phantom); -- Phantom is already taken care of, and ProofIrrel doesn't relate tyconapps - = let roles = tyConRolesX role tc1 + = let roles = tyConRoleListX role tc1 arg_cos = zipWith3 (mkUnivCo prov') roles tys1 tys2 arg_cos' = zipWith (opt_co4 env sym False) roles arg_cos in ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -63,6 +63,8 @@ import GHC.Utils.Outputable import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Data.Bag +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf {- ************************************************************************ @@ -1477,7 +1479,7 @@ normalise_type ty Nothing -> do { ArgsReductions redns res_co <- normalise_args (typeKind nfun) - (repeat Nominal) + (Inf.repeat Nominal) arg_tys ; role <- getRole ; return $ @@ -1486,7 +1488,7 @@ normalise_type ty (mkSymMCo res_co) } } normalise_args :: Kind -- of the function - -> [Role] -- roles at which to normalise args + -> Infinite Role -- roles at which to normalise args -> [Type] -- args -> NormM ArgsReductions -- returns ArgsReductions (Reductions cos xis) res_co, @@ -1496,7 +1498,7 @@ normalise_args :: Kind -- of the function -- but the resulting application *will* be well-kinded -- cf. GHC.Tc.Solver.Rewrite.rewrite_args_slow normalise_args fun_ki roles args - = do { normed_args <- zipWithM normalise1 roles args + = do { normed_args <- zipWithM normalise1 (Inf.toList roles) args ; return $ simplifyArgsWorker ki_binders inner_ki fvs roles normed_args } where (ki_binders, inner_ki) = splitPiTys fun_ki ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -2177,7 +2177,7 @@ lintCoercion co@(TyConAppCo r tc cos) ; let (co_kinds, co_roles) = unzip (map coercionKindRole cos') ; lint_co_app co (tyConKind tc) (map pFst co_kinds) ; lint_co_app co (tyConKind tc) (map pSnd co_kinds) - ; zipWithM_ (lintRole co) (tyConRolesX r tc) co_roles + ; zipWithM_ (lintRole co) (tyConRoleListX r tc) co_roles ; return (TyConAppCo r tc cos') } lintCoercion co@(AppCo co1 co2) ===================================== compiler/GHC/Core/Reduction.hs ===================================== @@ -35,6 +35,8 @@ import GHC.Core.TyCon ( TyCon ) import GHC.Core.Type import GHC.Data.Pair ( Pair(Pair) ) +import GHC.Data.List.Infinite ( Infinite (..) ) +import qualified GHC.Data.List.Infinite as Inf import GHC.Types.Var ( setTyVarKind ) import GHC.Types.Var.Env ( mkInScopeSet ) @@ -42,7 +44,7 @@ import GHC.Types.Var.Set ( TyCoVarSet ) import GHC.Utils.Misc ( HasDebugCallStack, equalLength ) import GHC.Utils.Outputable -import GHC.Utils.Panic ( assertPpr, panic ) +import GHC.Utils.Panic ( assertPpr ) {- %************************************************************************ @@ -788,7 +790,7 @@ simplifyArgsWorker :: HasDebugCallStack -- the binders & result kind (not a Π-type) of the function applied to the args -- list of binders can be shorter or longer than the list of args -> TyCoVarSet -- free vars of the args - -> [Role] -- list of roles, r + -> Infinite Role-- list of roles, r -> [Reduction] -- rewritten type arguments, arg_i -- each comes with the coercion used to rewrite it, -- arg_co_i :: ty_i ~ arg_i @@ -809,11 +811,11 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs where orig_lc = emptyLiftingContext $ mkInScopeSet orig_fvs - go :: LiftingContext -- mapping from tyvars to rewriting coercions - -> [TyCoBinder] -- Unsubsted binders of function's kind - -> Kind -- Unsubsted result kind of function (not a Pi-type) - -> [Role] -- Roles at which to rewrite these ... - -> [Reduction] -- rewritten arguments, with their rewriting coercions + go :: LiftingContext -- mapping from tyvars to rewriting coercions + -> [TyCoBinder] -- Unsubsted binders of function's kind + -> Kind -- Unsubsted result kind of function (not a Pi-type) + -> Infinite Role -- Roles at which to rewrite these ... + -> [Reduction] -- rewritten arguments, with their rewriting coercions -> ArgsReductions go !lc binders inner_ki _ [] -- The !lc makes the function strict in the lifting context @@ -826,7 +828,7 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs kind_co | noFreeVarsOfType final_kind = MRefl | otherwise = MCo $ liftCoSubst Nominal lc final_kind - go lc (binder:binders) inner_ki (role:roles) (arg_redn:arg_redns) + go lc (binder:binders) inner_ki (Inf role roles) (arg_redn:arg_redns) = -- We rewrite an argument ty with arg_redn = Reduction arg_co arg -- By Note [Rewriting] in GHC.Tc.Solver.Rewrite invariant (F2), -- tcTypeKind(ty) = tcTypeKind(arg). @@ -859,7 +861,7 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs (arg_cos, res_co) = decomposePiCos co1 co1_kind unrewritten_tys casted_args = assertPpr (equalLength arg_redns arg_cos) (ppr arg_redns $$ ppr arg_cos) - $ zipWith3 mkCoherenceRightRedn roles arg_redns arg_cos + $ zipWith3 mkCoherenceRightRedn (Inf.toList roles) arg_redns arg_cos -- In general decomposePiCos can return fewer cos than tys, -- but not here; because we're well typed, there will be enough -- binders. Note that decomposePiCos does substitutions, so even @@ -874,19 +876,3 @@ simplifyArgsWorker orig_ki_binders orig_inner_ki orig_fvs = go zapped_lc bndrs new_inner roles casted_args in ArgsReductions redns_out (res_co `mkTransMCoR` res_co_out) - - go _ _ _ _ _ = panic - "simplifyArgsWorker wandered into deeper water than usual" - -- This debug information is commented out because leaving it in - -- causes a ~2% increase in allocations in T9872d. - -- That's independent of the analogous case in rewrite_args_fast - -- in GHC.Tc.Solver.Rewrite: - -- each of these causes a 2% increase on its own, so commenting them - -- both out gives a 4% decrease in T9872d. - {- - - (vcat [ppr orig_binders, - ppr orig_inner_ki, - ppr (take 10 orig_roles), -- often infinite! - ppr orig_tys]) - -} ===================================== compiler/GHC/Core/Unify.hs ===================================== @@ -1742,7 +1742,7 @@ pushRefl co = -> Just (TyConAppCo r funTyCon [ multToCo w, mkReflCo r rep1, mkReflCo r rep2 , mkReflCo r ty1, mkReflCo r ty2 ]) Just (TyConApp tc tys, r) - -> Just (TyConAppCo r tc (zipWith mkReflCo (tyConRolesX r tc) tys)) + -> Just (TyConAppCo r tc (zipWith mkReflCo (tyConRoleListX r tc) tys)) Just (ForAllTy (Bndr tv _) ty, r) -> Just (ForAllCo tv (mkNomReflCo (varType tv)) (mkReflCo r ty)) -- NB: NoRefl variant. Otherwise, we get a loop! ===================================== compiler/GHC/Data/List/Infinite.hs ===================================== @@ -0,0 +1,194 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE RankNTypes #-} + +module GHC.Data.List.Infinite + ( Infinite (..) + , head, tail + , filter + , (++) + , unfoldr + , (!!) + , groupBy + , dropList + , iterate + , concatMap + , allListsOf + , toList + , repeat + ) where + +import Prelude ((-), Applicative (..), Bool (..), Foldable, Functor (..), Int, Maybe (..), Traversable (..), flip, otherwise) +import Control.Category (Category (..)) +import Control.Monad (guard) +import qualified Data.Foldable as F +import Data.List.NonEmpty (NonEmpty (..)) +import qualified GHC.Base as List (build) + +data Infinite a = Inf a (Infinite a) + deriving (Foldable, Functor, Traversable) + +head :: Infinite a -> a +head (Inf a _) = a +{-# NOINLINE [1] head #-} + +tail :: Infinite a -> Infinite a +tail (Inf _ as) = as +{-# NOINLINE [1] tail #-} + +{-# RULES +"head/build" forall (g :: forall b . (a -> b -> b) -> b) . head (build g) = g \ x _ -> x +#-} + +instance Applicative Infinite where + pure = repeat + Inf f fs <*> Inf a as = Inf (f a) (fs <*> as) + +mapMaybe :: (a -> Maybe b) -> Infinite a -> Infinite b +mapMaybe f = go + where + go (Inf a as) = let bs = go as in case f a of + Nothing -> bs + Just b -> Inf b bs +{-# NOINLINE [1] mapMaybe #-} + +{-# RULES +"mapMaybe" [~1] forall f as . mapMaybe f as = build \ c -> foldr (mapMaybeFB c f) as +"mapMaybeList" [1] forall f . foldr (mapMaybeFB Inf f) = mapMaybe f + #-} + +{-# INLINE [0] mapMaybeFB #-} +mapMaybeFB :: (b -> r -> r) -> (a -> Maybe b) -> a -> r -> r +mapMaybeFB cons f a bs = case f a of + Nothing -> bs + Just r -> cons r bs + +filter :: (a -> Bool) -> Infinite a -> Infinite a +filter f = mapMaybe (\ a -> a <$ guard (f a)) +{-# INLINE filter #-} + +infixr 5 ++ +(++) :: Foldable f => f a -> Infinite a -> Infinite a +(++) = flip (F.foldr Inf) + +unfoldr :: (b -> (a, b)) -> b -> Infinite a +unfoldr f b = build \ c -> let go b = case f b of (a, b') -> a `c` go b' in go b +{-# INLINE unfoldr #-} + +(!!) :: Infinite a -> Int -> a +Inf a _ !! 0 = a +Inf _ as !! n = as !! (n-1) + +groupBy :: (a -> a -> Bool) -> Infinite a -> Infinite (NonEmpty a) +groupBy eq = go + where + go (Inf a as) = Inf (a:|bs) (go cs) + where (bs, cs) = span (eq a) as + +span :: (a -> Bool) -> Infinite a -> ([a], Infinite a) +span p = spanJust (\ a -> a <$ guard (p a)) +{-# INLINE span #-} + +spanJust :: (a -> Maybe b) -> Infinite a -> ([b], Infinite a) +spanJust p = go + where + go as@(Inf a as') + | Just b <- p a = let (bs, cs) = go as' in (b:bs, cs) + | otherwise = ([], as) + +iterate :: (a -> a) -> a -> Infinite a +iterate f = go where go a = Inf a (go (f a)) +{-# NOINLINE [1] iterate #-} + +{-# RULES +"iterate" [~1] forall f a . iterate f a = build (\ c -> iterateFB c f a) +"iterateFB" [1] iterateFB Inf = iterate +#-} + +iterateFB :: (a -> b -> b) -> (a -> a) -> a -> b +iterateFB c f a = go a + where go a = a `c` go (f a) +{-# INLINE [0] iterateFB #-} + +concatMap :: Foldable f => (a -> f b) -> Infinite a -> Infinite b +concatMap f = go where go (Inf a as) = f a ++ go as +{-# NOINLINE [1] concatMap #-} + +{-# RULES "concatMap" forall f as . concatMap f as = build \ c -> foldr (\ x b -> F.foldr c b (f x)) as #-} + +{-# SPECIALIZE concatMap :: (a -> [b]) -> Infinite a -> Infinite b #-} + +foldr :: (a -> b -> b) -> Infinite a -> b +foldr f = go where go (Inf a as) = f a (go as) +{-# INLINE [0] foldr #-} + +build :: (forall b . (a -> b -> b) -> b) -> Infinite a +build g = g Inf +{-# INLINE [1] build #-} + +-- Analogous to 'foldr'/'build' fusion for '[]' +{-# RULES +"foldr/build" forall f (g :: forall b . (a -> b -> b) -> b) . foldr f (build g) = g f +"foldr/id" foldr Inf = id + +"foldr/cons/build" forall f a (g :: forall b . (a -> b -> b) -> b) . foldr f (Inf a (build g)) = f a (g f) +#-} + +{-# RULES +"map" [~1] forall f (as :: Infinite a) . fmap f as = build \ c -> foldr (mapFB c f) as +"mapFB" forall c f g . mapFB (mapFB c f) g = mapFB c (f . g) +"mapFB/id" forall c . mapFB c (\ x -> x) = c +#-} + +mapFB :: (b -> c -> c) -> (a -> b) -> a -> c -> c +mapFB c f = \ x ys -> c (f x) ys +{-# INLINE [0] mapFB #-} + +dropList :: [a] -> Infinite b -> Infinite b +dropList [] bs = bs +dropList (_:as) (Inf _ bs) = dropList as bs + +-- | Compute all lists of the given alphabet. +-- For example: @'allListsOf' "ab" = ["a", "b", "aa", "ba", "ab", "bb", "aaa", "baa", "aba", ...]@ +allListsOf :: [a] -> Infinite [a] +allListsOf as = concatMap (\ bs -> [a:bs | a <- as]) ([] `Inf` allListsOf as) + +-- See Note [Fusion for `Infinite` lists]. +toList :: Infinite a -> [a] +toList = \ as -> List.build (\ c _ -> foldr c as) +{-# INLINE toList #-} + +repeat :: a -> Infinite a +repeat a = as where as = Inf a as +{-# INLINE [0] repeat #-} + +repeatFB :: (a -> b -> b) -> a -> b +repeatFB c x = xs where xs = c x xs +{-# INLINE [0] repeatFB #-} + +{-# RULES +"repeat" [~1] forall a . repeat a = build \ c -> repeatFB c a +"repeatFB" [1] repeatFB Inf = repeat +#-} + +{- +Note [Fusion for `Infinite` lists] +~~~~~~~~~~~~~~~~~~~~ +We use RULES to support foldr/build fusion for Infinite lists, analogously to the RULES in +GHC.Base to support fusion for regular lists. In particular, we define the following: +• `build :: (forall b . (a -> b -> b) -> b) -> Infinite a` +• `foldr :: (a -> b -> b) -> Infinite a -> b` +• A RULE `foldr f (build g) = g f` +• `Infinite`-producing functions in terms of `build`, and `Infinite`-consuming functions in + terms of `foldr` + +This can work across data types. For example, consider `toList :: Infinite a -> [a]`. +We want 'toList' to be both a good consumer (of 'Infinite' lists) and a good producer (of '[]'). +Ergo, we define it in terms of 'Infinite.foldr' and `List.build`. + +For a bigger example, consider `List.map f (toList (Infinite.map g as))` + +We want to fuse away the intermediate `Infinite` structure between `Infnite.map` and `toList`, +and the list structure between `toList` and `List.map`. And indeed we do: see test +"InfiniteListFusion". +-} ===================================== compiler/GHC/HsToCore/Pmc/Ppr.hs ===================================== @@ -1,6 +1,5 @@ -{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} -- | Provides facilities for pretty-printing 'Nabla's in a way appropriate for -- user facing pattern match warnings. @@ -10,6 +9,8 @@ module GHC.HsToCore.Pmc.Ppr ( import GHC.Prelude +import GHC.Data.List.Infinite (Infinite (..)) +import qualified GHC.Data.List.Infinite as Inf import GHC.Types.Basic import GHC.Types.Id import GHC.Types.Var.Env @@ -101,12 +102,11 @@ prettifyRefuts nabla = listToUDFM_Directly . map attach_refuts . udfmToList attach_refuts (u, (x, sdoc)) = (u, (sdoc, lookupRefuts nabla x)) -type PmPprM a = RWS Nabla () (DIdEnv (Id, SDoc), [SDoc]) a +type PmPprM a = RWS Nabla () (DIdEnv (Id, SDoc), Infinite SDoc) a -- Try nice names p,q,r,s,t before using the (ugly) t_i -nameList :: [SDoc] -nameList = map text ["p","q","r","s","t"] ++ - [ text ('t':show u) | u <- [(0 :: Int)..] ] +nameList :: Infinite SDoc +nameList = map text ["p","q","r","s","t"] Inf.++ flip Inf.unfoldr (0 :: Int) (\ u -> (text ('t':show u), u+1)) runPmPpr :: Nabla -> PmPprM a -> (a, DIdEnv (Id, SDoc)) runPmPpr nabla m = case runRWS m nabla (emptyDVarEnv, nameList) of @@ -117,7 +117,7 @@ runPmPpr nabla m = case runRWS m nabla (emptyDVarEnv, nameList) of getCleanName :: Id -> PmPprM SDoc getCleanName x = do (renamings, name_supply) <- get - let (clean_name:name_supply') = name_supply + let Inf clean_name name_supply' = name_supply case lookupDVarEnv renamings x of Just (_, nm) -> pure nm Nothing -> do ===================================== compiler/GHC/Parser/Errors/Ppr.hs ===================================== @@ -31,7 +31,7 @@ import GHC.Data.FastString import GHC.Data.Maybe (catMaybes) import GHC.Hs.Expr (prependQualified, HsExpr(..), LamCaseVariant(..), lamCaseKeyword) import GHC.Hs.Type (pprLHsContext) -import GHC.Builtin.Names (allNameStrings) +import GHC.Builtin.Names (allNameStringList) import GHC.Builtin.Types (filterCTuple) import qualified GHC.LanguageExtensions as LangExt import Data.List.NonEmpty (NonEmpty((:|))) @@ -486,7 +486,7 @@ instance Diagnostic PsMessage where , nest 2 (what <+> tc' - <+> hsep (map text (takeList tparms allNameStrings)) + <+> hsep (map text (takeList tparms allNameStringList)) <+> equals_or_where) ] ] where -- Avoid printing a constraint tuple in the error message. Print ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -173,7 +173,7 @@ normaliseFfiType' env ty0 = runWriterT $ go Representational initRecTc ty0 children_only = do { args <- unzipRedns <$> zipWithM ( \ ty r -> go r rec_nts ty ) - tys (tyConRolesX role tc) + tys (tyConRoleListX role tc) ; return $ mkTyConAppRedn role tc args } nt_co = mkUnbranchedAxInstCo role (newTyConCo tc) tys [] nt_rhs = newTyConInstRhs tc tys ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1,5 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE MonadComprehensions #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} @@ -125,6 +126,8 @@ import GHC.Driver.Session import qualified GHC.LanguageExtensions as LangExt import GHC.Data.FastString +import GHC.Data.List.Infinite ( Infinite (..) ) +import qualified GHC.Data.List.Infinite as Inf import GHC.Data.List.SetOps import GHC.Data.Maybe import GHC.Data.Bag( unitBag ) @@ -3693,12 +3696,10 @@ splitTyConKind skol_info in_scope avoid_occs kind ; uniqs <- newUniqueSupply ; rdr_env <- getLocalRdrEnv ; lvl <- getTcLevel - ; let new_occs = [ occ - | str <- allNameStrings - , let occ = mkOccName tvName str - , isNothing (lookupLocalRdrOcc rdr_env occ) - -- Note [Avoid name clashes for associated data types] - , not (occ `elem` avoid_occs) ] + ; let new_occs = Inf.filter (\ occ -> + isNothing (lookupLocalRdrOcc rdr_env occ) && + -- Note [Avoid name clashes for associated data types] + not (occ `elem` avoid_occs)) $ mkOccName tvName <$> allNameStrings new_uniqs = uniqsFromSupply uniqs subst = mkEmptySubst in_scope details = SkolemTv skol_info (pushTcLevel lvl) False @@ -3716,8 +3717,8 @@ splitTyConKind skol_info in_scope avoid_occs kind name = mkInternalName uniq occ loc tv = mkTcTyVar name arg' details subst' = extendSubstInScope subst tv - (uniq:uniqs') = uniqs - (occ:occs') = occs + uniq:uniqs' = uniqs + Inf occ occs' = occs Just (Named (Bndr tv vis), kind') -> go occs uniqs subst' (tcb : acc) kind' ===================================== compiler/GHC/Tc/Solver/Canonical.hs ===================================== @@ -1914,7 +1914,7 @@ canDecomposableTyConAppOK ev eq_rel tc tys1 tys2 role = eqRelRole eq_rel -- infinite, as tyConRolesX returns an infinite tail of Nominal - tc_roles = tyConRolesX role tc + tc_roles = tyConRoleListX role tc -- Add nuances to the location during decomposition: -- * if the argument is a kind argument, remember this, so that error @@ -3128,7 +3128,7 @@ unifyWanted rewriters loc role orig_ty1 orig_ty2 | tc1 == tc2, tys1 `equalLength` tys2 , isInjectiveTyCon tc1 role -- don't look under newtypes at Rep equality = do { cos <- zipWith3M (unifyWanted rewriters loc) - (tyConRolesX role tc1) tys1 tys2 + (tyConRoleListX role tc1) tys1 tys2 ; return (mkTyConAppCo role tc1 cos) } go ty1@(TyVarTy tv) ty2 ===================================== compiler/GHC/Tc/Solver/Rewrite.hs ===================================== @@ -42,6 +42,8 @@ import Control.Monad import Control.Applicative (liftA3) import GHC.Builtin.Types.Prim (tYPETyCon) import Data.List ( find ) +import GHC.Data.List.Infinite (Infinite) +import qualified GHC.Data.List.Infinite as Inf {- ************************************************************************ @@ -368,7 +370,7 @@ we skip adding to the cache here. {-# INLINE rewrite_args_tc #-} rewrite_args_tc :: TyCon -- T - -> Maybe [Role] -- Nothing: ambient role is Nominal; all args are Nominal + -> Maybe (Infinite Role) -- Nothing: ambient role is Nominal; all args are Nominal -- Otherwise: no assumptions; use roles provided -> [Type] -> RewriteM ArgsReductions -- See the commentary on rewrite_args @@ -392,7 +394,7 @@ rewrite_args_tc tc = rewrite_args all_bndrs any_named_bndrs inner_ki emptyVarSet rewrite_args :: [TyCoBinder] -> Bool -- Binders, and True iff any of them are -- named. -> Kind -> TcTyCoVarSet -- function kind; kind's free vars - -> Maybe [Role] -> [Type] -- these are in 1-to-1 correspondence + -> Maybe (Infinite Role) -> [Type] -- these are in 1-to-1 correspondence -- Nothing: use all Nominal -> RewriteM ArgsReductions -- This function returns ArgsReductions (Reductions cos xis) res_co @@ -413,7 +415,7 @@ rewrite_args orig_binders = case (orig_m_roles, any_named_bndrs) of (Nothing, False) -> rewrite_args_fast orig_tys _ -> rewrite_args_slow orig_binders orig_inner_ki orig_fvs orig_roles orig_tys - where orig_roles = fromMaybe (repeat Nominal) orig_m_roles + where orig_roles = fromMaybe (Inf.repeat Nominal) orig_m_roles {-# INLINE rewrite_args_fast #-} -- | fast path rewrite_args, in which none of the binders are named and @@ -438,10 +440,10 @@ rewrite_args_fast orig_tys -- | Slow path, compared to rewrite_args_fast, because this one must track -- a lifting context. rewrite_args_slow :: [TyCoBinder] -> Kind -> TcTyCoVarSet - -> [Role] -> [Type] + -> Infinite Role -> [Type] -> RewriteM ArgsReductions rewrite_args_slow binders inner_ki fvs roles tys - = do { rewritten_args <- zipWithM rw roles tys + = do { rewritten_args <- zipWithM rw (Inf.toList roles) tys ; return (simplifyArgsWorker binders inner_ki fvs roles rewritten_args) } where {-# INLINE rw #-} @@ -587,7 +589,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys = do { het_redn <- case tcSplitTyConApp_maybe fun_xi of Just (tc, xis) -> do { let tc_roles = tyConRolesRepresentational tc - arg_roles = dropList xis tc_roles + arg_roles = Inf.dropList xis tc_roles ; ArgsReductions (Reductions arg_cos arg_xis) kind_co <- rewrite_vector (tcTypeKind fun_xi) arg_roles arg_tys @@ -608,7 +610,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys ReprEq -> mkAppCos fun_co (map mkNomReflCo arg_tys) `mkTcTransCo` mkTcTyConAppCo Representational tc - (zipWith mkReflCo tc_roles xis ++ arg_cos) + (zipWith mkReflCo (Inf.toList tc_roles) xis ++ arg_cos) ; return $ mkHetReduction @@ -616,7 +618,7 @@ rewrite_app_ty_args fun_redn@(Reduction fun_co fun_xi) arg_tys kind_co } Nothing -> do { ArgsReductions redns kind_co - <- rewrite_vector (tcTypeKind fun_xi) (repeat Nominal) arg_tys + <- rewrite_vector (tcTypeKind fun_xi) (Inf.repeat Nominal) arg_tys ; return $ mkHetReduction (mkAppRedns fun_redn redns) kind_co } ; role <- getRole @@ -636,7 +638,7 @@ rewrite_ty_con_app tc tys -- Rewrite a vector (list of arguments). rewrite_vector :: Kind -- of the function being applied to these arguments - -> [Role] -- If we're rewriting w.r.t. ReprEq, what roles do the + -> Infinite Role -- If we're rewriting w.r.t. ReprEq, what roles do the -- args have? -> [Type] -- the args to rewrite -> RewriteM ArgsReductions ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -976,7 +976,7 @@ any_rewritable role tv_pred tc_pred should_expand go_tc NomEq bvs _ tys = any (go NomEq bvs) tys go_tc ReprEq bvs tc tys = any (go_arg bvs) - (tyConRolesRepresentational tc `zip` tys) + (tyConRoleListRepresentational tc `zip` tys) go_arg bvs (Nominal, ty) = go NomEq bvs ty go_arg bvs (Representational, ty) = go ReprEq bvs ty ===================================== compiler/ghc.cabal.in ===================================== @@ -378,6 +378,7 @@ Library GHC.Data.Graph.Ppr GHC.Data.Graph.UnVar GHC.Data.IOEnv + GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== testsuite/tests/count-deps/CountDepsAst.stdout ===================================== @@ -87,6 +87,7 @@ GHC.Data.FiniteMap GHC.Data.Graph.Directed GHC.Data.Graph.UnVar GHC.Data.IOEnv +GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== testsuite/tests/count-deps/CountDepsParser.stdout ===================================== @@ -87,6 +87,7 @@ GHC.Data.FiniteMap GHC.Data.Graph.Directed GHC.Data.Graph.UnVar GHC.Data.IOEnv +GHC.Data.List.Infinite GHC.Data.List.SetOps GHC.Data.Maybe GHC.Data.OrdList ===================================== testsuite/tests/perf/compiler/InfiniteListFusion.hs ===================================== @@ -0,0 +1,9 @@ +module Main where + +import qualified GHC.Data.List.Infinite as Inf + +main :: IO () +main = print $ sum $ take (2^16) $ Inf.toList $ Inf.filter isEven $ Inf.iterate succ (0 :: Int) + +isEven :: Integral a => a -> Bool +isEven n = 0 == mod n 2 ===================================== testsuite/tests/perf/compiler/InfiniteListFusion.stdout ===================================== @@ -0,0 +1 @@ +4294901760 ===================================== testsuite/tests/perf/compiler/all.T ===================================== @@ -649,4 +649,9 @@ test('T21839c', [ collect_compiler_stats('all', 1), only_ways(['normal'])], compile, - ['-O']) \ No newline at end of file + ['-O']) + +test ('InfiniteListFusion', + [collect_stats('bytes allocated',2), when(arch('i386'), skip)], + compile_and_run, + ['-O2 -package ghc']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68f49874aa217c2222c80c596ef11ffd992b459a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/68f49874aa217c2222c80c596ef11ffd992b459a You're receiving 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 Nov 8 17:55:07 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 12:55:07 -0500 Subject: [Git][ghc/ghc][master] Fix TypeData issues (fixes #22315 and #22332) Message-ID: <636a97fb541b8_10da055ac8adc33704@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 28 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/DataCon.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/TyThing.hs - + testsuite/tests/type-data/should_compile/T22315a/Lib.hs - + testsuite/tests/type-data/should_compile/T22315a/Main.hs - + testsuite/tests/type-data/should_compile/TDGADT.hs - testsuite/tests/type-data/should_compile/all.T - + testsuite/tests/type-data/should_fail/T22332b.hs - + testsuite/tests/type-data/should_fail/T22332b.stderr - testsuite/tests/type-data/should_fail/all.T - + testsuite/tests/type-data/should_run/Makefile - + testsuite/tests/type-data/should_run/T22315b.hs - + testsuite/tests/type-data/should_run/T22315b.script - + testsuite/tests/type-data/should_run/T22315b.stdout - + testsuite/tests/type-data/should_run/T22332a.hs - + testsuite/tests/type-data/should_run/T22332a.stderr - + testsuite/tests/type-data/should_run/all.T Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -1638,7 +1638,7 @@ isNewDataCon dc = isNewTyCon (dataConTyCon dc) -- | Is this data constructor in a "type data" declaration? -- See Note [Type data declarations] in GHC.Rename.Module. isTypeDataCon :: DataCon -> Bool -isTypeDataCon dc = isTcClsNameSpace (nameNameSpace (getName dc)) +isTypeDataCon dc = isTypeDataTyCon (dataConTyCon dc) -- | Should this DataCon be allowed in a type even without -XDataKinds? -- Currently, only Lifted & Unlifted ===================================== compiler/GHC/Core/DataCon.hs-boot ===================================== @@ -27,6 +27,7 @@ dataConStupidTheta :: DataCon -> ThetaType dataConFullSig :: DataCon -> ([TyVar], [TyCoVar], [EqSpec], ThetaType, [Scaled Type], Type) isUnboxedSumDataCon :: DataCon -> Bool +isTypeDataCon :: DataCon -> Bool instance Eq DataCon instance Uniquable DataCon ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -56,10 +56,12 @@ module GHC.Core.TyCon( isTypeSynonymTyCon, mustBeSaturated, isPromotedDataCon, isPromotedDataCon_maybe, + isDataKindsPromotedDataCon, isKindTyCon, isLiftedTypeKindTyConName, isTauTyCon, isFamFreeTyCon, isForgetfulSynTyCon, isDataTyCon, + isTypeDataTyCon, isEnumerationTyCon, isNewTyCon, isAbstractTyCon, isFamilyTyCon, isOpenFamilyTyCon, @@ -147,7 +149,7 @@ import {-# SOURCE #-} GHC.Builtin.Types import {-# SOURCE #-} GHC.Core.DataCon ( DataCon, dataConFieldLabels , dataConTyCon, dataConFullSig - , isUnboxedSumDataCon ) + , isUnboxedSumDataCon, isTypeDataCon ) import {-# SOURCE #-} GHC.Core.Type ( isLiftedTypeKind ) import GHC.Builtin.Uniques @@ -1138,6 +1140,9 @@ data AlgTyConRhs -- ^ Cached value: length data_cons is_enum :: Bool, -- ^ Cached value: is this an enumeration type? -- See Note [Enumeration types] + is_type_data :: Bool, + -- from a "type data" declaration + -- See Note [Type data declarations] in GHC.Rename.Module data_fixed_lev :: Bool -- ^ 'True' if the data type constructor has -- a known, fixed levity when fully applied @@ -1218,14 +1223,18 @@ mkSumTyConRhs data_cons = SumTyCon data_cons (length data_cons) -- | Create an 'AlgTyConRhs' from the data constructors, -- for a potentially levity-polymorphic datatype (with `UnliftedDatatypes`). mkLevPolyDataTyConRhs :: Bool -- ^ whether the 'DataCon' has a fixed levity + -> Bool -- ^ True if this is a "type data" declaration + -- See Note [Type data declarations] + -- in GHC.Rename.Module -> [DataCon] -> AlgTyConRhs -mkLevPolyDataTyConRhs fixed_lev cons +mkLevPolyDataTyConRhs fixed_lev type_data cons = DataTyCon { data_cons = cons, data_cons_size = length cons, is_enum = not (null cons) && all is_enum_con cons, -- See Note [Enumeration types] in GHC.Core.TyCon + is_type_data = type_data, data_fixed_lev = fixed_lev } where @@ -1236,9 +1245,10 @@ mkLevPolyDataTyConRhs fixed_lev cons -- | Create an 'AlgTyConRhs' from the data constructors. -- --- Use 'mkLevPolyDataConRhs' if the datatype can be levity-polymorphic. +-- Use 'mkLevPolyDataConRhs' if the datatype can be levity-polymorphic +-- or if it comes from a "data type" declaration mkDataTyConRhs :: [DataCon] -> AlgTyConRhs -mkDataTyConRhs = mkLevPolyDataTyConRhs True +mkDataTyConRhs = mkLevPolyDataTyConRhs True False -- | Some promoted datacons signify extra info relevant to GHC. For example, -- the @IntRep@ constructor of @RuntimeRep@ corresponds to the 'IntRep' @@ -2133,11 +2143,21 @@ isDataTyCon (AlgTyCon {algTcRhs = rhs}) TupleTyCon { tup_sort = sort } -> isBoxed (tupleSortBoxity sort) SumTyCon {} -> False - DataTyCon {} -> True + -- Constructors from "type data" declarations exist only at + -- the type level. + -- See Note [Type data declarations] in GHC.Rename.Module. + DataTyCon { is_type_data = type_data } -> not type_data NewTyCon {} -> False AbstractTyCon {} -> False -- We don't know, so return False isDataTyCon _ = False +-- | Was this 'TyCon' declared as "type data"? +-- See Note [Type data declarations] in GHC.Rename.Module. +isTypeDataTyCon :: TyCon -> Bool +isTypeDataTyCon (AlgTyCon {algTcRhs = DataTyCon {is_type_data = type_data }}) + = type_data +isTypeDataTyCon _ = False + -- | 'isInjectiveTyCon' is true of 'TyCon's for which this property holds -- (where X is the role passed in): -- If (T a1 b1 c1) ~X (T a2 b2 c2), then (a1 ~X1 a2), (b1 ~X2 b2), and (c1 ~X3 c2) @@ -2385,6 +2405,19 @@ isPromotedDataCon :: TyCon -> Bool isPromotedDataCon (PromotedDataCon {}) = True isPromotedDataCon _ = False +-- | This function identifies PromotedDataCon's from data constructors in +-- `data T = K1 | K2`, promoted by -XDataKinds. These type constructors +-- are printed with a tick mark 'K1 and 'K2, and similarly have a tick +-- mark added to their OccName's. +-- +-- In contrast, constructors in `type data T = K1 | K2` are printed and +-- represented with their original undecorated names. +-- See Note [Type data declarations] in GHC.Rename.Module +isDataKindsPromotedDataCon :: TyCon -> Bool +isDataKindsPromotedDataCon (PromotedDataCon { dataCon = dc }) + = not (isTypeDataCon dc) +isDataKindsPromotedDataCon _ = False + -- | Retrieves the promoted DataCon if this is a PromotedDataCon; isPromotedDataCon_maybe :: TyCon -> Maybe DataCon isPromotedDataCon_maybe (PromotedDataCon { dataCon = dc }) = Just dc @@ -2921,9 +2954,10 @@ tcFlavourIsOpen TypeSynonymFlavour = False pprPromotionQuote :: TyCon -> SDoc -- Promoted data constructors already have a tick in their OccName pprPromotionQuote tc - = case tc of - PromotedDataCon {} -> char '\'' -- Always quote promoted DataCons in types - _ -> empty + -- Always quote promoted DataCons in types, unless they come + -- from "type data" declarations. + | isDataKindsPromotedDataCon tc = char '\'' + | otherwise = empty instance NamedThing TyCon where getName = tyConName ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -230,7 +230,7 @@ toIfaceTyCon tc where tc_name = tyConName tc info = mkIfaceTyConInfo promoted sort - promoted | isPromotedDataCon tc = IsPromoted + promoted | isDataKindsPromotedDataCon tc = IsPromoted | otherwise = NotPromoted tupleSort :: TyCon -> Maybe IfaceTyConSort ===================================== compiler/GHC/Iface/Make.hs ===================================== @@ -550,7 +550,7 @@ tyConToIfaceDecl env tycon ifCType = Nothing, ifRoles = tyConRoles tycon, ifCtxt = [], - ifCons = IfDataTyCon [], + ifCons = IfDataTyCon False [], ifGadtSyntax = False, ifParent = IfNoParent }) where @@ -584,9 +584,10 @@ tyConToIfaceDecl env tycon axn = coAxiomName ax ifaceConDecls (NewTyCon { data_con = con }) = IfNewTyCon (ifaceConDecl con) - ifaceConDecls (DataTyCon { data_cons = cons }) = IfDataTyCon (map ifaceConDecl cons) - ifaceConDecls (TupleTyCon { data_con = con }) = IfDataTyCon [ifaceConDecl con] - ifaceConDecls (SumTyCon { data_cons = cons }) = IfDataTyCon (map ifaceConDecl cons) + ifaceConDecls (DataTyCon { data_cons = cons, is_type_data = type_data }) + = IfDataTyCon type_data (map ifaceConDecl cons) + ifaceConDecls (TupleTyCon { data_con = con }) = IfDataTyCon False [ifaceConDecl con] + ifaceConDecls (SumTyCon { data_cons = cons }) = IfDataTyCon False (map ifaceConDecl cons) ifaceConDecls AbstractTyCon = IfAbstractTyCon -- The AbstractTyCon case happens when a TyCon has been trimmed -- during tidying. ===================================== compiler/GHC/Iface/Rename.hs ===================================== @@ -543,8 +543,8 @@ rnIfaceTyConParent (IfDataInstance n tc args) rnIfaceTyConParent IfNoParent = pure IfNoParent rnIfaceConDecls :: Rename IfaceConDecls -rnIfaceConDecls (IfDataTyCon ds) - = IfDataTyCon <$> mapM rnIfaceConDecl ds +rnIfaceConDecls (IfDataTyCon type_data ds) + = IfDataTyCon type_data <$> mapM rnIfaceConDecl ds rnIfaceConDecls (IfNewTyCon d) = IfNewTyCon <$> rnIfaceConDecl d rnIfaceConDecls IfAbstractTyCon = pure IfAbstractTyCon ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -236,7 +236,9 @@ data IfaceAxBranch = IfaceAxBranch { ifaxbTyVars :: [IfaceTvBndr] data IfaceConDecls = IfAbstractTyCon -- c.f TyCon.AbstractTyCon - | IfDataTyCon [IfaceConDecl] -- Data type decls + | IfDataTyCon !Bool [IfaceConDecl] -- Data type decls + -- The Bool is True for "type data" declarations. + -- see Note [Type data declarations] in GHC.Rename.Module | IfNewTyCon IfaceConDecl -- Newtype decls -- For IfDataTyCon and IfNewTyCon we store: @@ -450,7 +452,7 @@ See [https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/recompilation- visibleIfConDecls :: IfaceConDecls -> [IfaceConDecl] visibleIfConDecls (IfAbstractTyCon {}) = [] -visibleIfConDecls (IfDataTyCon cs) = cs +visibleIfConDecls (IfDataTyCon _ cs) = cs visibleIfConDecls (IfNewTyCon c) = [c] ifaceDeclImplicitBndrs :: IfaceDecl -> [OccName] @@ -459,18 +461,23 @@ ifaceDeclImplicitBndrs :: IfaceDecl -> [OccName] -- especially the question of whether there's a wrapper for a datacon -- See Note [Implicit TyThings] in GHC.Driver.Env --- N.B. the set of names returned here *must* match the set of --- TyThings returned by GHC.Driver.Env.implicitTyThings, in the sense that +-- N.B. the set of names returned here *must* match the set of TyThings +-- returned by GHC.Types.TyThing.implicitTyThings, in the sense that -- TyThing.getOccName should define a bijection between the two lists. --- This invariant is used in GHC.IfaceToCore.tc_iface_decl_fingerprint (see note --- [Tricky iface loop]) +-- This invariant is used in GHC.IfaceToCore.tc_iface_decl_fingerprint +-- (see Note [Tricky iface loop] in GHC.Types.TyThing.) -- The order of the list does not matter. ifaceDeclImplicitBndrs (IfaceData {ifName = tc_name, ifCons = cons }) = case cons of IfAbstractTyCon {} -> [] IfNewTyCon cd -> mkNewTyCoOcc (occName tc_name) : ifaceConDeclImplicitBndrs cd - IfDataTyCon cds -> concatMap ifaceConDeclImplicitBndrs cds + IfDataTyCon type_data cds + | type_data -> + -- Constructors in "type data" declarations have no implicits. + -- see Note [Type data declarations] in GHC.Rename.Module + [occName con_name | IfCon { ifConName = con_name } <- cds] + | otherwise -> concatMap ifaceConDeclImplicitBndrs cds ifaceDeclImplicitBndrs (IfaceClass { ifBody = IfAbstractClass }) = [] @@ -907,6 +914,7 @@ pprIfaceDecl ss (IfaceData { ifName = tycon, ifCType = ctype, pp_nd = case condecls of IfAbstractTyCon{} -> text "data" + IfDataTyCon True _ -> text "type data" IfDataTyCon{} -> text "data" IfNewTyCon{} -> text "newtype" @@ -1633,8 +1641,8 @@ freeNamesDM (Just (GenericDM ty)) = freeNamesIfType ty freeNamesDM _ = emptyNameSet freeNamesIfConDecls :: IfaceConDecls -> NameSet -freeNamesIfConDecls (IfDataTyCon c) = fnList freeNamesIfConDecl c -freeNamesIfConDecls (IfNewTyCon c) = freeNamesIfConDecl c +freeNamesIfConDecls (IfDataTyCon _ cs) = fnList freeNamesIfConDecl cs +freeNamesIfConDecls (IfNewTyCon c) = freeNamesIfConDecl c freeNamesIfConDecls _ = emptyNameSet freeNamesIfConDecl :: IfaceConDecl -> NameSet @@ -2118,14 +2126,16 @@ instance Binary IfaceAxBranch where instance Binary IfaceConDecls where put_ bh IfAbstractTyCon = putByte bh 0 - put_ bh (IfDataTyCon cs) = putByte bh 1 >> put_ bh cs - put_ bh (IfNewTyCon c) = putByte bh 2 >> put_ bh c + put_ bh (IfDataTyCon False cs) = putByte bh 1 >> put_ bh cs + put_ bh (IfDataTyCon True cs) = putByte bh 2 >> put_ bh cs + put_ bh (IfNewTyCon c) = putByte bh 3 >> put_ bh c get bh = do h <- getByte bh case h of 0 -> return IfAbstractTyCon - 1 -> liftM IfDataTyCon (get bh) - 2 -> liftM IfNewTyCon (get bh) + 1 -> liftM (IfDataTyCon False) (get bh) + 2 -> liftM (IfDataTyCon True) (get bh) + 3 -> liftM IfNewTyCon (get bh) _ -> error "Binary(IfaceConDecls).get: Invalid IfaceConDecls" instance Binary IfaceConDecl where @@ -2624,7 +2634,7 @@ instance NFData IfaceTyConParent where instance NFData IfaceConDecls where rnf = \case IfAbstractTyCon -> () - IfDataTyCon f1 -> rnf f1 + IfDataTyCon _ f1 -> rnf f1 IfNewTyCon f1 -> rnf f1 instance NFData IfaceConDecl where ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -352,9 +352,13 @@ for the purposes of pretty-printing. See Note [The equality types story] in GHC.Builtin.Types.Prim. -} -data IfaceTyConInfo -- Used to guide pretty-printing - -- and to disambiguate D from 'D (they share a name) +data IfaceTyConInfo -- Used only to guide pretty-printing = IfaceTyConInfo { ifaceTyConIsPromoted :: PromotionFlag + -- A PromotionFlag value of IsPromoted indicates + -- that the type constructor came from a data + -- constructor promoted by -XDataKinds, and thus + -- should be printed as 'D to distinguish it from + -- an existing type constructor D. , ifaceTyConSort :: IfaceTyConSort } deriving (Eq) ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -338,7 +338,7 @@ d1 `withRolesFrom` d2 mergeRoles roles1 roles2 = zipWithEqual "mergeRoles" max roles1 roles2 isRepInjectiveIfaceDecl :: IfaceDecl -> Bool -isRepInjectiveIfaceDecl IfaceData{ ifCons = IfDataTyCon _ } = True +isRepInjectiveIfaceDecl IfaceData{ ifCons = IfDataTyCon{} } = True isRepInjectiveIfaceDecl IfaceFamily{ ifFamFlav = IfaceDataFamilyTyCon } = True isRepInjectiveIfaceDecl _ = False @@ -1083,11 +1083,12 @@ tcIfaceDataCons tycon_name tycon tc_tybinders if_cons = case if_cons of IfAbstractTyCon -> return AbstractTyCon - IfDataTyCon cons + IfDataTyCon type_data cons -> do { data_cons <- mapM tc_con_decl cons ; return $ mkLevPolyDataTyConRhs (isFixedRuntimeRepKind $ tyConResKind tycon) + type_data data_cons } IfNewTyCon con -> do { data_con <- tc_con_decl con @@ -1957,11 +1958,12 @@ tcIfaceGlobal name -- this expression *after* typechecking T. tcIfaceTyCon :: IfaceTyCon -> IfL TyCon -tcIfaceTyCon (IfaceTyCon name info) +tcIfaceTyCon (IfaceTyCon name _info) = do { thing <- tcIfaceGlobal name - ; return $ case ifaceTyConIsPromoted info of - NotPromoted -> tyThingTyCon thing - IsPromoted -> promoteDataCon $ tyThingDataCon thing } + ; case thing of + ATyCon tc -> return tc + AConLike (RealDataCon dc) -> return (promoteDataCon dc) + _ -> pprPanic "tcIfaceTyCon" (ppr thing) } tcIfaceCoAxiom :: Name -> IfL (CoAxiom Branched) tcIfaceCoAxiom name = do { thing <- tcIfaceImplicit name ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2036,7 +2036,7 @@ rnDataDefn doc (HsDataDefn { dd_cType = cType, dd_ctxt = context, dd_cons = cond {- Note [Type data declarations] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -With the TypeData extension (GHC proposal #106), one can write "type data" +With the TypeData extension (GHC proposal #106), one can write `type data` declarations, like type data Nat = Zero | Succ Nat @@ -2047,17 +2047,18 @@ or equivalently in GADT style: Zero :: Nat Succ :: Nat -> Nat -This defines the constructors Zero and Succ in the TcCls namespace +This defines the constructors `Zero` and `Succ` in the TcCls namespace (type constructors and classes) instead of the Data namespace (data -constructors). This contrasts with the DataKinds extension, which allows -constructors defined in the Data namespace to be promoted to the TcCls -namespace at the point of use in a type. +constructors). This contrasts with the DataKinds extension, which +allows constructors defined in the Data namespace to be promoted to the +TcCls namespace at the point of use in a type. -Type data declarations have the syntax of data declarations, either -ordinary algebraic data types or GADTs, preceded by "type", with the -following restrictions: +Type data declarations have the syntax of `data` declarations (but not +`newtype` declarations), either ordinary algebraic data types or GADTs, +preceded by `type`, with the following restrictions: -(R1) There are data type contexts (even with the DatatypeContexts extension). +(R1) There are no data type contexts (even with the DatatypeContexts + extension). (R2) There are no labelled fields. Perhaps these could be supported using type families, but they are omitted for now. @@ -2078,14 +2079,15 @@ following restrictions: The main parts of the implementation are: -* The Bool argument to DataTypeCons (in Language.Haskell.Syntax.Decls) - distinguishes "type data" declarations from ordinary "data" declarations. +* The parser recognizes `type data` (but not `type newtype`). -* This flag is set, and the constructor names placed in the - TcCls namespace, during the initial construction of the AST in - GHC.Parser.PostProcess.checkNewOrData. +* During the initial construction of the AST, + GHC.Parser.PostProcess.checkNewOrData sets the `Bool` argument of the + `DataTypeCons` inside a `HsDataDefn` to mark a `type data` declaration. + It also puts the the constructor names (`Zero` and `Succ` in our + example) in the TcCls namespace. -* GHC.Rename.Module.rnDataDefn calls check_type_data on these +* GHC.Rename.Module.rnDataDefn calls `check_type_data` on these declarations, which checks that the TypeData extension is enabled and checks restrictions (R1), (R2), (R3) and (R5). They could equally well be checked in the typechecker, but we err on the side of catching @@ -2094,19 +2096,40 @@ The main parts of the implementation are: * GHC.Tc.TyCl.checkValidDataCon checks restriction (R4) on these declarations. * When beginning to type check a mutually recursive group of declarations, - the "type data" constructors are added to the type-checker environment - as APromotionErr TyConPE by GHC.Tc.TyCl.mkPromotionErrorEnv, so they - cannot be used within the recursive group. This mirrors the DataKinds - behaviour described at Note [Recursion and promoting data constructors] - in GHC.Tc.TyCl. For example, this is rejected: - - type data T f = K (f (K Int)) - -* After a "type data" declaration has been type-checked, the type-checker - environment entry for each constructor (which can be recognized - by being in the TcCls namespace) is just the promoted type - constructor, not the bundle required for a data constructor. - (GHC.Types.TyThing.implicitTyConThings) + the `type data` constructors (`Zero` and `Succ` in our example) are + added to the type-checker environment as `APromotionErr TyConPE` by + GHC.Tc.TyCl.mkPromotionErrorEnv, so they cannot be used within the + recursive group. This mirrors the DataKinds behaviour described + at Note [Recursion and promoting data constructors] in GHC.Tc.TyCl. + For example, this is rejected: + + type data T f = K (f (K Int)) -- illegal: tycon K is recursively defined + +* The `type data` data type, such as `Nat` in our example, is represented + by a `TyCon` that is an `AlgTyCon`, but its `AlgTyConRhs` has the + `is_type_data` field set. + +* The constructors of the data type, `Zero` and `Succ` in our example, + are each represented by a `DataCon` as usual. That `DataCon`'s + `dcPromotedField` is a `TyCon` (for `Zero`, say) that you can use + in a type. + +* After a `type data` declaration has been type-checked, the type-checker + environment entry for each constructor (`Zero` and `Succ` in our + example) is just the promoted type constructor, not the bundle required + for a data constructor. (GHC.Types.TyThing.implicitTyConThings) + +* GHC.Core.TyCon.isDataKindsPromotedDataCon ignores promoted constructors + from `type data`, which do not use the distinguishing quote mark added + to constructors promoted by DataKinds. + +* GHC.Core.TyCon.isDataTyCon ignores types coming from a `type data` + declaration (by checking the `is_type_data` field), so that these do + not contribute executable code such as constructor wrappers. + +* The `is_type_data` field is copied into a Boolean argument + of the `IfDataTyCon` constructor of `IfaceConDecls` by + GHC.Iface.Make.tyConToIfaceDecl. -} ===================================== compiler/GHC/Tc/Instance/Typeable.hs ===================================== @@ -649,7 +649,7 @@ mkTyConRepTyConRHS (Stuff {..}) todo tycon kind_rep where n_kind_vars = length $ filter isNamedTyConBinder (tyConBinders tycon) tycon_str = add_tick (occNameString (getOccName tycon)) - add_tick s | isPromotedDataCon tycon = '\'' : s + add_tick s | isDataKindsPromotedDataCon tycon = '\'' : s | otherwise = s -- This must match the computation done in ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -2981,9 +2981,10 @@ tcDataDefn err_ctxt roles_info tc_name = return AbstractTyCon mk_tc_rhs _ tycon data_cons = case data_cons of - DataTypeCons _ data_cons -> return $ + DataTypeCons is_type_data data_cons -> return $ mkLevPolyDataTyConRhs (isFixedRuntimeRepKind (tyConResKind tycon)) + is_type_data data_cons NewTypeCon data_con -> mkNewTyConRhs tc_name tycon data_con ===================================== compiler/GHC/Tc/TyCl/Instance.hs ===================================== @@ -772,9 +772,10 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env ; rep_tc_name <- newFamInstTyConName lfam_name pats ; axiom_name <- newFamInstAxiomName lfam_name [pats] ; tc_rhs <- case data_cons of - DataTypeCons _ data_cons -> return $ + DataTypeCons type_data data_cons -> return $ mkLevPolyDataTyConRhs (isFixedRuntimeRepKind res_kind) + type_data data_cons NewTypeCon data_con -> mkNewTyConRhs rep_tc_name rec_rep_tc data_con ===================================== compiler/GHC/Types/TyThing.hs ===================================== @@ -184,7 +184,7 @@ implicitTyConThings tc -- for each data constructor in order, -- the constructor and associated implicit 'Id's - concatMap datacon_stuff (tyConDataCons tc) + datacon_stuff -- NB. record selectors are *not* implicit, they have fully-fledged -- bindings that pass through the compilation pipeline as normal. where @@ -192,16 +192,22 @@ implicitTyConThings tc Nothing -> [] Just cl -> implicitClassThings cl - -- For each data constructor, + -- For each data constructor in order, -- the constructor, worker, and (possibly) wrapper -- -- If the data constructor is in a "type data" declaration, -- promote it to the type level now. -- See Note [Type data declarations] in GHC.Rename.Module. - datacon_stuff dc - | isTypeDataCon dc = [ATyCon (promoteDataCon dc)] + datacon_stuff :: [TyThing] + datacon_stuff + | isTypeDataTyCon tc = [ATyCon (promoteDataCon dc) | dc <- cons] | otherwise - = AConLike (RealDataCon dc) : dataConImplicitTyThings dc + = [ty_thing | dc <- cons, + ty_thing <- AConLike (RealDataCon dc) : + dataConImplicitTyThings dc] + + cons :: [DataCon] + cons = tyConDataCons tc -- For newtypes and closed type families (only) add the implicit coercion tycon implicitCoTyCon :: TyCon -> [TyThing] ===================================== testsuite/tests/type-data/should_compile/T22315a/Lib.hs ===================================== @@ -0,0 +1,12 @@ +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE DataKinds, TypeData #-} +module T22315a.Lib where + +data TermLevel = Mk +type data TypeLevel = Mk + +class C (a :: TypeLevel) +instance C Mk where + +foo :: C a => proxy a -> () +foo _ = () ===================================== testsuite/tests/type-data/should_compile/T22315a/Main.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE NoImplicitPrelude #-} +module T22315a.Main where + +import T22315a.Lib + +data Proxy (a :: TypeLevel) + +bar :: Proxy Mk -> () +bar = foo ===================================== testsuite/tests/type-data/should_compile/TDGADT.hs ===================================== @@ -0,0 +1,13 @@ +{-# LANGUAGE TypeData #-} +module TDGADT where + +import Data.Kind (Type) + +type data Nat = Zero | Succ Nat + +-- type level GADT +type data Vec :: Nat -> Type -> Type where + VNil :: Vec Zero a + VCons :: a -> Vec n a -> Vec (Succ n) a + +type X = VCons Bool (VCons Int VNil) ===================================== testsuite/tests/type-data/should_compile/all.T ===================================== @@ -1,4 +1,6 @@ test('TDDataConstructor', normal, compile, ['']) test('TDExistential', normal, compile, ['']) +test('TDGADT', normal, compile, ['']) test('TDGoodConsConstraints', normal, compile, ['']) test('TDVector', normal, compile, ['']) +test('T22315a', [extra_files(['T22315a/'])], multimod_compile, ['T22315a.Lib T22315a.Main', '-v0']) ===================================== testsuite/tests/type-data/should_fail/T22332b.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TypeData, DataKinds #-} +module T22332b where + +type data X1 = T +data X2 = T +data Proxy a + +f :: Proxy T +f = f :: Proxy 'T ===================================== testsuite/tests/type-data/should_fail/T22332b.stderr ===================================== @@ -0,0 +1,7 @@ + +T22332b.hs:9:5: error: [GHC-83865] + • Couldn't match type ‘T’ with ‘'T’ + Expected: Proxy 'T + Actual: Proxy T + • In the expression: f :: Proxy 'T + In an equation for ‘f’: f = f :: Proxy 'T ===================================== testsuite/tests/type-data/should_fail/all.T ===================================== @@ -11,3 +11,4 @@ test('TDRecordsH98', normal, compile_fail, ['']) test('TDRecursive', normal, compile_fail, ['']) test('TDStrictnessGADT', normal, compile_fail, ['']) test('TDStrictnessH98', normal, compile_fail, ['']) +test('T22332b', normal, compile_fail, ['']) ===================================== testsuite/tests/type-data/should_run/Makefile ===================================== @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk ===================================== testsuite/tests/type-data/should_run/T22315b.hs ===================================== @@ -0,0 +1,9 @@ +{-# LANGUAGE TypeData #-} +module T22315b where + +data TermLevel = Mk +type data TypeLevel = Mk + +mk = Mk + +type Mk2 = Mk ===================================== testsuite/tests/type-data/should_run/T22315b.script ===================================== @@ -0,0 +1,5 @@ +:load T22315b.hs +:type Mk +:kind Mk +:type mk +:kind Mk2 ===================================== testsuite/tests/type-data/should_run/T22315b.stdout ===================================== @@ -0,0 +1,4 @@ +Mk :: TermLevel +Mk :: TypeLevel +mk :: TermLevel +Mk2 :: TypeLevel ===================================== testsuite/tests/type-data/should_run/T22332a.hs ===================================== @@ -0,0 +1,27 @@ +{-# LANGUAGE TypeData, DataKinds, TypeFamilies #-} +module Main where + +import Type.Reflection +import Data.Type.Equality + +data Proxy a +type data X1 = T -- defines type constructor T +data X2 = T -- defines type constructor 'T + +data family F p + +newtype instance F (Proxy T) = ID (forall a. a -> a) +newtype instance F (Proxy 'T) = UC (forall a b. a -> b) + +-- This should fail at runtime because these are different types +eq :: T :~~: 'T +Just eq = eqTypeRep typeRep typeRep + +p :: a :~~: b -> F (Proxy a) :~: F (Proxy b) +p HRefl = Refl + +uc :: a -> b +uc = case castWith (p eq) (ID id) of UC a -> a + +main :: IO () +main = print (uc 'a' :: Int) ===================================== testsuite/tests/type-data/should_run/T22332a.stderr ===================================== @@ -0,0 +1 @@ +T22332a: T22332a.hs:18:1-35: Non-exhaustive patterns in Just eq ===================================== testsuite/tests/type-data/should_run/all.T ===================================== @@ -0,0 +1,2 @@ +test('T22332a', exit_code(1), compile_and_run, ['']) +test('T22315b', extra_files(['T22315b.hs']), ghci_script, ['T22315b.script']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce726cd2a3182006999c57eff73368ab9a4f7c60 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ce726cd2a3182006999c57eff73368ab9a4f7c60 You're receiving 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 Nov 8 17:55:36 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 12:55:36 -0500 Subject: [Git][ghc/ghc][master] 3 commits: Clarify msum/asum documentation Message-ID: <636a9818404d5_10da0554a1034081d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 3 changed files: - libraries/base/Data/Foldable.hs - libraries/base/GHC/Base.hs - libraries/base/GHC/Conc/Sync.hs Changes: ===================================== libraries/base/Data/Foldable.hs ===================================== @@ -1175,7 +1175,7 @@ sequence_ = foldr c (return ()) where c m k = m >> k {-# INLINE c #-} --- | The sum of a collection of actions, generalizing 'concat'. +-- | The sum of a collection of actions using '(<|>)', generalizing 'concat'. -- -- 'asum' is just like 'msum', but generalised to 'Alternative'. -- @@ -1189,10 +1189,16 @@ asum :: (Foldable t, Alternative f) => t (f a) -> f a {-# INLINE asum #-} asum = foldr (<|>) empty --- | The sum of a collection of actions, generalizing 'concat'. +-- | The sum of a collection of actions using '(<|>)', generalizing 'concat'. -- -- 'msum' is just like 'asum', but specialised to 'MonadPlus'. -- +-- ==== __Examples__ +-- +-- Basic usage, using the 'MonadPlus' instance for 'Maybe': +-- +-- >>> msum [Just "Hello", Nothing, Just "World"] +-- Just "Hello" msum :: (Foldable t, MonadPlus m) => t (m a) -> m a {-# INLINE msum #-} msum = asum ===================================== libraries/base/GHC/Base.hs ===================================== @@ -599,6 +599,15 @@ class Functor f where -- The default definition is @'fmap' . 'const'@, but this may be -- overridden with a more efficient version. -- + -- ==== __Examples__ + -- + -- Perform a computation with 'Maybe' and replace the result with a + -- constant value if it is 'Just': + -- + -- >>> 'a' <$ Just 2 + -- Just 'a' + -- >>> 'a' <$ Nothing + -- Nothing (<$) :: a -> f b -> f a (<$) = fmap . const @@ -1111,7 +1120,9 @@ class Applicative f => Alternative f where some_v = liftA2 (:) v many_v --- | @since 2.01 +-- | Picks the leftmost 'Just' value, or, alternatively, 'Nothing'. +-- +-- @since 2.01 instance Alternative Maybe where empty = Nothing Nothing <|> r = r @@ -1143,7 +1154,9 @@ class (Alternative m, Monad m) => MonadPlus m where mplus :: m a -> m a -> m a mplus = (<|>) --- | @since 2.01 +-- | Picks the leftmost 'Just' value, or, alternatively, 'Nothing'. +-- +-- @since 2.01 instance MonadPlus Maybe --------------------------------------------- @@ -1205,12 +1218,16 @@ instance Monad [] where {-# INLINE (>>) #-} (>>) = (*>) --- | @since 2.01 +-- | Combines lists by concatenation, starting from the empty list. +-- +-- @since 2.01 instance Alternative [] where empty = [] (<|>) = (++) --- | @since 2.01 +-- | Combines lists by concatenation, starting from the empty list. +-- +-- @since 2.01 instance MonadPlus [] {- @@ -1593,12 +1610,18 @@ instance Monad IO where (>>) = (*>) (>>=) = bindIO --- | @since 4.9.0.0 +-- | Takes the first non-throwing 'IO' action\'s result. +-- 'empty' throws an exception. +-- +-- @since 4.9.0.0 instance Alternative IO where empty = failIO "mzero" (<|>) = mplusIO --- | @since 4.9.0.0 +-- | Takes the first non-throwing 'IO' action\'s result. +-- 'mzero' throws an exception. +-- +-- @since 4.9.0.0 instance MonadPlus IO returnIO :: a -> IO a ===================================== libraries/base/GHC/Conc/Sync.hs ===================================== @@ -733,12 +733,16 @@ thenSTM (STM m) k = STM ( \s -> returnSTM :: a -> STM a returnSTM x = STM (\s -> (# s, x #)) --- | @since 4.8.0.0 +-- | Takes the first non-'retry'ing 'STM' action. +-- +-- @since 4.8.0.0 instance Alternative STM where empty = retry (<|>) = orElse --- | @since 4.3.0.0 +-- | Takes the first non-'retry'ing 'STM' action. +-- +-- @since 4.3.0.0 instance MonadPlus STM -- | Unsafely performs IO in the STM monad. Beware: this is a highly View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ce726cd2a3182006999c57eff73368ab9a4f7c60...080fffa1015bcc0cff8ab4ad1eeb507fb7a13383 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ce726cd2a3182006999c57eff73368ab9a4f7c60...080fffa1015bcc0cff8ab4ad1eeb507fb7a13383 You're receiving 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 Nov 8 19:26:32 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 14:26:32 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Define `Infinite` list and use where appropriate. Message-ID: <636aad687fe4e_10da054050cf43605a7@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 5ada9a01 by Giles Anderson at 2022-11-08T14:26:22-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 75721b4e by Hécate Moonlight at 2022-11-08T14:26:25-05:00 GHCi tags generation phase 2 see #19884 - - - - - 30 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/DataCon.hs-boot - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Reduction.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToIface.hs - + compiler/GHC/Data/List/Infinite.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/HsToCore/Pmc/Ppr.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Typeable.hs - compiler/GHC/Tc/Solver/Canonical.hs - compiler/GHC/Tc/Solver/Rewrite.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/TyCl/Instance.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dd859669579a7f1d48f7881c1772df16607562e5...75721b4e65ce4a01c599002021146b98fe2c3866 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dd859669579a7f1d48f7881c1772df16607562e5...75721b4e65ce4a01c599002021146b98fe2c3866 You're receiving 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 Nov 8 20:21:36 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 08 Nov 2022 15:21:36 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <636aba5090e16_10da0552b5c39559e@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: 5f8253ba by Sebastian Graf at 2022-11-08T21:21:21+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1762,7 +1763,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1772,91 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Recall that unboxed tuples will be flattened to individual arguments during +unarisation. Here, `unboxed` will have 5 arguments at runtime because of the +nested unboxed tuple, which will be flattened to 4 args. So it's best to leave +`(a,b)` boxed (because we already are above our arg threshold), but unbox `c` +through `f` because that doesn't increase the number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. For example at the top-level, `(# x,y #)` is to be +treated just like two arguments `x` and `y`. +Of course, for that to work, our budget calculations must initialise +'max_wkr_args' to 5, based on the 'unariseArity' of each Core arg: That would be +1 for the pair and 4 for the unboxed pair. Then when we decide whether to unbox +the unboxed pair, we *directly* recurse into the fields, spending our budget +on retaining `c` and (after recursing once more) `d` through `f` as arguments, +depleting our budget completely in the first layer. Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1877,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets + +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1900,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1913,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1960,46 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) + where + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of + -- the retaining the arg -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- Unboxed through unboxed sums would be tricky (and we + -- currently don't 'wantToUnboxArg' these). It's impossible + -- to predict the effect of dropping absent fields and + -- unboxing others on the unariseArity of the sum without + -- losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) -- "~": This match *must* be lazy! | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) - where - decremented_bg = MkB (bg_top-1) bg_inner add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,19 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False + +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -822,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -839,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -851,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -871,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -883,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -891,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -906,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts -> Var -> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -941,8 +946,8 @@ unbox_one_arg opts arg_var ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co -- See Note [Unboxing through unboxed tuples] ; return $ if isUnboxedTupleDataCon dc && not nested_useful - then (badWorker, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) - else (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1210,7 +1215,7 @@ It's entirely pointless to "unbox" the triple because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. Conclusion: Only consider unboxing an unboxed tuple useful when we will -also unbox its components. That is governed by the `goodWorker` mechanism. +also unbox its components. That is governed by the `usefulSplit` mechanism. ************************************************************************ * * @@ -1393,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1415,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1428,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1458,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1486,8 +1491,8 @@ unbox_one_result opts res_bndr -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,43 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,27 @@ + +==================== Strictness signatures ==================== +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f8253ba3b607939e3031026ac793790d2d05deb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5f8253ba3b607939e3031026ac793790d2d05deb You're receiving 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 Nov 8 21:56:44 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 16:56:44 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636ad09c701de_10da055ac8adc4711ad@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2125d2f0 by Giles Anderson at 2022-11-08T16:56:36-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 4ad62b37 by Hécate Moonlight at 2022-11-08T16:56:37-05:00 GHCi tags generation phase 2 see #19884 - - - - - 30 changed files: - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - ghc/GHCi/UI/Tags.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.hs - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.stderr - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs-boot - testsuite/tests/indexed-types/should_fail/Overlap3.stderr - testsuite/tests/indexed-types/should_fail/Overlap7.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail7.stderr - testsuite/tests/indexed-types/should_fail/T3092.stderr - testsuite/tests/indexed-types/should_fail/T7862.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/75721b4e65ce4a01c599002021146b98fe2c3866...4ad62b37f2e7f5ae97e1922cfa1665d7dc103489 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/75721b4e65ce4a01c599002021146b98fe2c3866...4ad62b37f2e7f5ae97e1922cfa1665d7dc103489 You're receiving 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 Nov 8 23:32:36 2022 From: gitlab at gitlab.haskell.org (Alan Zimmerman (@alanz)) Date: Tue, 08 Nov 2022 18:32:36 -0500 Subject: [Git][ghc/ghc][wip/az/locateda-epa-improve] 2 commits: WIP. Thinking of re-looking at what an Anchor should be Message-ID: <636ae71428447_10da054796c984954b4@gitlab.mail> Alan Zimmerman pushed to branch wip/az/locateda-epa-improve at Glasgow Haskell Compiler / GHC Commits: c2fa156c by Alan Zimmerman at 2022-11-07T21:58:09+00:00 WIP. Thinking of re-looking at what an Anchor should be - - - - - 680fddff by Alan Zimmerman at 2022-11-08T23:32:23+00:00 Using EpaLocation instead of Anchor Via a synonym initially, to prove the concept - - - - - 9 changed files: - compiler/GHC/Hs/Dump.hs - compiler/GHC/HsToCore/Docs.hs - compiler/GHC/Iface/Ext/Ast.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Annotation.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Unit/Module/Warnings.hs - testsuite/tests/parser/should_compile/DumpParsedAst.stderr - testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/abbaa6d604ee79afebdd095e0486ae23a8aa0de6...680fddfff2d56b1993ed69303a7888958a602173 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/abbaa6d604ee79afebdd095e0486ae23a8aa0de6...680fddfff2d56b1993ed69303a7888958a602173 You're receiving 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 Nov 8 23:48:21 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Tue, 08 Nov 2022 18:48:21 -0500 Subject: [Git][ghc/ghc][wip/T21623] 35 commits: Define `Infinite` list and use where appropriate. Message-ID: <636aeac5bcba9_10da054a1b79850347b@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 7ab5f4a1 by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Start work Not ready for review More progress Wibbles Stage1 compiles More wibbles More wibbles More -- almost working Comments Wibbles Wibbles Wibble inlineId Wibbles Infinite loop somewhere More wibbles. Maybe can build stage2 Make FuNCo a thing by itself Wibble Wibble Wibbles Fix OptCoercion Wibble Wibble to optCoercion Replace SORT with TYPE and CONSTRAINT Wibble Delete unused import Delete TypeOrConstraint from ghc-prim:GHC.Types Move from NthCo to SelCo Wibbles Wibbles in RepType Wibble Add mkWpEta Really add mkWpEta Wibble Typeable binds etc Improve error messages More wibbles, mainly to error messages Wibbles Wibbles to errors Wibbles But especially: treat Constraint as Typeable More wibbles More changes * Move role into SelTyCon * Get rid of mkTcSymCo and friends Unused variable Wibbles Wibble Accept error message changes Refactoring... Remove tc functions like tcKind, tcGetTyVar. Move tyConsOfType, occCheckExpand to TyCo.FVs. Introduce GHC.Core.TyCo.Compare Lots of import changes! Update haddock submodule (I hope) Wibbles (notably: actually add GHC.Core.TyCo.Compare) Wibbles Wibble output of T16575 Wibbles More wibbles Remove infinite loop in T1946 See Note [ForAllTy and type equality] Deal with rejigConRes Needs a Note to be written by Richard Some renaming AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag Update haddock submodule Rename TyCoBinder to ForAllTyBinder Wibbles Update haddock Wibble Update unix submodule I think I accidentally got it out of sync with HEAD; this puts it back. Rename TyCoBinder to PiTyBinder Update Haddock submodule Wrap dictionaries in tuples This fixes the kind bugs in arrow desugaring. Needs some Notes, but I want to try CI. More on boxing data cons Rebase and update GHC.Tc.Errors/GHC.Tc.Errors.Ppr Revert accidental changes in SameOccInfo fixes mod180, tcfail182 Wibbles in error messages ..plus eqType comes from GHC.Core.TyCo.Compare Wibbles More wibbles Reaedy for RAE review Fix fragile rule setup in GHC.Float See Note [realToFrac natural-to-float] Wibbles More wibbles Remove unused import Remove another unused import Wibbles Update haddock submodule Respond to Sam's suggestions Wibbles Wibbles - - - - - 6df2a36d by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Wibbles - - - - - 34cb2419 by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Unused import - - - - - d63da24b by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Better boxingCon_maybe - - - - - f5d3dffd by Richard Eisenberg at 2022-11-08T22:25:36+00:00 Improvements to comments, etc., from Richard - - - - - 2f3b4c6e by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Respond to Richard - - - - - a6bac926 by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Improve boxing-data-con API - - - - - 3d5fd2e9 by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Update error messages - - - - - b755a898 by Richard Eisenberg at 2022-11-08T22:25:36+00:00 Fix the equality constraint problem - - - - - dcc4f704 by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Wibbles - - - - - f43669f1 by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Add isCovertGadtDataCon, fixing build - - - - - 2905262b by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Wibbles - - - - - 7ee4b66d by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Wibbles - - - - - 086f147a by Simon Peyton Jones at 2022-11-08T22:25:36+00:00 Move RoughMatch code out of Unify into RoughMatch - - - - - f7acba96 by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Wibble - - - - - 8599bd23 by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Wibbles - - - - - 3154729a by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Update haddock submodule again - - - - - 95b95894 by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Wibbles, esp in RoughMap - - - - - 0240fb6c by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Upate haddock submodule - - - - - 672c49a9 by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Define eqType using tcEqType A one-line change - - - - - 657836a4 by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Revert "Define eqType using tcEqType" This reverts commit eaf04c17c6a159ddb70eedd6fb8ab0b4fc180b7a. Performance got worse! T18223 was 60% worse T8095 75% T12227 9% T13386 6% T15703 7% T5030 8% - - - - - 4467a5d8 by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Refactor FunTyFlag Mostly just renaming stuff - - - - - 5c117494 by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Wibbles - - - - - 9af6492d by Simon Peyton Jones at 2022-11-08T22:25:37+00:00 Wibble - - - - - 44b6d680 by Simon Peyton Jones at 2022-11-08T22:26:23+00:00 Add FunTyFlags to FunCo - - - - - b5e716b7 by Simon Peyton Jones at 2022-11-08T22:26:23+00:00 More improvements Hopefully perf improves a bit Plus rep-poly/T13105 and rep-poly/T17536b are fixed. - - - - - 2414db62 by Simon Peyton Jones at 2022-11-08T22:26:23+00:00 Add tests for #21530 - - - - - 980238ad by Simon Peyton Jones at 2022-11-08T22:26:23+00:00 Make the Unique in a TyCon strict This avoids lots of evals when comparing TyCons - - - - - 58e94ebe by Simon Peyton Jones at 2022-11-08T22:26:23+00:00 Improve efficiency in sORTKind_mabye - - - - - 5de16523 by Simon Peyton Jones at 2022-11-08T23:48:05+00:00 Wibbles - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c564cbd60c26039277d92dd4484b38acc4b672ba...5de1652319de20655690891b286fdf32915b17ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c564cbd60c26039277d92dd4484b38acc4b672ba...5de1652319de20655690891b286fdf32915b17ca You're receiving 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 Nov 9 00:46:57 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 19:46:57 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636af8818ff11_10da054796c98510199@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: aa0257d5 by Giles Anderson at 2022-11-08T19:46:49-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - ac92d0eb by Hécate Moonlight at 2022-11-08T19:46:51-05:00 GHCi tags generation phase 2 see #19884 - - - - - 30 changed files: - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - ghc/GHCi/UI/Tags.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.hs - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.stderr - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs-boot - testsuite/tests/indexed-types/should_fail/Overlap3.stderr - testsuite/tests/indexed-types/should_fail/Overlap7.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail7.stderr - testsuite/tests/indexed-types/should_fail/T3092.stderr - testsuite/tests/indexed-types/should_fail/T7862.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ad62b37f2e7f5ae97e1922cfa1665d7dc103489...ac92d0eb2bc39dd1024d6a480d73887e74e07888 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ad62b37f2e7f5ae97e1922cfa1665d7dc103489...ac92d0eb2bc39dd1024d6a480d73887e74e07888 You're receiving 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 Nov 9 04:47:15 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 08 Nov 2022 23:47:15 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636b30d3d5bce_10da05526c053448a@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 85db03cd by Giles Anderson at 2022-11-08T23:47:06-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 2e8f1938 by Hécate Moonlight at 2022-11-08T23:47:07-05:00 GHCi tags generation phase 2 see #19884 - - - - - 30 changed files: - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - ghc/GHCi/UI/Tags.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.hs - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.stderr - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs-boot - testsuite/tests/indexed-types/should_fail/Overlap3.stderr - testsuite/tests/indexed-types/should_fail/Overlap7.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail7.stderr - testsuite/tests/indexed-types/should_fail/T3092.stderr - testsuite/tests/indexed-types/should_fail/T7862.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac92d0eb2bc39dd1024d6a480d73887e74e07888...2e8f19389bed5674593a58b26ebf0bd560212e88 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ac92d0eb2bc39dd1024d6a480d73887e74e07888...2e8f19389bed5674593a58b26ebf0bd560212e88 You're receiving 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 Nov 9 07:17:34 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 09 Nov 2022 02:17:34 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636b540e468d0_10da054050cf45501e8@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 687e0900 by Giles Anderson at 2022-11-09T02:17:27-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 00e48458 by Hécate Moonlight at 2022-11-09T02:17:28-05:00 GHCi tags generation phase 2 see #19884 - - - - - 30 changed files: - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - ghc/GHCi/UI/Tags.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.hs - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.stderr - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs-boot - testsuite/tests/indexed-types/should_fail/Overlap3.stderr - testsuite/tests/indexed-types/should_fail/Overlap7.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail7.stderr - testsuite/tests/indexed-types/should_fail/T3092.stderr - testsuite/tests/indexed-types/should_fail/T7862.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2e8f19389bed5674593a58b26ebf0bd560212e88...00e48458d13181f45810b0ef6a45b2f27f811eb4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2e8f19389bed5674593a58b26ebf0bd560212e88...00e48458d13181f45810b0ef6a45b2f27f811eb4 You're receiving 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 Nov 9 08:33:17 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 09 Nov 2022 03:33:17 -0500 Subject: [Git][ghc/ghc][wip/T21623] Remove import Message-ID: <636b65cda2be8_10da054a1b79857132c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 4e4645af by Simon Peyton Jones at 2022-11-09T08:34:53+00:00 Remove import - - - - - 1 changed file: - compiler/GHC/Builtin/Uniques.hs Changes: ===================================== compiler/GHC/Builtin/Uniques.hs ===================================== @@ -63,7 +63,6 @@ import GHC.Data.FastString import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Misc( HasDebugCallStack ) import Data.Maybe View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e4645af27761ad4edb5eb54d001acea93a2a80e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4e4645af27761ad4edb5eb54d001acea93a2a80e You're receiving 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 Nov 9 10:33:33 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 09 Nov 2022 05:33:33 -0500 Subject: [Git][ghc/ghc][wip/T21623] 2 commits: Fix fragile RULE setup in GHC.Float Message-ID: <636b81fd3df7f_10da0554a105930d0@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: de0fe9be by Simon Peyton Jones at 2022-11-09T10:34:42+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 92e31139 by Simon Peyton Jones at 2022-11-09T10:34:43+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e4645af27761ad4edb5eb54d001acea93a2a80e...92e311395d01e624e37f48281525d58524917472 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4e4645af27761ad4edb5eb54d001acea93a2a80e...92e311395d01e624e37f48281525d58524917472 You're receiving 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 Nov 9 10:53:30 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 09 Nov 2022 05:53:30 -0500 Subject: [Git][ghc/ghc][wip/T21623] Type vs Constraint: finally nailed Message-ID: <636b86aae6fb5_10da054a1b798603160@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 184e3dcc by Simon Peyton Jones at 2022-11-09T10:55:01+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/184e3dcce8c2a539967d3b2ce0d4caf359cdecbb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/184e3dcce8c2a539967d3b2ce0d4caf359cdecbb You're receiving 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 Nov 9 11:17:53 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 09 Nov 2022 06:17:53 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636b8c615a0f9_10da0554a10612661@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 57365f82 by Giles Anderson at 2022-11-09T06:17:43-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - e26bdb17 by Hécate Moonlight at 2022-11-09T06:17:45-05:00 GHCi tags generation phase 2 see #19884 - - - - - 30 changed files: - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - ghc/GHCi/UI/Tags.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.hs - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.stderr - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs-boot - testsuite/tests/indexed-types/should_fail/Overlap3.stderr - testsuite/tests/indexed-types/should_fail/Overlap7.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail7.stderr - testsuite/tests/indexed-types/should_fail/T3092.stderr - testsuite/tests/indexed-types/should_fail/T7862.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00e48458d13181f45810b0ef6a45b2f27f811eb4...e26bdb17f207db1e6aa626b61fcef7782999346c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/00e48458d13181f45810b0ef6a45b2f27f811eb4...e26bdb17f207db1e6aa626b61fcef7782999346c You're receiving 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 Nov 9 12:10:22 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 09 Nov 2022 07:10:22 -0500 Subject: [Git][ghc/ghc][wip/T21851] 17 commits: CI: Allow hadrian-ghc-in-ghci to run in nightlies Message-ID: <636b98aeb1ac_10da0552b5c62216c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851 at Glasgow Haskell Compiler / GHC Commits: bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - e20c010a by Simon Peyton Jones at 2022-11-09T12:09:27+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. Metric Decrease: T9961 - - - - - 70a8c9b5 by Simon Peyton Jones at 2022-11-09T12:10:17+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 15407a35 by Simon Peyton Jones at 2022-11-09T12:11:19+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - 39717dfe by Simon Peyton Jones at 2022-11-09T12:12:12+00:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/DataCon.hs-boot - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Reduction.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9617b84aff7ad41e19d3d610af41adb0b48b744...39717dfe7a328dbefe88c62a8208852e95ddcfa4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e9617b84aff7ad41e19d3d610af41adb0b48b744...39717dfe7a328dbefe88c62a8208852e95ddcfa4 You're receiving 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 Nov 9 12:27:05 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 09 Nov 2022 07:27:05 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/t22405 Message-ID: <636b9c999ec8d_10da054a1b7986269eb@gitlab.mail> Matthew Pickering pushed new branch wip/t22405 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/t22405 You're receiving 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 Nov 9 12:30:54 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 09 Nov 2022 07:30:54 -0500 Subject: [Git][ghc/ghc][wip/js-staging] 4 commits: Remove dubious JSLinkConfig instances Message-ID: <636b9d7e9766f_10da0552b5c6309c3@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 257c8175 by Sylvain Henry at 2022-11-09T13:27:29+01:00 Remove dubious JSLinkConfig instances - - - - - 7bf1e700 by Sylvain Henry at 2022-11-09T13:27:59+01:00 Hadrian: tweak validate flavour to avoid building threaded - - - - - feef116b by Sylvain Henry at 2022-11-09T13:29:35+01:00 Fix warnings in base - - - - - 4556033e by Sylvain Henry at 2022-11-09T13:34:25+01:00 Add some HasDebugCallStack - - - - - 10 changed files: - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/StgToJS/Linker/Types.hs - compiler/GHC/StgToJS/Utils.hs - hadrian/src/Settings/Flavours/Validate.hs - libraries/base/GHC/Conc/IO.hs - libraries/base/GHC/IO/FD.hs - libraries/base/GHC/TopHandler.hs - libraries/base/System/CPUTime.hsc - + libraries/base/System/CPUTime/Javascript.hs - libraries/base/base.cabal Changes: ===================================== compiler/GHC/Driver/Pipeline.hs ===================================== @@ -83,6 +83,7 @@ import GHC.Linker.Static.Utils import GHC.Linker.Types import GHC.StgToJS.Linker.Linker +import GHC.StgToJS.Linker.Types (defaultJSLinkConfig) import GHC.Utils.Outputable import GHC.Utils.Error @@ -364,8 +365,8 @@ link :: GhcLink -- ^ interactive or batch -- exports main, i.e., we have good reason to believe that linking -- will succeed. -link ghcLink logger tmpfs hooks dflags unit_env batch_attempt_linking mHscMessage hpt - = case linkHook hooks of +link ghcLink logger tmpfs hooks dflags unit_env batch_attempt_linking mHscMessage hpt = + case linkHook hooks of Nothing -> case ghcLink of NoLink -> return Succeeded LinkBinary -> normal_link @@ -448,7 +449,7 @@ link' logger tmpfs dflags unit_env batch_attempt_linking mHscMessager hpt case ghcLink dflags of LinkBinary | isJS -> do - let lc_cfg = mempty + let lc_cfg = defaultJSLinkConfig let extra_js = mempty let cfg = initStgToJSConfig dflags jsLinkBinary lc_cfg cfg extra_js logger dflags unit_env obj_files pkg_deps @@ -574,7 +575,7 @@ doLink hsc_env o_files = do NoLink -> return () LinkBinary | isJS -> do - let lc_cfg = mempty + let lc_cfg = defaultJSLinkConfig let extra_js = mempty let cfg = initStgToJSConfig dflags jsLinkBinary lc_cfg cfg extra_js logger dflags unit_env o_files [] ===================================== compiler/GHC/StgToJS/Linker/Types.hs ===================================== @@ -22,6 +22,7 @@ module GHC.StgToJS.Linker.Types ( GhcjsEnv (..) , newGhcjsEnv , JSLinkConfig (..) + , defaultJSLinkConfig , generateAllJs , LinkedObj (..) , LinkableUnit @@ -60,26 +61,14 @@ data JSLinkConfig = JSLinkConfig generateAllJs :: JSLinkConfig -> Bool generateAllJs s = not (lcOnlyOut s) && not (lcNoRts s) -instance Monoid JSLinkConfig where - mempty = JSLinkConfig - { lcNoJSExecutables = False - , lcNoHsMain = False - , lcOnlyOut = False - , lcNoRts = False - , lcNoStats = False - } - -instance Semigroup JSLinkConfig where - (<>) c1 c2 = - let comb :: (a -> a -> a) -> (JSLinkConfig -> a) -> a - comb f a = f (a c1) (a c2) - in JSLinkConfig - { lcNoJSExecutables = comb (||) lcNoJSExecutables - , lcNoHsMain = comb (||) lcNoHsMain - , lcOnlyOut = comb (||) lcOnlyOut - , lcNoRts = comb (||) lcNoRts - , lcNoStats = comb (||) lcNoStats - } +defaultJSLinkConfig :: JSLinkConfig +defaultJSLinkConfig = JSLinkConfig + { lcNoJSExecutables = False + , lcNoHsMain = False + , lcOnlyOut = False + , lcNoRts = False + , lcNoStats = False + } -------------------------------------------------------------------------------- -- Linker Environment ===================================== compiler/GHC/StgToJS/Utils.hs ===================================== @@ -21,7 +21,7 @@ import GHC.Utils.Misc import GHC.Utils.Panic import GHC.Utils.Outputable -assignToTypedExprs :: [TypedExpr] -> [JExpr] -> JStat +assignToTypedExprs :: HasDebugCallStack => [TypedExpr] -> [JExpr] -> JStat assignToTypedExprs tes es = assignAllEqual (concatMap typex_expr tes) es @@ -30,7 +30,7 @@ assignTypedExprs tes es = -- TODO: check primRep (typex_typ) here? assignToTypedExprs tes (concatMap typex_expr es) -assignToExprCtx :: ExprCtx -> [JExpr] -> JStat +assignToExprCtx :: HasDebugCallStack => ExprCtx -> [JExpr] -> JStat assignToExprCtx ctx es = assignToTypedExprs (ctxTarget ctx) es -- | Assign first expr only (if it exists), performing coercions between some ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -18,9 +18,11 @@ validateFlavour = enableLinting $ werror $ defaultFlavour , notStage0 ? platformSupportsSharedLibs ? pure [dynamic] ] , rtsWays = Set.fromList <$> - mconcat [ pure [vanilla, threaded, debug, threadedDebug] - , notStage0 ? platformSupportsSharedLibs ? pure - [ dynamic, threadedDynamic, debugDynamic, threadedDebugDynamic + mconcat [ pure [vanilla, debug] + , targetSupportsSMP ? pure [threaded, threadedDebug] + , notStage0 ? platformSupportsSharedLibs ? mconcat + [ pure [ dynamic, debugDynamic ] + , targetSupportsSMP ? pure [ threadedDynamic, threadedDebugDynamic ] ] ] , ghcDebugAssertions = (<= Stage1) ===================================== libraries/base/GHC/Conc/IO.hs ===================================== @@ -215,13 +215,15 @@ threadDelay time -- 2147483647 μs, less than 36 minutes. -- registerDelay :: Int -> IO (TVar Bool) -registerDelay usecs +registerDelay _usecs #if defined(mingw32_HOST_OS) - | isWindowsNativeIO = Windows.registerDelay usecs - | threaded = Windows.registerDelay usecs + | isWindowsNativeIO = Windows.registerDelay _usecs + | threaded = Windows.registerDelay _usecs #elif !defined(js_HOST_ARCH) - | threaded = Event.registerDelay usecs + | threaded = Event.registerDelay _usecs #endif | otherwise = errorWithoutStackTrace "registerDelay: requires -threaded" +#if !defined(js_HOST_ARCH) foreign import ccall unsafe "rtsSupportsBoundThreads" threaded :: Bool +#endif ===================================== libraries/base/GHC/IO/FD.hs ===================================== @@ -658,15 +658,13 @@ writeRawBufferPtrNoBlock loc !fd !buf !off !len safe_write = do_write (c_safe_write (fdFD fd) (buf `plusPtr` off) len) #endif +#ifndef js_HOST_ARCH isNonBlocking :: FD -> Bool -#ifdef js_HOST_ARCH -isNonBlocking _ = True -#else isNonBlocking fd = fdIsNonBlocking fd /= 0 -#endif foreign import ccall unsafe "fdReady" unsafe_fdReady :: CInt -> CBool -> Int64 -> CBool -> IO CInt +#endif #else /* mingw32_HOST_OS.... */ @@ -756,7 +754,9 @@ foreign import WINDOWS_CCONV safe "send" #endif +#ifndef js_HOST_ARCH foreign import ccall unsafe "rtsSupportsBoundThreads" threaded :: Bool +#endif -- ----------------------------------------------------------------------------- -- utils ===================================== libraries/base/GHC/TopHandler.hs ===================================== @@ -46,6 +46,7 @@ import GHC.Weak #if defined(mingw32_HOST_OS) import GHC.ConsoleHandler +#elif defined(js_HOST_ARCH) #else import Data.Dynamic (toDyn) #endif ===================================== libraries/base/System/CPUTime.hsc ===================================== @@ -1,8 +1,5 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE CPP, CApiFFI #-} -##if defined(js_HOST_ARCH) -{-# LANGUAGE JavaScriptFFI #-} -##endif ----------------------------------------------------------------------------- -- | @@ -33,31 +30,13 @@ module System.CPUTime import System.IO.Unsafe (unsafePerformIO) -##if defined(js_HOST_ARCH) -import qualified System.CPUTime.Unsupported as I - -cpuTimePrecision :: Integer -cpuTimePrecision = toInteger js_cpuTimePrecision - -getCPUTime :: IO Integer -getCPUTime = do - t <- js_getCPUTime - if t == -1 then I.getCPUTime - else pure (1000 * round t) - -foreign import javascript unsafe - "(() => { return h$cpuTimePrecision; })" - js_cpuTimePrecision :: Int - -foreign import javascript unsafe - "(() => { return h$getCPUTime; })" - js_getCPUTime :: IO Double - -##else -- Here is where we decide which backend to use #if defined(mingw32_HOST_OS) import qualified System.CPUTime.Windows as I +#elif defined(js_HOST_ARCH) +import qualified System.CPUTime.Javascript as I + #elif _POSIX_TIMERS > 0 && defined(_POSIX_CPUTIME) && _POSIX_CPUTIME >= 0 import qualified System.CPUTime.Posix.ClockGetTime as I @@ -89,5 +68,3 @@ cpuTimePrecision = unsafePerformIO I.getCpuTimePrecision -- implementation-dependent. getCPUTime :: IO Integer getCPUTime = I.getCPUTime - -##endif ===================================== libraries/base/System/CPUTime/Javascript.hs ===================================== @@ -0,0 +1,26 @@ +{-# LANGUAGE JavaScriptFFI #-} + +module System.CPUTime.Javascript + ( getCPUTime + , getCpuTimePrecision + ) +where + +import qualified System.CPUTime.Unsupported as I + +getCpuTimePrecision :: IO Integer +getCpuTimePrecision = toInteger <$> js_cpuTimePrecision + +getCPUTime :: IO Integer +getCPUTime = do + t <- js_getCPUTime + if t == -1 then I.getCPUTime + else pure (1000 * round t) + +foreign import javascript unsafe + "(() => { return h$cpuTimePrecision(); })" + js_cpuTimePrecision :: IO Int + +foreign import javascript unsafe + "(() => { return h$getCPUTime(); })" + js_getCPUTime :: IO Double ===================================== libraries/base/base.cabal ===================================== @@ -460,6 +460,10 @@ Library System.CPUTime.Posix.RUsage System.CPUTime.Unsupported + if arch(js) + other-modules: + System.CPUTime.Javascript + -- The Ports framework always passes this flag when building software that -- uses iconv to make iconv from Ports compatible with iconv from the base system -- See /usr/ports/Mk/Uses/iconv.mk View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/291ae43721c76895f93fc052194dae80eea54585...4556033e37a93bb02c4c2c04433cf86d4be9ebe0 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/291ae43721c76895f93fc052194dae80eea54585...4556033e37a93bb02c4c2c04433cf86d4be9ebe0 You're receiving 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 Nov 9 12:32:18 2022 From: gitlab at gitlab.haskell.org (Matthew Pickering (@mpickering)) Date: Wed, 09 Nov 2022 07:32:18 -0500 Subject: [Git][ghc/ghc][wip/t22405] Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` Message-ID: <636b9dd239172_10da054a1b7986311bc@gitlab.mail> Matthew Pickering pushed to branch wip/t22405 at Glasgow Haskell Compiler / GHC Commits: 7346a019 by Matthew Pickering at 2022-11-09T12:32:08+00:00 Add special case for :Main module in `GHC.IfaceToCore.mk_top_id` See Note [Root-main Id] The `:Main` special binding is actually defined in the current module (hence don't go looking for it externally) but the module name is rOOT_MAIN rather than the current module so we need this special case. There was already some similar logic in `GHC.Rename.Env` for External Core, but now the "External Core" is in interface files it needs to be moved here instead. Fixes #22405 - - - - - 9 changed files: - compiler/GHC/IfaceToCore.hs - compiler/GHC/Rename/Env.hs - compiler/GHC/Tc/Module.hs - + testsuite/tests/driver/fat-iface/T22405/Main.hs - + testsuite/tests/driver/fat-iface/T22405/Main2.hs - + testsuite/tests/driver/fat-iface/T22405/Makefile - + testsuite/tests/driver/fat-iface/T22405/T22405.stdout - + testsuite/tests/driver/fat-iface/T22405/T22405b.stdout - + testsuite/tests/driver/fat-iface/T22405/all.T Changes: ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -123,6 +123,7 @@ import GHC.Driver.Env.KnotVars import GHC.Unit.Module.WholeCoreBindings import Data.IORef import Data.Foldable +import GHC.Builtin.Names (ioTyConName, rOOT_MAIN) {- This module takes @@ -930,7 +931,17 @@ tc_iface_binding i IfUseUnfoldingRhs = return (unfoldingTemplate $ realIdUnfoldi tc_iface_binding _ (IfRhs rhs) = tcIfaceExpr rhs mk_top_id :: IfaceTopBndrInfo -> IfL Id -mk_top_id (IfGblTopBndr gbl_name) = tcIfaceExtId gbl_name +mk_top_id (IfGblTopBndr gbl_name) + -- See Note [Root-main Id] + -- This special binding is actually defined in the current module + -- (hence don't go looking for it externally) but the module name is rOOT_MAIN + -- rather than the current module so we need this special case. + -- See some similar logic in `GHC.Rename.Env`. + | Just rOOT_MAIN == nameModule_maybe gbl_name + = do + ATyCon ioTyCon <- tcIfaceGlobal ioTyConName + return $ mkExportedVanillaId gbl_name (mkTyConApp ioTyCon [unitTy]) + | otherwise = tcIfaceExtId gbl_name mk_top_id (IfLclTopBndr raw_name iface_type info details) = do name <- newIfaceName (mkVarOccFS raw_name) ty <- tcIfaceType iface_type ===================================== compiler/GHC/Rename/Env.hs ===================================== @@ -207,6 +207,11 @@ newTopSrcBinder (L loc rdr_name) -- the nice Exact name for the TyCon gets swizzled to an Orig name. -- Hence the badOrigBinding error message. -- + + -- MP 2022: I suspect this code path is never called for `rOOT_MAIN` anymore + -- because External Core has been removed but we instead have some similar logic for + -- serialising whole programs into interface files in GHC.IfaceToCore.mk_top_id. + -- Except for the ":Main.main = ..." definition inserted into -- the Main module; ugh! ===================================== compiler/GHC/Tc/Module.hs ===================================== @@ -2042,6 +2042,14 @@ This is unusual: it's a LocalId whose Name has a Module from another module. Tiresomely, we must filter it out again in GHC.Iface.Make, less we get two defns for 'main' in the interface file! +When using `-fwrite-if-simplified-core` the root_main_id can end up in an interface file. +When the interface is read back in we have to add a special case when creating the +Id because otherwise we would go looking for the :Main module which obviously doesn't +exist. For this logic see GHC.IfaceToCore.mk_top_id. + +There is also some similar (probably dead) logic in GHC.Rename.Env which says it +was added for External Core which faced a similar issue. + ********************************************************* * * ===================================== testsuite/tests/driver/fat-iface/T22405/Main.hs ===================================== @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = return () ===================================== testsuite/tests/driver/fat-iface/T22405/Main2.hs ===================================== @@ -0,0 +1,6 @@ +module Main2 where + +main :: IO () +main = return () + + ===================================== testsuite/tests/driver/fat-iface/T22405/Makefile ===================================== @@ -0,0 +1,17 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +TEST_HC_OPTS_NO_RTSOPTS = $(filter-out -rtsopts,$(TEST_HC_OPTS)) + +clean: + rm -f *.hi *.hi-fat *.o + +T22405: clean + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main + +T22405b: clean + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main2 -main-is Main2 + "$(TEST_HC)" $(TEST_HC_OPTS) -fbyte-code-and-object-code Main2 -main-is Main2 + ===================================== testsuite/tests/driver/fat-iface/T22405/T22405.stdout ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Main ( Main.hs, Main.o, interpreted ) +[2 of 2] Linking Main ===================================== testsuite/tests/driver/fat-iface/T22405/T22405b.stdout ===================================== @@ -0,0 +1,2 @@ +[1 of 2] Compiling Main2 ( Main2.hs, Main2.o, interpreted ) +[2 of 2] Linking Main2 ===================================== testsuite/tests/driver/fat-iface/T22405/all.T ===================================== @@ -0,0 +1,2 @@ +test('T22405', [extra_files(['Main.hs'])], makefile_test, ['T22405']) +test('T22405b', [extra_files(['Main2.hs'])], makefile_test, ['T22405b']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7346a019517822b3a1bf3f26535c7c1f83a12461 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7346a019517822b3a1bf3f26535c7c1f83a12461 You're receiving 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 Nov 9 13:31:30 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 09 Nov 2022 08:31:30 -0500 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Remove redundant import Message-ID: <636babb2b0d5b_10da054796c9865429f@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 20c49025 by Andreas Klebinger at 2022-11-09T14:29:19+01:00 Remove redundant import - - - - - 1 changed file: - compiler/GHC/Cmm/CLabel.hs Changes: ===================================== compiler/GHC/Cmm/CLabel.hs ===================================== @@ -152,7 +152,6 @@ import GHC.Builtin.PrimOps import GHC.Types.CostCentre import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Utils.Trace import GHC.Utils.Panic.Plain import GHC.Data.FastString import GHC.Platform View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20c49025a22eb381ebdb5f0cf34e18e0f9f8d746 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/20c49025a22eb381ebdb5f0cf34e18e0f9f8d746 You're receiving 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 Nov 9 14:28:11 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 09 Nov 2022 09:28:11 -0500 Subject: [Git][ghc/ghc][master] Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636bb8fbe6b6a_10da0552b5c685452@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 30 changed files: - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.hs - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.stderr - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs-boot - testsuite/tests/indexed-types/should_fail/Overlap3.stderr - testsuite/tests/indexed-types/should_fail/Overlap7.stderr - testsuite/tests/indexed-types/should_fail/SimpleFail7.stderr - testsuite/tests/indexed-types/should_fail/T3092.stderr - testsuite/tests/indexed-types/should_fail/T7862.stderr - testsuite/tests/indexed-types/should_fail/all.T The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/92ccb8de9624ea930d66152b2f6a181941a497c9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/92ccb8de9624ea930d66152b2f6a181941a497c9 You're receiving 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 Nov 9 14:28:45 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Wed, 09 Nov 2022 09:28:45 -0500 Subject: [Git][ghc/ghc][master] GHCi tags generation phase 2 Message-ID: <636bb91de5474_10da0554a2468885b@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - 1 changed file: - ghc/GHCi/UI/Tags.hs Changes: ===================================== ghc/GHCi/UI/Tags.hs ===================================== @@ -61,7 +61,7 @@ data TagsKind = ETags | CTagsWithLineNumbers | CTagsWithRegExes ghciCreateTagsFile :: TagsKind -> FilePath -> GHCi () ghciCreateTagsFile kind file = do - liftIO $ putStrLn "Tags generation from GHCi will be deprecated in future releases" + liftIO $ putStrLn "Tags generation from GHCi will be deprecated in GHC 9.8" liftIO $ putStrLn "Use the method described in https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/GHCi/Tags" createTagsFile kind file View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/90c5abd4581b404f715e72ad55303e18d0c31d68 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/90c5abd4581b404f715e72ad55303e18d0c31d68 You're receiving 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 Nov 9 14:50:49 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 09 Nov 2022 09:50:49 -0500 Subject: [Git][ghc/ghc][wip/T22388] Boxity: Handle argument budget of unboxed tuples correctly (#21737) Message-ID: <636bbe4966bf_10da053ed19f0690621@gitlab.mail> Sebastian Graf pushed to branch wip/T22388 at Glasgow Haskell Compiler / GHC Commits: 213dd4ce by Sebastian Graf at 2022-11-09T15:50:38+01:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1762,7 +1763,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1772,91 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Recall that unboxed tuples will be flattened to individual arguments during +unarisation. Here, `unboxed` will have 5 arguments at runtime because of the +nested unboxed tuple, which will be flattened to 4 args. So it's best to leave +`(a,b)` boxed (because we already are above our arg threshold), but unbox `c` +through `f` because that doesn't increase the number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. For example at the top-level, `(# x,y #)` is to be +treated just like two arguments `x` and `y`. +Of course, for that to work, our budget calculations must initialise +'max_wkr_args' to 5, based on the 'unariseArity' of each Core arg: That would be +1 for the pair and 4 for the unboxed pair. Then when we decide whether to unbox +the unboxed pair, we *directly* recurse into the fields, spending our budget +on retaining `c` and (after recursing once more) `d` through `f` as arguments, +depleting our budget completely in the first layer. Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1877,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets + +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1900,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1913,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1960,49 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg + -- The unboxed case does happen here, for example + -- app g x = g x :: (# Int, Int #) + -- here, `x` is used `L`azy and thus Boxed + + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- We currently don't return DoUnbox for unboxed sums. + -- But hopefully we will at some point. When that happens, + -- it would still be impossible to predict the effect + -- of dropping absent fields and unboxing others on the + -- unariseArity of the sum without losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) + where + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) -- "~": This match *must* be lazy! | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) - where - decremented_bg = MkB (bg_top-1) bg_inner add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,19 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False + +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -822,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -839,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -851,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -871,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -883,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -891,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -906,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts -> Var -> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -941,8 +946,8 @@ unbox_one_arg opts arg_var ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co -- See Note [Unboxing through unboxed tuples] ; return $ if isUnboxedTupleDataCon dc && not nested_useful - then (badWorker, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) - else (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1210,7 +1215,7 @@ It's entirely pointless to "unbox" the triple because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. Conclusion: Only consider unboxing an unboxed tuple useful when we will -also unbox its components. That is governed by the `goodWorker` mechanism. +also unbox its components. That is governed by the `usefulSplit` mechanism. ************************************************************************ * * @@ -1393,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1415,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1428,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1458,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1486,8 +1491,8 @@ unbox_one_result opts res_bndr -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,47 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} + +-- Point: Demand on `x` is lazy and thus Unboxed +app :: ((# Int, Int #) -> (# Int, Int #)) -> (# Int, Int #) -> (# Int, Int #) +app g x = g x ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.app: +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/213dd4ce5aee85681636a08f90a2bf32eee5e821 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/213dd4ce5aee85681636a08f90a2bf32eee5e821 You're receiving 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 Nov 9 15:07:08 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 09 Nov 2022 10:07:08 -0500 Subject: [Git][ghc/ghc][wip/T22274] Identify exit cases in OccurAnal Message-ID: <636bc21c1efaa_10da05526ac695913@gitlab.mail> Sebastian Graf pushed to branch wip/T22274 at Glasgow Haskell Compiler / GHC Commits: 554ea79f by Sebastian Graf at 2022-11-09T16:05:45+01:00 Identify exit cases in OccurAnal Also had to mark a few key WordArray functions as INLINE so that they don't allocate a closure for the continuation. - - - - - 3 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Types/Unique/SlimSet.hs - libraries/ghc-bignum/src/GHC/Num/WordArray.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -34,7 +34,7 @@ import GHC.Core.Predicate ( isDictId ) import GHC.Core.Type import GHC.Core.TyCo.FVs ( tyCoVarsOfMCo ) -import GHC.Data.Maybe( isJust, orElse ) +import GHC.Data.Maybe( isJust, orElse, mapMaybe, expectJust ) import GHC.Data.Graph.Directed ( SCC(..), Node(..) , stronglyConnCompFromEdgedVerticesUniq , stronglyConnCompFromEdgedVerticesUniqR ) @@ -48,6 +48,7 @@ import GHC.Types.Tickish import GHC.Types.Var.Set import GHC.Types.Var.Env import GHC.Types.Var +import GHC.Types.Unique.SlimSet import GHC.Types.Demand ( argOneShots, argsOneShots ) import GHC.Utils.Outputable @@ -59,6 +60,8 @@ import GHC.Utils.Trace import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) +import Data.IntMap.Strict (IntMap) +import qualified Data.IntMap.Strict as IntMap import Data.List (mapAccumL, mapAccumR) import Data.List.NonEmpty (NonEmpty (..), nonEmpty) import qualified Data.List.NonEmpty as NE @@ -755,7 +758,8 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage = WithUsageDetails body_usage [] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = -- applyWhen (getOccFS bndr `elem` map fsLit ["binder_set","refined_id"]) (pprTrace "NonRec" (ppr bndr $$ ppr body_usage' $$ ppr rhs_usage $$ ppr (body_usage' `andUDs` rhs_usage))) $ + WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] where (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr final_bndr = tagged_bndr `setIdUnfolding` unf' @@ -774,7 +778,7 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity (idOccInfo tagged_bndr) rhs --------- Unfolding --------- -- See Note [Unfoldings and join points] @@ -831,7 +835,9 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage bndrs = map fst pairs bndr_set = mkVarSet bndrs - rhs_env = env `addInScope` bndrs + -- enter the loop here and leave it in makeNode + rhs_env = -- pprTrace "entering" (ppr bndrs) $ + env `addInScope` bndrs `enterLoop` bndrs ----------------------------- @@ -852,7 +858,7 @@ occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs (NonRec tagged_bndr rhs : binds) where (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + rhs_uds' = adjustRhsUsage mb_join_arity (idOccInfo tagged_bndr) rhs rhs_uds mb_join_arity = willBeJoinId_maybe tagged_bndr -- The Rec case is the interesting one @@ -863,7 +869,8 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- At this point we always build a single Rec - = -- pprTrace "occAnalRec" (ppr loop_breaker_nodes) + -- = -- pprTrace "occAnalRec" (ppr loop_breaker_nodes) + = -- applyWhen (any (\bndr -> getOccFS bndr `elem` map fsLit ["search"]) bndrs) (pprTrace "Rec" (ppr bndrs <+> ppr (NE.nonEmpty bndrs >>= (lookupVarEnv (occ_loops env) . NE.head)) $$ ppr body_uds $$ ppr (map nd_uds details_s) $$ ppr final_uds)) $ WithUsageDetails final_uds (Rec pairs : binds) where @@ -1399,8 +1406,10 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) bndr' = bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' + loop_lvl = lookupLoopLevel env bndr inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + scope_uds = -- pprTrace "leaving" (ppr bndr <+> ppr loop_lvl) $ + leaveLoop loop_lvl bndr $ inl_uds `andUDs` rule_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] scope_fvs = udFreeVars bndr_set scope_uds @@ -1897,15 +1906,16 @@ of a right hand side is handled by occAnalLam. ********************************************************************* -} occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity + -> OccInfo -- How often does the binder of the RHS occur? -> CoreExpr -- RHS -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs +occAnalRhs !env is_rec mb_join_arity occ rhs = let (WithUsageDetails usage rhs1) = occAnalLam env rhs -- We call occAnalLam here, not occAnalExpr, so that it doesn't -- do the markAllInsideLam and markNonTailCall stuff before -- we've had a chance to help with join points; that comes next rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage + rhs_usage = adjustRhsUsage mb_join_arity occ rhs2 usage in WithUsageDetails rhs_usage rhs2 @@ -1940,7 +1950,7 @@ occAnalUnfolding !env is_rec mb_join_arity unf unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity noOccInfo rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } @@ -2287,7 +2297,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) IAmDead arg -- IAmDead is OK because we are only interested in whether it is ManyOcc or not = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2299,7 +2309,7 @@ occAnalApp env (Var fun_id, args, ticks) !(fun', fun_id') = lookupBndrSwap env fun_id !(WithUsageDetails args_uds app') = occAnalArgs env fun' args one_shots - fun_uds = mkOneOcc fun_id' int_cxt n_args + fun_uds = mkOneOcc env fun_id' int_cxt n_args -- NB: fun_uds is computed for fun_id', not fun_id -- See (BS1) in Note [The binder-swap substitution] @@ -2459,6 +2469,8 @@ scrutinised y). data OccEnv = OccEnv { occ_encl :: !OccEncl -- Enclosing context information , occ_one_shots :: !OneShots -- See Note [OneShots] + , occ_cur_lvl :: !LoopLevel -- ^ Current loop level + , occ_loops :: !(IdEnv LoopLevel) -- ^ The loop levels of enclosing letrec binders , occ_unf_act :: Id -> Bool -- Which Id unfoldings are active , occ_rule_act :: Activation -> Bool -- Which rules are active -- See Note [Finding rule RHS free vars] @@ -2507,6 +2519,8 @@ initOccEnv :: OccEnv initOccEnv = OccEnv { occ_encl = OccVanilla , occ_one_shots = [] + , occ_cur_lvl = 0 + , occ_loops = emptyVarEnv -- To be conservative, we say that all -- inlines and rules are active @@ -2546,6 +2560,11 @@ isRhsEnv (OccEnv { occ_encl = cxt }) = case cxt of OccRhs -> True _ -> False +lookupLoopLevel :: OccEnv -> Id -> Int +lookupLoopLevel (OccEnv { occ_loops = loops }) id + | Just lvl <- lookupVarEnv loops id = lvl + | otherwise = 0 + addOneInScope :: OccEnv -> CoreBndr -> OccEnv addOneInScope env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) bndr | bndr `elemVarSet` rng_vars = env { occ_bs_env = emptyVarEnv, occ_bs_rng = emptyVarSet } @@ -2559,6 +2578,29 @@ addInScope env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) bndrs | any (`elemVarSet` rng_vars) bndrs = env { occ_bs_env = emptyVarEnv, occ_bs_rng = emptyVarSet } | otherwise = env { occ_bs_env = swap_env `delVarEnvList` bndrs } +enterLoop :: OccEnv -> [Var] -> OccEnv +enterLoop env vs + = env { occ_cur_lvl = new_lvl + , occ_loops = extendVarEnvList (occ_loops env) [(v,new_lvl) | v<-vs] } + where + new_lvl = occ_cur_lvl env + 1 + +leaveLoop :: LoopLevel -> Id -> UsageDetails -> UsageDetails +leaveLoop loop_lvl bndr ud at UD{ud_loop_info=lli} + | loop_lvl > max_lvl = ud + | otherwise = assertPpr (loop_lvl == max_lvl) (text "loop_lvl < max_lvl is wrong" $$ ppr bndr <+> ppr loop_lvl <+> ppr max_lvl $$ ppr ud) $ + -- pprTraceWith "leave interesting" (\r -> ppr lvl $$ ppr ud $$ ppr r) $ + ud { ud_z_in_lam = ud_z_in_lam ud `plusVarEnv` (ud_env ud `minusVarEnv` nml), ud_loop_info = lli' } + where + max_lvl = lli_max (ud_loop_info ud) + nml = lli_non_max_lvls lli + lli' = case IntMap.maxViewWithKey (lli_inv lli) of + Nothing -> emptyLoopLevelInfo + Just ((new_lvl, new_max_occs), inv') -> + lli { lli_max = new_lvl + , lli_inv = inv' + , lli_non_max_lvls = nonDetFoldUniqSlimSet (\u nml -> delFromUFM_Directly nml u) (lli_non_max_lvls lli) new_max_occs + } -------------------- transClosureFV :: VarEnv VarSet -> VarEnv VarSet @@ -2976,34 +3018,83 @@ info then simply means setting the corresponding zapped set to the whole 'OccInfoEnv', a fast O(1) operation. -} -type OccInfoEnv = IdEnv OccInfo -- A finite map from ids to their usage - -- INVARIANT: never IAmDead - -- (Deadness is signalled by not being in the map at all) +type LoopLevel = Int + +-- | Level 0 is the loop level we never exit. Every letrec binder will have loop +-- level at least 1. +notLooping :: LoopLevel +notLooping = 0 + +type LoopLevelMap = IntMap + +type OccInfoEnv = IdEnv OccInfo + -- ^ A finite map from ids to their usage. + -- INVARIANT: The OccInfo is never IAmDead + -- (Deadness is signalled by not being in the map at all) type ZappedSet = OccInfoEnv -- Values are ignored +-- | Represents an efficient bidirectional mapping between occuring 'Id's +-- and the maximum 'LoopLevel' of the recursive binders with which they +-- co-occur. +data LoopLevelInfo + = LLI { lli_max :: !LoopLevel + -- ^ Maximum loop level of a rec binder occuring in the expression + , lli_non_max_lvls :: !(IdEnv Int) + -- ^ Binders that (are not dead, and) do not occur at loop level + -- 'lli_max' will have their loop-level stated here. + , lli_inv :: !(LoopLevelMap VarSlimSet) + -- ^ Inverse mapping of 'lli_non_max_lvls'. + -- If a binder has max loop level l, it will be regarded as "used on an + -- exit path" wrt. the loop with level l. + -- INVARIANT: The sets for different levels are disjoint + } + + data UsageDetails = UD { ud_env :: !OccInfoEnv + , ud_loop_info :: !LoopLevelInfo , ud_z_many :: !ZappedSet -- apply 'markMany' to these , ud_z_in_lam :: !ZappedSet -- apply 'markInsideLam' to these , ud_z_no_tail :: !ZappedSet } -- apply 'markNonTail' to these -- INVARIANT: All three zapped sets are subsets of the OccInfoEnv instance Outputable UsageDetails where - ppr ud = ppr (ud_env (flattenUsageDetails ud)) + ppr ud = ppr (ud_env (flattenUsageDetails ud)) $$ ppr (ud_loop_info ud) + +instance Outputable LoopLevelInfo where + ppr LLI{lli_max=lvl, lli_non_max_lvls=lvls} = int lvl <> ppr lvls ------------------- -- UsageDetails API andUDs, orUDs :: UsageDetails -> UsageDetails -> UsageDetails -andUDs = combineUsageDetailsWith addOccInfo -orUDs = combineUsageDetailsWith orOccInfo +andUDs = combineUsageDetailsWith addOccInfo andLoopLevelInfo +orUDs = combineUsageDetailsWith orOccInfo orLoopLevelInfo + +andLoopLevelInfo :: LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo +andLoopLevelInfo lvl _occs lli = markAllLoopLevel lvl lli + +orLoopLevelInfo :: LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo +orLoopLevelInfo other_max occs lli + | other_max <= our_max = lli + | otherwise = LLI { lli_max = other_max + , lli_non_max_lvls = non_max_lvls' + , lli_inv = inv' + } + where + our_max = lli_max lli + our_max_occs = occs `minusVarEnv` lli_non_max_lvls lli + inv' = IntMap.insert our_max (ufmDom our_max_occs) (lli_inv lli) + non_max_lvls' = mapVarEnv (const our_max) our_max_occs `plusVarEnv` lli_non_max_lvls lli -- NB: plusVarEnv is right-biased, so lower level wins -mkOneOcc :: Id -> InterestingCxt -> JoinArity -> UsageDetails -mkOneOcc id int_cxt arity +mkOneOcc :: OccEnv -> Id -> InterestingCxt -> JoinArity -> UsageDetails +mkOneOcc env id int_cxt arity | isLocalId id - = emptyDetails { ud_env = unitVarEnv id occ_info } + , let !lvl = lookupLoopLevel env id + = emptyDetails { ud_env = unitVarEnv id occ_info + , ud_loop_info = emptyLoopLevelInfo { lli_max = lvl } } | otherwise = emptyDetails where @@ -3038,14 +3129,36 @@ addLamCoVarOccs uds bndrs delDetails :: UsageDetails -> Id -> UsageDetails delDetails ud bndr - = ud `alterUsageDetails` (`delVarEnv` bndr) + = ud `alterUsageDetails` (`delVarEnv` bndr) `alterLoopLevelInfo` (`delLoopLevel` bndr) delDetailsList :: UsageDetails -> [Id] -> UsageDetails delDetailsList ud bndrs - = ud `alterUsageDetails` (`delVarEnvList` bndrs) + = ud `alterUsageDetails` (`delVarEnvList` bndrs) `alterLoopLevelInfo` (`delLoopLevelList` bndrs) + +delLoopLevel :: LoopLevelInfo -> Id -> LoopLevelInfo +delLoopLevel lli@(LLI { lli_non_max_lvls = nml, lli_inv = inv }) id + | Just lvl <- lookupVarEnv (lli_non_max_lvls lli) id + = lli { lli_non_max_lvls = delVarEnv nml id + , lli_inv = IntMap.adjust (`delUniqSlimSet` id) lvl inv } + | otherwise + = lli + +delLoopLevelList :: LoopLevelInfo -> [Id] -> LoopLevelInfo +delLoopLevelList lli@(LLI { lli_non_max_lvls = nml, lli_inv = inv }) ids + = lli { lli_non_max_lvls = delVarEnvList nml ids + , lli_inv = foldr (IntMap.adjust (`minusUniqSlimSet` ids_set)) inv lvls } + where + ids_set = mkUniqSlimSet ids + lvls = mapMaybe (lookupVarEnv (lli_non_max_lvls lli)) ids + +emptyLoopLevelInfo :: LoopLevelInfo +emptyLoopLevelInfo = LLI { lli_max = notLooping + , lli_non_max_lvls = emptyVarEnv + , lli_inv = IntMap.empty } emptyDetails :: UsageDetails emptyDetails = UD { ud_env = emptyVarEnv + , ud_loop_info = emptyLoopLevelInfo , ud_z_many = emptyVarEnv , ud_z_in_lam = emptyVarEnv , ud_z_no_tail = emptyVarEnv } @@ -3067,9 +3180,21 @@ markAllInsideLamIf False ud = ud markAllNonTailIf True ud = markAllNonTail ud markAllNonTailIf False ud = ud - markAllManyNonTail = markAllMany . markAllNonTail -- effectively sets to noOccInfo +markAllLoopLevel :: LoopLevel -> LoopLevelInfo -> LoopLevelInfo +markAllLoopLevel lvl lli + | lvl >= lli_max lli = LLI { lli_max = lvl, lli_non_max_lvls = emptyVarEnv, lli_inv = IntMap.empty } + | otherwise = LLI { lli_max = lli_max lli + , lli_non_max_lvls = non_max_lvls' + , lli_inv = inv' + } + where + (lower, mb_exact, higher) = IntMap.splitLookup lvl (lli_inv lli) + raised_vars = IntMap.foldr unionUniqSlimSet (mb_exact `orElse` emptyUniqSlimSet) lower + inv' = IntMap.insert lvl raised_vars higher + non_max_lvls' = nonDetFoldUniqSlimSet (\u lvls -> addToUFM_Directly lvls u lvl) (lli_non_max_lvls lli) raised_vars + lookupDetails :: UsageDetails -> Id -> OccInfo lookupDetails ud id = case lookupVarEnv (ud_env ud) id of @@ -3090,16 +3215,33 @@ restrictFreeVars bndrs fvs = restrictUniqSetToUFM bndrs fvs -- Auxiliary functions for UsageDetails implementation combineUsageDetailsWith :: (OccInfo -> OccInfo -> OccInfo) + -> (LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo) -> UsageDetails -> UsageDetails -> UsageDetails -combineUsageDetailsWith plus_occ_info ud1 ud2 +combineUsageDetailsWith plus_occ_info bump_loop_info ud1 ud2 | isEmptyDetails ud1 = ud2 | isEmptyDetails ud2 = ud1 | otherwise = UD { ud_env = plusVarEnv_C plus_occ_info (ud_env ud1) (ud_env ud2) + , ud_loop_info = combineLoopLevelInfoWith bump_loop_info (ud_env ud1) (ud_loop_info ud1) (ud_env ud2) (ud_loop_info ud2) , ud_z_many = plusVarEnv (ud_z_many ud1) (ud_z_many ud2) , ud_z_in_lam = plusVarEnv (ud_z_in_lam ud1) (ud_z_in_lam ud2) , ud_z_no_tail = plusVarEnv (ud_z_no_tail ud1) (ud_z_no_tail ud2) } +combineLoopLevelInfoWith :: (LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo) + -> OccInfoEnv -> LoopLevelInfo + -> OccInfoEnv -> LoopLevelInfo + -> LoopLevelInfo +combineLoopLevelInfoWith bump_loop_info u1 lli1 u2 lli2 + = assert (lli_max lli1' == lli_max lli2') $ + assert (lli_max lli1' == lli_max lli1 `max` lli_max lli2) $ + LLI { lli_max = lli_max lli1 `max` lli_max lli2 + , lli_non_max_lvls = plusVarEnv_C max (lli_non_max_lvls lli1') (lli_non_max_lvls lli2') + , lli_inv = IntMap.unionWith unionUniqSlimSet (lli_inv lli1') (lli_inv lli2') + } + where + lli1' = bump_loop_info (lli_max lli2) u1 lli1 + lli2' = bump_loop_info (lli_max lli1) u2 lli2 + doZapping :: UsageDetails -> Var -> OccInfo -> OccInfo doZapping ud var occ = doZappingByUnique ud (varUnique var) occ @@ -3119,14 +3261,19 @@ doZappingByUnique (UD { ud_z_many = many alterUsageDetails :: UsageDetails -> (OccInfoEnv -> OccInfoEnv) -> UsageDetails alterUsageDetails !ud f - = UD { ud_env = f (ud_env ud) + = ud { ud_env = f (ud_env ud) , ud_z_many = f (ud_z_many ud) , ud_z_in_lam = f (ud_z_in_lam ud) , ud_z_no_tail = f (ud_z_no_tail ud) } +alterLoopLevelInfo :: UsageDetails -> (LoopLevelInfo -> LoopLevelInfo) -> UsageDetails +alterLoopLevelInfo !ud f + = ud { ud_loop_info = f (ud_loop_info ud) } + flattenUsageDetails :: UsageDetails -> UsageDetails flattenUsageDetails ud@(UD { ud_env = env }) = UD { ud_env = mapUFM_Directly (doZappingByUnique ud) env + , ud_loop_info = ud_loop_info ud , ud_z_many = emptyVarEnv , ud_z_in_lam = emptyVarEnv , ud_z_no_tail = emptyVarEnv } @@ -3134,16 +3281,23 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] adjustRhsUsage :: Maybe JoinArity + -> OccInfo -> CoreExpr -- Rhs, AFTER occ anal -> UsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustRhsUsage mb_join_arity occ rhs usage = -- c.f. occAnal (Lam {}) - markAllInsideLamIf (not one_shot) $ + -- pprTrace "adjust" (ppr mb_join_arity <+> ppr occ <+> ppr rhs <+> ppr usage) $ + markAllInsideLamIf (not one_shot && not occ_one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs + occ_one_shot = case occ of + IAmDead -> True + OneOcc{} -> occ_in_lam occ == NotInsideLam + _ -> False + exact_join = exactJoin mb_join_arity bndrs (bndrs,_) = collectBinders rhs @@ -3212,20 +3366,20 @@ tagRecBinders :: TopLevelFlag -- At top level? tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s + bndrs_ne = expectJust "empty list of bndrs" $ nonEmpty bndrs rhs_udss = map nd_uds details_s - + body_occ = case filter (not . isDeadOcc) (map (lookupDetails body_uds) bndrs) of + [] -> IAmDead + o:os -> foldr addOccInfo o os -- 1. Determine join-point-hood of whole group, as determined by -- the *unadjusted* usage details unadj_uds = foldr andUDs body_uds rhs_udss - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) + will_be_joins = decideJoinPointHood lvl unadj_uds bndrs_ne -- 2. Adjust usage details of each RHS, taking into account the -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds + rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) body_occ rhs rhs_uds | ND { nd_bndr = bndr, nd_uds = rhs_uds , nd_rhs = rhs } <- details_s ] ===================================== compiler/GHC/Types/Unique/SlimSet.hs ===================================== @@ -11,7 +11,8 @@ module GHC.Types.Unique.SlimSet ( minusUniqSlimSet, unionUniqSlimSet, unionUniqSlimSets, ufmDom, -- * Querying - isEmptyUniqSlimSet, sizeUniqSlimSet, elemUniqSlimSet + isEmptyUniqSlimSet, sizeUniqSlimSet, elemUniqSlimSet, + nonDetEltsUniqSlimSet, nonDetFoldUniqSlimSet ) where import GHC.Prelude @@ -76,6 +77,12 @@ unionUniqSlimSet (UniqSlimSet set1) (UniqSlimSet set2) = UniqSlimSet (set1 `S.un unionUniqSlimSets :: [UniqSlimSet a] -> UniqSlimSet a unionUniqSlimSets = foldl' (flip unionUniqSlimSet) emptyUniqSlimSet +nonDetEltsUniqSlimSet :: UniqSlimSet a -> [Unique] +nonDetEltsUniqSlimSet (UniqSlimSet s) = map mkUniqueGrimily (S.elems s) + +nonDetFoldUniqSlimSet :: (Unique -> acc -> acc) -> acc -> UniqSlimSet a -> acc +nonDetFoldUniqSlimSet f acc (UniqSlimSet s) = S.foldr (f . mkUniqueGrimily) acc s + instance Outputable (UniqSlimSet a) where ppr (UniqSlimSet s) = braces $ hcat $ punctuate comma [ ppr (getUnique i) | i <- S.toList s] ===================================== libraries/ghc-bignum/src/GHC/Num/WordArray.hs ===================================== @@ -51,6 +51,7 @@ withNewWordArray# sz act = case runRW# io of (# _, a #) -> a case act mwa s of { s -> unsafeFreezeByteArray# mwa s }} +{-# INLINE withNewWordArray# #-} -- | Create two new WordArray# of the given sizes (*in Word#*) and apply the -- action to them before returning them frozen @@ -86,6 +87,7 @@ withNewWordArrayTrimmed# withNewWordArrayTrimmed# sz act = withNewWordArray# sz \mwa s -> case act mwa s of s' -> mwaTrimZeroes# mwa s' +{-# INLINE withNewWordArrayTrimmed# #-} -- | Create two new WordArray# of the given sizes (*in Word#*), apply the action -- to them, trim their most significant zeroes, then return them frozen @@ -101,6 +103,7 @@ withNewWordArray2Trimmed# sz1 sz2 act = withNewWordArray2# sz1 sz2 \mwa1 mwa2 s case act mwa1 mwa2 s of s' -> case mwaTrimZeroes# mwa1 s' of s'' -> mwaTrimZeroes# mwa2 s'' +{-# INLINE withNewWordArray2Trimmed# #-} -- | Create a new WordArray# of the given size (*in Word#*), apply the action to -- it. If the action returns true#, trim its most significant zeroes, then @@ -118,6 +121,7 @@ withNewWordArrayTrimmedMaybe# sz act = case runRW# io of (# _, a #) -> a (# s, _ #) -> case mwaTrimZeroes# mwa s of s -> case unsafeFreezeByteArray# mwa s of (# s, ba #) -> (# s, (# | ba #) #) +{-# INLINE withNewWordArrayTrimmedMaybe# #-} -- | Create a WordArray# from two Word# -- @@ -296,6 +300,7 @@ mwaInitArrayBinOp mwa wa wb op s = go 0# s case indexWordArray# wa i `op` indexWordArray# wb i of v -> case mwaWrite# mwa i v s' of s'' -> go (i +# 1#) s'' +{-# INLINE mwaInitArrayBinOp #-} -- | Write an element of the MutableWordArray mwaWrite# :: MutableWordArray# s -> Int# -> Word# -> State# s -> State# s View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/554ea79fd60e8de15680359fa8a007e4671a4580 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/554ea79fd60e8de15680359fa8a007e4671a4580 You're receiving 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 Nov 9 15:56:45 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 09 Nov 2022 10:56:45 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22434 Message-ID: <636bcdbd39bbf_10da055ac8adc70249c@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22434 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22434 You're receiving 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 Nov 9 16:11:37 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Wed, 09 Nov 2022 11:11:37 -0500 Subject: [Git][ghc/ghc][wip/js-staging] Make field lazy Message-ID: <636bd13964f5d_10da054796c98709175@gitlab.mail> Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC Commits: 3e1d171e by Sylvain Henry at 2022-11-09T17:15:07+01:00 Make field lazy - - - - - 1 changed file: - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -172,7 +172,7 @@ handleData (BinMem _ ixr _ binr) = BinData <$> readFastMutInt ixr <*> readIORef data BinHandle = BinMem { -- binary data stored in an unboxed array - bh_usr :: !UserData, -- sigh, need parameterized modules :-) + bh_usr :: UserData, -- sigh, need parameterized modules :-) _off_r :: !FastMutInt, -- the current offset _sz_r :: !FastMutInt, -- size of the array (cached) _arr_r :: !(IORef BinArray) -- the array (bounds: (0,size-1)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e1d171ef7adf527f5df0d8d5cc8de32f36f270a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e1d171ef7adf527f5df0d8d5cc8de32f36f270a You're receiving 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 Nov 9 17:24:50 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 09 Nov 2022 12:24:50 -0500 Subject: [Git][ghc/ghc][wip/T21851] 3 commits: Fire RULES in the Specialiser Message-ID: <636be262c4273_10da051c787b7c7158e7@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851 at Glasgow Haskell Compiler / GHC Commits: 31761130 by Simon Peyton Jones at 2022-11-09T17:26:29+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. - - - - - abd2160f by Simon Peyton Jones at 2022-11-09T17:26:29+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 03e7ad7d by Simon Peyton Jones at 2022-11-09T17:26:29+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - 20 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/Unit/External.hs - libraries/base/GHC/Ix.hs - libraries/base/GHC/Real.hs - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T21851_2.hs - + testsuite/tests/simplCore/should_compile/T21851_2.stderr - + testsuite/tests/simplCore/should_compile/T21851_2a.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -85,9 +85,8 @@ module GHC.Core ( IsOrphan(..), isOrphan, notOrphan, chooseOrphanAnchor, -- * Core rule data types - CoreRule(..), RuleBase, - RuleName, RuleFun, IdUnfoldingFun, InScopeEnv, - RuleEnv(..), RuleOpts, mkRuleEnv, emptyRuleEnv, + CoreRule(..), + RuleName, RuleFun, IdUnfoldingFun, InScopeEnv, RuleOpts, -- ** Operations on 'CoreRule's ruleArity, ruleName, ruleIdName, ruleActivation, @@ -105,7 +104,6 @@ import GHC.Core.Coercion import GHC.Core.Rules.Config ( RuleOpts ) import GHC.Types.Name import GHC.Types.Name.Set -import GHC.Types.Name.Env( NameEnv ) import GHC.Types.Literal import GHC.Types.Tickish import GHC.Core.DataCon @@ -1062,6 +1060,12 @@ has two major consequences M. But it's painful, because it means we need to keep track of all the orphan modules below us. + * The "visible orphan modules" are all the orphan module in the transitive + closure of the imports of this module. + + * During instance lookup, we filter orphan instances depending on + whether or not the instance is in a visible orphan module. + * A non-orphan is not finger-printed separately. Instead, for fingerprinting purposes it is treated as part of the entity it mentions on the LHS. For example @@ -1076,12 +1080,20 @@ has two major consequences Orphan-hood is computed * For class instances: - when we make a ClsInst - (because it is needed during instance lookup) + when we make a ClsInst in GHC.Core.InstEnv.mkLocalInstance + (because it is needed during instance lookup) + See Note [When exactly is an instance decl an orphan?] + in GHC.Core.InstEnv + + * For rules + when we generate a CoreRule (GHC.Core.Rules.mkRule) + + * For family instances: + when we generate an IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst) + +Orphan-hood is persisted into interface files, in ClsInst, FamInst, +and CoreRules. - * For rules and family instances: - when we generate an IfaceRule (GHC.Iface.Make.coreRuleToIfaceRule) - or IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst) -} {- @@ -1096,49 +1108,6 @@ GHC.Core.FVs, GHC.Core.Subst, GHC.Core.Ppr, GHC.Core.Tidy also inspect the representation. -} --- | Gathers a collection of 'CoreRule's. Maps (the name of) an 'Id' to its rules -type RuleBase = NameEnv [CoreRule] - -- The rules are unordered; - -- we sort out any overlaps on lookup - --- | A full rule environment which we can apply rules from. Like a 'RuleBase', --- but it also includes the set of visible orphans we use to filter out orphan --- rules which are not visible (even though we can see them...) -data RuleEnv - = RuleEnv { re_base :: [RuleBase] -- See Note [Why re_base is a list] - , re_visible_orphs :: ModuleSet - } - -mkRuleEnv :: RuleBase -> [Module] -> RuleEnv -mkRuleEnv rules vis_orphs = RuleEnv [rules] (mkModuleSet vis_orphs) - -emptyRuleEnv :: RuleEnv -emptyRuleEnv = RuleEnv [] emptyModuleSet - -{- -Note [Why re_base is a list] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In Note [Overall plumbing for rules], it is explained that the final -RuleBase which we must consider is combined from 4 different sources. - -During simplifier runs, the fourth source of rules is constantly being updated -as new interfaces are loaded into the EPS. Therefore just before we check to see -if any rules match we get the EPS RuleBase and combine it with the existing RuleBase -and then perform exactly 1 lookup into the new map. - -It is more efficient to avoid combining the environments and store the uncombined -environments as we can instead perform 1 lookup into each environment and then combine -the results. - -Essentially we use the identity: - -> lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) -> = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 - -The latter being more efficient as we don't construct an intermediate -map. --} -- | A 'CoreRule' is: -- ===================================== compiler/GHC/Core/InstEnv.hs ===================================== @@ -323,7 +323,9 @@ mkImportedInstance cls_nm mb_tcs dfun_name dfun oflag orphan {- Note [When exactly is an instance decl an orphan?] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - (see GHC.Iface.Make.instanceToIfaceInst, which implements this) +(See GHC.Iface.Make.instanceToIfaceInst, which implements this.) +See Note [Orphans] in GHC.Core + Roughly speaking, an instance is an orphan if its head (after the =>) mentions nothing defined in this module. ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -1520,6 +1520,9 @@ $wtheresCrud = \ ww ww1 -> ... ``` This is currently a bug that we willingly accept and it's documented in #21128. + +See also Note [indexError] in base:GHC.Ix, which describes how we use +SPECIALISE to mitigate this problem for indexError. -} {- ********************************************************************* ===================================== compiler/GHC/Core/Opt/Monad.hs ===================================== @@ -19,10 +19,10 @@ module GHC.Core.Opt.Monad ( -- ** Reading from the monad getHscEnv, getModule, - getRuleBase, getExternalRuleBase, + initRuleEnv, getExternalRuleBase, getDynFlags, getPackageFamInstEnv, getInteractiveContext, - getVisibleOrphanMods, getUniqMask, + getUniqMask, getPrintUnqualified, getSrcSpanM, -- ** Writing to the monad @@ -45,7 +45,7 @@ import GHC.Prelude hiding ( read ) import GHC.Driver.Session import GHC.Driver.Env -import GHC.Core +import GHC.Core.Rules ( RuleBase, RuleEnv, mkRuleEnv ) import GHC.Core.Opt.Stats ( SimplCount, zeroSimplCount, plusSimplCount ) import GHC.Types.Annotations @@ -114,12 +114,11 @@ pprFloatOutSwitches sw data CoreReader = CoreReader { cr_hsc_env :: HscEnv, - cr_rule_base :: RuleBase, + cr_rule_base :: RuleBase, -- Home package table rules cr_module :: Module, cr_print_unqual :: PrintUnqualified, cr_loc :: SrcSpan, -- Use this for log/error messages so they -- are at least tagged with the right source file - cr_visible_orphan_mods :: !ModuleSet, cr_uniq_mask :: !Char -- Mask for creating unique values } @@ -181,19 +180,17 @@ runCoreM :: HscEnv -> RuleBase -> Char -- ^ Mask -> Module - -> ModuleSet -> PrintUnqualified -> SrcSpan -> CoreM a -> IO (a, SimplCount) -runCoreM hsc_env rule_base mask mod orph_imps print_unqual loc m +runCoreM hsc_env rule_base mask mod print_unqual loc m = liftM extract $ runIOEnv reader $ unCoreM m where reader = CoreReader { cr_hsc_env = hsc_env, cr_rule_base = rule_base, cr_module = mod, - cr_visible_orphan_mods = orph_imps, cr_print_unqual = print_unqual, cr_loc = loc, cr_uniq_mask = mask @@ -245,15 +242,18 @@ liftIOWithCount what = liftIO what >>= (\(count, x) -> addSimplCount count >> re getHscEnv :: CoreM HscEnv getHscEnv = read cr_hsc_env -getRuleBase :: CoreM RuleBase -getRuleBase = read cr_rule_base +getHomeRuleBase :: CoreM RuleBase +getHomeRuleBase = read cr_rule_base + +initRuleEnv :: ModGuts -> CoreM RuleEnv +initRuleEnv guts + = do { hpt_rules <- getHomeRuleBase + ; eps_rules <- getExternalRuleBase + ; return (mkRuleEnv guts eps_rules hpt_rules) } getExternalRuleBase :: CoreM RuleBase getExternalRuleBase = eps_rule_base <$> get_eps -getVisibleOrphanMods :: CoreM ModuleSet -getVisibleOrphanMods = read cr_visible_orphan_mods - getPrintUnqualified :: CoreM PrintUnqualified getPrintUnqualified = read cr_print_unqual ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -22,7 +22,7 @@ import GHC.Platform.Ways ( hasWay, Way(WayProf) ) import GHC.Core import GHC.Core.Opt.CSE ( cseProgram ) -import GHC.Core.Rules ( mkRuleBase, ruleCheckProgram, getRules ) +import GHC.Core.Rules ( RuleBase, mkRuleBase, ruleCheckProgram, getRules ) import GHC.Core.Ppr ( pprCoreBindings ) import GHC.Core.Utils ( dumpIdInfoOfProgram ) import GHC.Core.Lint ( lintAnnots ) @@ -53,9 +53,7 @@ import GHC.Utils.Logger as Logger import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Unit.Module.Env import GHC.Unit.Module.ModGuts -import GHC.Unit.Module.Deps import GHC.Types.Id.Info import GHC.Types.Basic @@ -78,14 +76,12 @@ import GHC.Unit.Module core2core :: HscEnv -> ModGuts -> IO ModGuts core2core hsc_env guts@(ModGuts { mg_module = mod , mg_loc = loc - , mg_deps = deps , mg_rdr_env = rdr_env }) = do { let builtin_passes = getCoreToDo dflags hpt_rule_base extra_vars - orph_mods = mkModuleSet (mod : dep_orphs deps) uniq_mask = 's' - ; + ; (guts2, stats) <- runCoreM hsc_env hpt_rule_base uniq_mask mod - orph_mods print_unqual loc $ + print_unqual loc $ do { hsc_env' <- getHscEnv ; all_passes <- withPlugins (hsc_plugins hsc_env') installCoreToDos @@ -121,7 +117,8 @@ core2core hsc_env guts@(ModGuts { mg_module = mod -} getCoreToDo :: DynFlags -> RuleBase -> [Var] -> [CoreToDo] -getCoreToDo dflags rule_base extra_vars +-- This function builds the pipeline of optimisations +getCoreToDo dflags hpt_rule_base extra_vars = flatten_todos core_todo where phases = simplPhases dflags @@ -176,7 +173,7 @@ getCoreToDo dflags rule_base extra_vars ---------------------------- run_simplifier mode iter - = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode rule_base + = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode hpt_rule_base simpl_phase phase name iter = CoreDoPasses $ [ maybe_strictness_before phase @@ -573,11 +570,9 @@ ruleCheckPass current_phase pat guts = do logger <- getLogger withTiming logger (text "RuleCheck"<+>brackets (ppr $ mg_module guts)) (const ()) $ do - rb <- getRuleBase - vis_orphs <- getVisibleOrphanMods - let rule_fn fn = getRules (RuleEnv [rb] vis_orphs) fn - ++ (mg_rules guts) - let ropts = initRuleOpts dflags + rule_env <- initRuleEnv guts + let rule_fn fn = getRules rule_env fn + ropts = initRuleOpts dflags liftIO $ logDumpMsg logger "Rule check" (ruleCheckProgram ropts current_phase pat rule_fn (mg_binds guts)) ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -10,7 +10,7 @@ import GHC.Prelude import GHC.Driver.Flags import GHC.Core -import GHC.Core.Rules ( extendRuleBaseList, extendRuleEnv, addRuleInfo ) +import GHC.Core.Rules import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize ) @@ -31,7 +31,6 @@ import GHC.Utils.Constants (debugIsOn) import GHC.Unit.Env ( UnitEnv, ueEPS ) import GHC.Unit.External import GHC.Unit.Module.ModGuts -import GHC.Unit.Module.Deps import GHC.Types.Id import GHC.Types.Id.Info @@ -81,7 +80,7 @@ simplifyExpr logger euc opts expr simpl_env = mkSimplEnv (se_mode opts) fam_envs top_env_cfg = se_top_env_cfg opts read_eps_rules = eps_rule_base <$> eucEPS euc - read_ruleenv = extendRuleEnv emptyRuleEnv <$> read_eps_rules + read_ruleenv = updExternalPackageRules emptyRuleEnv <$> read_eps_rules ; let sz = exprSize expr @@ -132,11 +131,11 @@ simplExprGently env expr = do -- The values of this datatype are /only/ driven by the demands of that function. data SimplifyOpts = SimplifyOpts { so_dump_core_sizes :: !Bool - , so_iterations :: !Int - , so_mode :: !SimplMode + , so_iterations :: !Int + , so_mode :: !SimplMode , so_pass_result_cfg :: !(Maybe LintPassResultConfig) - , so_rule_base :: !RuleBase - , so_top_env_cfg :: !TopEnvConfig + , so_hpt_rules :: !RuleBase + , so_top_env_cfg :: !TopEnvConfig } simplifyPgm :: Logger @@ -148,11 +147,10 @@ simplifyPgm :: Logger simplifyPgm logger unit_env opts guts@(ModGuts { mg_module = this_mod , mg_rdr_env = rdr_env - , mg_deps = deps - , mg_binds = binds, mg_rules = rules + , mg_binds = binds, mg_rules = local_rules , mg_fam_inst_env = fam_inst_env }) = do { (termination_msg, it_count, counts_out, guts') - <- do_iteration 1 [] binds rules + <- do_iteration 1 [] binds local_rules ; when (logHasDumpFlag logger Opt_D_verbose_core2core && logHasDumpFlag logger Opt_D_dump_simpl_stats) $ @@ -169,7 +167,6 @@ simplifyPgm logger unit_env opts dump_core_sizes = so_dump_core_sizes opts mode = so_mode opts max_iterations = so_iterations opts - hpt_rule_base = so_rule_base opts top_env_cfg = so_top_env_cfg opts print_unqual = mkPrintUnqualified unit_env rdr_env active_rule = activeRule mode @@ -178,13 +175,18 @@ simplifyPgm logger unit_env opts -- the old bindings are retained until the end of all simplifier iterations !guts_no_binds = guts { mg_binds = [], mg_rules = [] } + hpt_rule_env :: RuleEnv + hpt_rule_env = mkRuleEnv guts emptyRuleBase (so_hpt_rules opts) + -- emptyRuleBase: no EPS rules yet; we will update + -- them on each iteration to pick up the most up to date set + do_iteration :: Int -- Counts iterations -> [SimplCount] -- Counts from earlier iterations, reversed - -> CoreProgram -- Bindings in - -> [CoreRule] -- and orphan rules + -> CoreProgram -- Bindings + -> [CoreRule] -- Local rules for imported Ids -> IO (String, Int, SimplCount, ModGuts) - do_iteration iteration_no counts_so_far binds rules + do_iteration iteration_no counts_so_far binds local_rules -- iteration_no is the number of the iteration we are -- about to begin, with '1' for the first | iteration_no > max_iterations -- Stop if we've run out of iterations @@ -200,7 +202,7 @@ simplifyPgm logger unit_env opts -- number of iterations we actually completed return ( "Simplifier baled out", iteration_no - 1 , totalise counts_so_far - , guts_no_binds { mg_binds = binds, mg_rules = rules } ) + , guts_no_binds { mg_binds = binds, mg_rules = local_rules } ) -- Try and force thunks off the binds; significantly reduces -- space usage, especially with -O. JRS, 000620. @@ -209,8 +211,8 @@ simplifyPgm logger unit_env opts = do { -- Occurrence analysis let { tagged_binds = {-# SCC "OccAnal" #-} - occurAnalysePgm this_mod active_unf active_rule rules - binds + occurAnalysePgm this_mod active_unf active_rule + local_rules binds } ; Logger.putDumpFileMaybe logger Opt_D_dump_occur_anal "Occurrence analysis" FormatCore @@ -221,24 +223,29 @@ simplifyPgm logger unit_env opts -- poke on IdInfo thunks, which in turn brings in new rules -- behind the scenes. Otherwise there's a danger we'll simply -- miss the rules for Ids hidden inside imported inlinings - -- Hence just before attempting to match rules we read on the EPS - -- value and then combine it when the existing rule base. + -- Hence just before attempting to match a rule we read the EPS + -- value (via read_rule_env) and then combine it with the existing rule base. -- See `GHC.Core.Opt.Simplify.Monad.getSimplRules`. - eps <- ueEPS unit_env ; - let { -- Forcing this value to avoid unnessecary allocations. + eps <- ueEPS unit_env ; + let { -- base_rule_env contains + -- (a) home package rules, fixed across all iterations + -- (b) local rules (substituted) from `local_rules` arg to do_iteration + -- Forcing base_rule_env to avoid unnecessary allocations. -- Not doing so results in +25.6% allocations of LargeRecord. - ; !rule_base = extendRuleBaseList hpt_rule_base rules - ; vis_orphs = this_mod : dep_orphs deps - ; base_ruleenv = mkRuleEnv rule_base vis_orphs + ; !base_rule_env = updLocalRules hpt_rule_env local_rules + + ; read_eps_rules :: IO PackageRuleBase ; read_eps_rules = eps_rule_base <$> ueEPS unit_env - ; read_ruleenv = extendRuleEnv base_ruleenv <$> read_eps_rules + + ; read_rule_env :: IO RuleEnv + ; read_rule_env = updExternalPackageRules base_rule_env <$> read_eps_rules ; fam_envs = (eps_fam_inst_env eps, fam_inst_env) ; simpl_env = mkSimplEnv mode fam_envs } ; -- Simplify the program ((binds1, rules1), counts1) <- - initSmpl logger read_ruleenv top_env_cfg sz $ + initSmpl logger read_rule_env top_env_cfg sz $ do { (floats, env1) <- {-# SCC "SimplTopBinds" #-} simplTopBinds simpl_env tagged_binds @@ -246,7 +253,7 @@ simplifyPgm logger unit_env opts -- for imported Ids. Eg RULE map my_f = blah -- If we have a substitution my_f :-> other_f, we'd better -- apply it to the rule to, or it'll never match - ; rules1 <- simplImpRules env1 rules + ; rules1 <- simplImpRules env1 local_rules ; return (getTopFloatBinds floats, rules1) } ; ===================================== compiler/GHC/Core/Opt/Simplify/Monad.hs ===================================== @@ -27,8 +27,8 @@ import GHC.Types.Name ( mkSystemVarName ) import GHC.Types.Id ( Id, mkSysLocalOrCoVarM ) import GHC.Types.Id.Info ( IdDetails(..), vanillaIdInfo, setArityInfo ) import GHC.Core.Type ( Type, Mult ) -import GHC.Core ( RuleEnv(..) ) import GHC.Core.Opt.Stats +import GHC.Core.Rules import GHC.Core.Utils ( mkLamTypes ) import GHC.Types.Unique.Supply import GHC.Driver.Flags ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -53,7 +53,7 @@ import GHC.Core.Ppr import GHC.Core.TyCo.Ppr ( pprParendType ) import GHC.Core.FVs import GHC.Core.Utils -import GHC.Core.Rules( getRules ) +import GHC.Core.Rules( RuleEnv, getRules ) import GHC.Core.Opt.Arity import GHC.Core.Unfold import GHC.Core.Unfold.Make ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -17,6 +17,7 @@ import GHC.Driver.Config.Core.Rules ( initRuleOpts ) import GHC.Core.Type hiding( substTy, substCo, extendTvSubst, zapSubst ) import GHC.Core.Multiplicity +import GHC.Core.SimpleOpt( defaultSimpleOpts, simpleOptExprWith ) import GHC.Core.Predicate import GHC.Core.Coercion( Coercion ) import GHC.Core.Opt.Monad @@ -636,9 +637,11 @@ Hence, the invariant is this: -- | Specialise calls to type-class overloaded functions occurring in a program. specProgram :: ModGuts -> CoreM ModGuts specProgram guts@(ModGuts { mg_module = this_mod - , mg_rules = local_rules - , mg_binds = binds }) - = do { dflags <- getDynFlags + , mg_rules = local_rules + , mg_binds = binds }) + = do { dflags <- getDynFlags + ; rule_env <- initRuleEnv guts + -- See Note [Fire rules in the specialiser] -- We need to start with a Subst that knows all the things -- that are in scope, so that the substitution engine doesn't @@ -650,6 +653,7 @@ specProgram guts@(ModGuts { mg_module = this_mod -- mkInScopeSetList $ -- bindersOfBinds binds , se_module = this_mod + , se_rules = rule_env , se_dflags = dflags } go [] = return ([], emptyUDs) @@ -660,7 +664,7 @@ specProgram guts@(ModGuts { mg_module = this_mod -- Specialise the bindings of this module ; (binds', uds) <- runSpecM (go binds) - ; (spec_rules, spec_binds) <- specImports top_env local_rules uds + ; (spec_rules, spec_binds) <- specImports top_env uds ; return (guts { mg_binds = spec_binds ++ binds' , mg_rules = spec_rules ++ local_rules }) } @@ -725,21 +729,15 @@ specialisation (see canSpecImport): -} specImports :: SpecEnv - -> [CoreRule] -> UsageDetails -> CoreM ([CoreRule], [CoreBind]) -specImports top_env local_rules - (MkUD { ud_binds = dict_binds, ud_calls = calls }) +specImports top_env (MkUD { ud_binds = dict_binds, ud_calls = calls }) | not $ gopt Opt_CrossModuleSpecialise (se_dflags top_env) -- See Note [Disabling cross-module specialisation] = return ([], wrapDictBinds dict_binds []) | otherwise - = do { hpt_rules <- getRuleBase - ; let rule_base = extendRuleBaseList hpt_rules local_rules - - ; (spec_rules, spec_binds) <- spec_imports top_env [] rule_base - dict_binds calls + = do { (_env, spec_rules, spec_binds) <- spec_imports top_env [] dict_binds calls -- Don't forget to wrap the specialized bindings with -- bindings for the needed dictionaries. @@ -757,89 +755,91 @@ specImports top_env local_rules spec_imports :: SpecEnv -- Passed in so that all top-level Ids are in scope -> [Id] -- Stack of imported functions being specialised -- See Note [specImport call stack] - -> RuleBase -- Rules from this module and the home package - -- (but not external packages, which can change) -> FloatedDictBinds -- Dict bindings, used /only/ for filterCalls -- See Note [Avoiding loops in specImports] -> CallDetails -- Calls for imported things - -> CoreM ( [CoreRule] -- New rules + -> CoreM ( SpecEnv -- Env contains the new rules + , [CoreRule] -- New rules , [CoreBind] ) -- Specialised bindings -spec_imports top_env callers rule_base dict_binds calls +spec_imports env callers dict_binds calls = do { let import_calls = dVarEnvElts calls -- ; debugTraceMsg (text "specImports {" <+> -- vcat [ text "calls:" <+> ppr import_calls -- , text "dict_binds:" <+> ppr dict_binds ]) - ; (rules, spec_binds) <- go rule_base import_calls + ; (env, rules, spec_binds) <- go env import_calls -- ; debugTraceMsg (text "End specImports }" <+> ppr import_calls) - ; return (rules, spec_binds) } + ; return (env, rules, spec_binds) } where - go :: RuleBase -> [CallInfoSet] -> CoreM ([CoreRule], [CoreBind]) - go _ [] = return ([], []) - go rb (cis : other_calls) + go :: SpecEnv -> [CallInfoSet] -> CoreM (SpecEnv, [CoreRule], [CoreBind]) + go env [] = return (env, [], []) + go env (cis : other_calls) = do { -- debugTraceMsg (text "specImport {" <+> ppr cis) - ; (rules1, spec_binds1) <- spec_import top_env callers rb dict_binds cis + ; (env, rules1, spec_binds1) <- spec_import env callers dict_binds cis ; -- debugTraceMsg (text "specImport }" <+> ppr cis) - ; (rules2, spec_binds2) <- go (extendRuleBaseList rb rules1) other_calls - ; return (rules1 ++ rules2, spec_binds1 ++ spec_binds2) } + ; (env, rules2, spec_binds2) <- go env other_calls + ; return (env, rules1 ++ rules2, spec_binds1 ++ spec_binds2) } spec_import :: SpecEnv -- Passed in so that all top-level Ids are in scope -> [Id] -- Stack of imported functions being specialised -- See Note [specImport call stack] - -> RuleBase -- Rules from this module -> FloatedDictBinds -- Dict bindings, used /only/ for filterCalls -- See Note [Avoiding loops in specImports] -> CallInfoSet -- Imported function and calls for it - -> CoreM ( [CoreRule] -- New rules + -> CoreM ( SpecEnv + , [CoreRule] -- New rules , [CoreBind] ) -- Specialised bindings -spec_import top_env callers rb dict_binds cis@(CIS fn _) +spec_import env callers dict_binds cis@(CIS fn _) | isIn "specImport" fn callers - = return ([], []) -- No warning. This actually happens all the time - -- when specialising a recursive function, because - -- the RHS of the specialised function contains a recursive - -- call to the original function + = return (env, [], []) -- No warning. This actually happens all the time + -- when specialising a recursive function, because + -- the RHS of the specialised function contains a recursive + -- call to the original function | null good_calls - = return ([], []) + = return (env, [], []) | Just rhs <- canSpecImport dflags fn = do { -- Get rules from the external package state -- We keep doing this in case we "page-fault in" -- more rules as we go along - ; external_rule_base <- getExternalRuleBase - ; vis_orphs <- getVisibleOrphanMods - ; let rules_for_fn = getRules (RuleEnv [rb, external_rule_base] vis_orphs) fn + ; eps_rules <- getExternalRuleBase + ; let rule_env = se_rules env `updExternalPackageRules` eps_rules - ; -- debugTraceMsg (text "specImport1" <+> vcat [ppr fn, ppr good_calls, ppr rhs]) +-- ; debugTraceMsg (text "specImport1" <+> vcat [ppr fn, ppr good_calls +-- , ppr (getRules rule_env fn), ppr rhs]) ; (rules1, spec_pairs, MkUD { ud_binds = dict_binds1, ud_calls = new_calls }) - <- runSpecM $ specCalls True top_env dict_binds - rules_for_fn good_calls fn rhs + <- runSpecM $ specCalls True env dict_binds + (getRules rule_env fn) good_calls fn rhs ; let spec_binds1 = [NonRec b r | (b,r) <- spec_pairs] -- After the rules kick in we may get recursion, but -- we rely on a global GlomBinds to sort that out later -- See Note [Glom the bindings if imported functions are specialised] + new_subst = se_subst env `Core.extendSubstInScopeList` map fst spec_pairs + new_env = env { se_rules = rule_env `addLocalRules` rules1 + , se_subst = new_subst } + -- Now specialise any cascaded calls - ; -- debugTraceMsg (text "specImport 2" <+> (ppr fn $$ ppr rules1 $$ ppr spec_binds1)) - ; (rules2, spec_binds2) <- spec_imports top_env - (fn:callers) - (extendRuleBaseList rb rules1) - (dict_binds `thenFDBs` dict_binds1) - new_calls +-- ; debugTraceMsg (text "specImport 2" <+> (ppr fn $$ ppr rules1 $$ ppr spec_binds1)) + ; (env, rules2, spec_binds2) + <- spec_imports new_env (fn:callers) + (dict_binds `thenFDBs` dict_binds1) + new_calls ; let final_binds = wrapDictBinds dict_binds1 $ spec_binds2 ++ spec_binds1 - ; return (rules2 ++ rules1, final_binds) } + ; return (env, rules2 ++ rules1, final_binds) } | otherwise = do { tryWarnMissingSpecs dflags callers fn good_calls - ; return ([], [])} + ; return (env, [], [])} where - dflags = se_dflags top_env + dflags = se_dflags env good_calls = filterCalls cis dict_binds -- SUPER IMPORTANT! Drop calls that (directly or indirectly) refer to fn -- See Note [Avoiding loops in specImports] @@ -1134,6 +1134,7 @@ data SpecEnv -- the RHS of specialised bindings (no type-let!) , se_module :: Module + , se_rules :: RuleEnv -- From the home package and this module , se_dflags :: DynFlags } @@ -1172,8 +1173,8 @@ specExpr env expr@(App {}) ; (args_out, uds_args) <- mapAndCombineSM (specExpr env) args_in ; let env_args = env `bringFloatedDictsIntoScope` ud_binds uds_args -- Some dicts may have floated out of args_in; - -- they should be in scope for rewriteClassOps (#21689) - (fun_in', args_out') = rewriteClassOps env_args fun_in args_out + -- they should be in scope for fireRewriteRules (#21689) + (fun_in', args_out') = fireRewriteRules env_args fun_in args_out ; (fun_out', uds_fun) <- specExpr env fun_in' ; let uds_call = mkCallUDs env fun_out' args_out' ; return (fun_out' `mkApps` args_out', uds_fun `thenUDs` uds_call `thenUDs` uds_args) } @@ -1208,17 +1209,19 @@ specExpr env (Let bind body) ; return (foldr Let body' binds', uds) } -- See Note [Specialisation modulo dictionary selectors] --- and Note [ClassOp/DFun selection] -rewriteClassOps :: SpecEnv -> InExpr -> [OutExpr] -> (InExpr, [OutExpr]) -rewriteClassOps env (Var f) args - | isClassOpId f -- If we see `op_sel $fCInt`, we rewrite to `$copInt` - , Just (rule, expr) <- -- pprTrace "rewriteClassOps" (ppr f $$ ppr args $$ ppr (se_subst env)) $ - specLookupRule env f args (idCoreRules f) - , let rest_args = drop (ruleArity rule) args -- See Note [Extra args in the target] --- , pprTrace "class op rewritten" (ppr f <+> ppr args $$ ppr expr <+> ppr rest_args) True - , (fun, args) <- collectArgs expr - = rewriteClassOps env fun (args++rest_args) -rewriteClassOps _ fun args = (fun, args) +-- Note [ClassOp/DFun selection] +-- Note [Fire rules in the specialiser] +fireRewriteRules :: SpecEnv -> InExpr -> [OutExpr] -> (InExpr, [OutExpr]) +fireRewriteRules env (Var f) args + | Just (rule, expr) <- specLookupRule env f args InitialPhase (getRules (se_rules env) f) + , let rest_args = drop (ruleArity rule) args -- See Note [Extra args in the target] + zapped_subst = Core.zapSubst (se_subst env) + expr' = simpleOptExprWith defaultSimpleOpts zapped_subst expr + -- simplOptExpr needed because lookupRule returns + -- (\x y. rhs) arg1 arg2 + , (fun, args) <- collectArgs expr' + = fireRewriteRules env fun (args++rest_args) +fireRewriteRules _ fun args = (fun, args) -------------- specLam :: SpecEnv -> [OutBndr] -> InExpr -> SpecM (OutExpr, UsageDetails) @@ -1324,7 +1327,67 @@ specCase env scrut case_bndr alts where (env_rhs, args') = substBndrs env_alt args -{- +{- Note [Fire rules in the specialiser] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this (#21851) + + module A where + f :: Num b => b -> (b, b) + f x = (x + 1, snd (f x)) + {-# SPECIALIZE f :: Int -> (Int, Int) #-} + + module B (g') where + import A + + g :: Num a => a -> a + g x = fst (f x) + {-# NOINLINE[99] g #-} + + h :: Int -> Int + h = g + +Note that `f` has the CPR property, and so will worker/wrapper. + +The call to `g` in `h` will make us specialise `g @Int`. And the specialised +version of `g` will contain the call `f @Int`; but in the subsequent run of +the Simplifier, there will be a competition between: +* The user-supplied SPECIALISE rule for `f` +* The inlining of the wrapper for `f` +In fact, the latter wins -- see Note [Rewrite rules and inlining] in +GHC.Core.Opt.Simplify.Iteration. However, it a bit fragile. + +Moreover consider (test T21851_2): + + module A + f :: (Ord a, Show b) => a -> b -> blah + {-# RULE forall b. f @Int @b = wombat #-} + + wombat :: Show b => Int -> b -> blah + wombat = blah + + module B + import A + g :: forall a. Ord a => blah + g @a = ...g...f @a @Char.... + + h = ....g @Int.... + +Now, in module B, GHC will specialise `g @Int`, which will lead to a +call `f @Int @Char`. If we immediately (in the specialiser) rewrite +that to `womabat @Char`, we have a chance to specialise `wombat`. + +Conclusion: it's treat if the Specialiser fires RULEs itself. +It's not hard to achieve: see `fireRewriteRules`. The only tricky bit is +making sure that we have a reasonably up to date EPS rule base. Currently +we load it up just once, in `initRuleEnv`, called at the beginning of +`specProgram`. + +NB: you might wonder if running rules in the specialiser (this Note) +renders Note [Rewrite rules and inlining] in the Simplifier redundant. +That is, if we run rules in the specialiser, does it matter if we make +rules "win" over inlining in the Simplifier? Yes, it does! See the +discussion in #21851. + Note [Floating dictionaries out of cases] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -1415,13 +1478,12 @@ specBind top_lvl env (NonRec fn rhs) do_body final_binds :: [DictBind] -- See Note [From non-recursive to recursive] - final_binds - | not (isNilOL dump_dbs) - , not (null spec_defns) - = [recWithDumpedDicts pairs dump_dbs] - | otherwise - = [mkDB $ NonRec b r | (b,r) <- pairs] - ++ fromOL dump_dbs + final_binds | not (isNilOL dump_dbs) + , not (null spec_defns) + = [recWithDumpedDicts pairs dump_dbs] + | otherwise + = [mkDB $ NonRec b r | (b,r) <- pairs] + ++ fromOL dump_dbs ; if float_all then -- Rather than discard the calls mentioning the bound variables @@ -1553,8 +1615,10 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs foldlM spec_call ([], [], emptyUDs) calls_for_me | otherwise -- No calls or RHS doesn't fit our preconceptions - = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me) + = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me && not (isClassOpId fn)) "Missed specialisation opportunity for" (ppr fn $$ trace_doc) $ + -- isClassOpId: class-op Ids never inline; we specialise them + -- through fireRewriteRules. So don't complain about missed opportunities -- Note [Specialisation shape] -- pprTrace "specCalls: none" (ppr fn <+> ppr calls_for_me) $ return ([], [], emptyUDs) @@ -1581,9 +1645,13 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs already_covered :: SpecEnv -> [CoreRule] -> [CoreExpr] -> Bool already_covered env new_rules args -- Note [Specialisations already covered] - = isJust (specLookupRule env fn args (new_rules ++ existing_rules)) - -- NB: we look both in the new_rules (generated by this invocation - -- of specCalls), and in existing_rules (passed in to specCalls) + = isJust (specLookupRule env fn args (beginPhase inl_act) + (new_rules ++ existing_rules)) + -- Rules: we look both in the new_rules (generated by this invocation + -- of specCalls), and in existing_rules (passed in to specCalls) + -- inl_act: is the activation we are going to put in the new SPEC + -- rule; so we want to see if it is covered by another rule with + -- that same activation. ---------------------------------------------------------- -- Specialise to one particular call pattern @@ -1708,13 +1776,16 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs -- Convenience function for invoking lookupRule from Specialise -- The SpecEnv's InScopeSet should include all the Vars in the [CoreExpr] -specLookupRule :: SpecEnv -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr) -specLookupRule env fn args rules - = lookupRule ropts (in_scope, realIdUnfolding) (const True) fn args rules +specLookupRule :: SpecEnv -> Id -> [CoreExpr] + -> CompilerPhase -- Look up rules as if we were in this phase + -> [CoreRule] -> Maybe (CoreRule, CoreExpr) +specLookupRule env fn args phase rules + = lookupRule ropts (in_scope, realIdUnfolding) is_active fn args rules where - dflags = se_dflags env - in_scope = getSubstInScope (se_subst env) - ropts = initRuleOpts dflags + dflags = se_dflags env + in_scope = getSubstInScope (se_subst env) + ropts = initRuleOpts dflags + is_active = isActive phase {- Note [Specialising DFuns] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1913,10 +1984,10 @@ We want to specialise this! How? By doing the method-selection rewrite in the Specialiser. Hence 1. In the App case of 'specExpr', try to apply the ClassOp/DFun rule on the - head of the application, repeatedly, via 'rewriteClassOps'. + head of the application, repeatedly, via 'fireRewriteRules'. 2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and `$dShow` in `bindAuxiliaryDict`, so that we can exploit the unfolding - in 'rewriteClassOps' to do the ClassOp/DFun rewrite. + in 'fireRewriteRules' to do the ClassOp/DFun rewrite. NB: Without (2), (1) would be pointless, because 'lookupRule' wouldn't be able to look into the RHS of `$dC` to see the DFun. ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -12,8 +12,10 @@ module GHC.Core.Rules ( lookupRule, -- ** RuleBase, RuleEnv + RuleBase, RuleEnv(..), mkRuleEnv, emptyRuleEnv, + updExternalPackageRules, addLocalRules, updLocalRules, emptyRuleBase, mkRuleBase, extendRuleBaseList, - pprRuleBase, extendRuleEnv, + pprRuleBase, -- ** Checking rule applications ruleCheckProgram, @@ -22,6 +24,8 @@ module GHC.Core.Rules ( extendRuleInfo, addRuleInfo, addIdSpecialisations, + -- ** RuleBase and RuleEnv + -- * Misc. CoreRule helpers rulesOfBinds, getRules, pprRulesForUser, @@ -34,6 +38,8 @@ import GHC.Prelude import GHC.Unit.Module ( Module ) import GHC.Unit.Module.Env +import GHC.Unit.Module.ModGuts( ModGuts(..) ) +import GHC.Unit.Module.Deps( Dependencies(..) ) import GHC.Driver.Session( DynFlags ) import GHC.Driver.Ppr( showSDoc ) @@ -135,7 +141,7 @@ Note [Overall plumbing for rules] * At the moment (c) is carried in a reader-monad way by the GHC.Core.Opt.Monad. The HomePackageTable doesn't have a single RuleBase because technically we should only be able to "see" rules "below" this module; so we - generate a RuleBase for (c) by combing rules from all the modules + generate a RuleBase for (c) by combining rules from all the modules "below" us. That's why we can't just select the home-package RuleBase from HscEnv. @@ -339,12 +345,106 @@ addIdSpecialisations id rules rulesOfBinds :: [CoreBind] -> [CoreRule] rulesOfBinds binds = concatMap (concatMap idCoreRules . bindersOf) binds + +{- +************************************************************************ +* * + RuleBase +* * +************************************************************************ +-} + +-- | Gathers a collection of 'CoreRule's. Maps (the name of) an 'Id' to its rules +type RuleBase = NameEnv [CoreRule] + -- The rules are unordered; + -- we sort out any overlaps on lookup + +emptyRuleBase :: RuleBase +emptyRuleBase = emptyNameEnv + +mkRuleBase :: [CoreRule] -> RuleBase +mkRuleBase rules = extendRuleBaseList emptyRuleBase rules + +extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase +extendRuleBaseList rule_base new_guys + = foldl' extendRuleBase rule_base new_guys + +extendRuleBase :: RuleBase -> CoreRule -> RuleBase +extendRuleBase rule_base rule + = extendNameEnv_Acc (:) Utils.singleton rule_base (ruleIdName rule) rule + +pprRuleBase :: RuleBase -> SDoc +pprRuleBase rules = pprUFM rules $ \rss -> + vcat [ pprRules (tidyRules emptyTidyEnv rs) + | rs <- rss ] + +-- | A full rule environment which we can apply rules from. Like a 'RuleBase', +-- but it also includes the set of visible orphans we use to filter out orphan +-- rules which are not visible (even though we can see them...) +-- See Note [Orphans] in GHC.Core +data RuleEnv + = RuleEnv { re_local_rules :: !RuleBase -- Rules from this module + , re_home_rules :: !RuleBase -- Rule from the home package + -- (excl this module) + , re_eps_rules :: !RuleBase -- Rules from other packages + -- see Note [External package rules] + , re_visible_orphs :: !ModuleSet + } + +mkRuleEnv :: ModGuts -> RuleBase -> RuleBase -> RuleEnv +mkRuleEnv (ModGuts { mg_module = this_mod + , mg_deps = deps + , mg_rules = local_rules }) + eps_rules hpt_rules + = RuleEnv { re_local_rules = mkRuleBase local_rules + , re_home_rules = hpt_rules + , re_eps_rules = eps_rules + , re_visible_orphs = mkModuleSet vis_orphs } + where + vis_orphs = this_mod : dep_orphs deps + +updExternalPackageRules :: RuleEnv -> RuleBase -> RuleEnv +-- Completely over-ride the external rules in RuleEnv +updExternalPackageRules rule_env eps_rules + = rule_env { re_eps_rules = eps_rules } + +updLocalRules :: RuleEnv -> [CoreRule] -> RuleEnv +-- Completely over-ride the local rules in RuleEnv +updLocalRules rule_env local_rules + = rule_env { re_local_rules = mkRuleBase local_rules } + +addLocalRules :: RuleEnv -> [CoreRule] -> RuleEnv +-- Add new local rules +addLocalRules rule_env rules + = rule_env { re_local_rules = extendRuleBaseList (re_local_rules rule_env) rules } + +emptyRuleEnv :: RuleEnv +emptyRuleEnv = RuleEnv { re_local_rules = emptyNameEnv + , re_home_rules = emptyNameEnv + , re_eps_rules = emptyNameEnv + , re_visible_orphs = emptyModuleSet } + getRules :: RuleEnv -> Id -> [CoreRule] +-- Given a RuleEnv and an Id, find the visible rules for that Id -- See Note [Where rules are found] -getRules (RuleEnv { re_base = rule_base, re_visible_orphs = orphs }) fn - = idCoreRules fn ++ concatMap imp_rules rule_base +getRules (RuleEnv { re_local_rules = local_rules + , re_home_rules = home_rules + , re_eps_rules = eps_rules + , re_visible_orphs = orphs }) fn + + | Just {} <- isDataConId_maybe fn -- Short cut for data constructor workers + = [] -- and wrappers, which never have any rules + + | otherwise + = idCoreRules fn ++ + get local_rules ++ + find_visible home_rules ++ + find_visible eps_rules + where - imp_rules rb = filter (ruleIsVisible orphs) (lookupNameEnv rb (idName fn) `orElse` []) + fn_name = idName fn + find_visible rb = filter (ruleIsVisible orphs) (get rb) + get rb = lookupNameEnv rb fn_name `orElse` [] ruleIsVisible :: ModuleSet -> CoreRule -> Bool ruleIsVisible _ BuiltinRule{} = True @@ -370,37 +470,28 @@ but that isn't quite right: in the module defining the Id (when it's a LocalId), but the rules are kept in the global RuleBase + Note [External package rules] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In Note [Overall plumbing for rules], it is explained that the final +RuleBase which we must consider is combined from 4 different sources. -************************************************************************ -* * - RuleBase -* * -************************************************************************ --} - --- RuleBase itself is defined in GHC.Core, along with CoreRule - -emptyRuleBase :: RuleBase -emptyRuleBase = emptyNameEnv - -mkRuleBase :: [CoreRule] -> RuleBase -mkRuleBase rules = extendRuleBaseList emptyRuleBase rules +During simplifier runs, the fourth source of rules is constantly being updated +as new interfaces are loaded into the EPS. Therefore just before we check to see +if any rules match we get the EPS RuleBase and combine it with the existing RuleBase +and then perform exactly 1 lookup into the new map. -extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase -extendRuleBaseList rule_base new_guys - = foldl' extendRuleBase rule_base new_guys +It is more efficient to avoid combining the environments and store the uncombined +environments as we can instead perform 1 lookup into each environment and then combine +the results. -extendRuleBase :: RuleBase -> CoreRule -> RuleBase -extendRuleBase rule_base rule - = extendNameEnv_Acc (:) Utils.singleton rule_base (ruleIdName rule) rule +Essentially we use the identity: -extendRuleEnv :: RuleEnv -> RuleBase -> RuleEnv -extendRuleEnv (RuleEnv rules orphs) rb = (RuleEnv (rb:rules) orphs) +> lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) +> = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 -pprRuleBase :: RuleBase -> SDoc -pprRuleBase rules = pprUFM rules $ \rss -> - vcat [ pprRules (tidyRules emptyTidyEnv rs) - | rs <- rss ] +The latter being more efficient as we don't construct an intermediate +map. +-} {- ************************************************************************ @@ -1575,7 +1666,7 @@ ruleCheckFun env fn args | otherwise = unitBag (ruleAppCheck_help env fn args name_match_rules) where name_match_rules = filter match (rc_rules env fn) - match rule = (rc_pattern env) `isPrefixOf` unpackFS (ruleName rule) + match rule = rc_pattern env `isPrefixOf` unpackFS (ruleName rule) ruleAppCheck_help :: RuleCheckEnv -> Id -> [CoreExpr] -> [CoreRule] -> SDoc ruleAppCheck_help env fn args rules ===================================== compiler/GHC/Driver/Config/Core/Opt/Simplify.hs ===================================== @@ -6,7 +6,7 @@ module GHC.Driver.Config.Core.Opt.Simplify import GHC.Prelude -import GHC.Core ( RuleBase ) +import GHC.Core.Rules ( RuleBase ) import GHC.Core.Opt.Pipeline.Types ( CoreToDo(..) ) import GHC.Core.Opt.Simplify ( SimplifyExprOpts(..), SimplifyOpts(..) ) import GHC.Core.Opt.Simplify.Env ( FloatEnable(..), SimplMode(..) ) @@ -40,20 +40,19 @@ initSimplifyExprOpts dflags ic = SimplifyExprOpts } initSimplifyOpts :: DynFlags -> [Var] -> Int -> SimplMode -> RuleBase -> SimplifyOpts -initSimplifyOpts dflags extra_vars iterations mode rule_base = let +initSimplifyOpts dflags extra_vars iterations mode hpt_rule_base = let -- This is a particularly ugly construction, but we will get rid of it in !8341. opts = SimplifyOpts { so_dump_core_sizes = not $ gopt Opt_SuppressCoreSizes dflags - , so_iterations = iterations - , so_mode = mode + , so_iterations = iterations + , so_mode = mode , so_pass_result_cfg = if gopt Opt_DoCoreLinting dflags - then Just $ initLintPassResultConfig dflags extra_vars (CoreDoSimplify opts) - else Nothing - , so_rule_base = rule_base - , so_top_env_cfg = TopEnvConfig - { te_history_size = historySize dflags - , te_tick_factor = simplTickFactor dflags - } + then Just $ initLintPassResultConfig dflags extra_vars + (CoreDoSimplify opts) + else Nothing + , so_hpt_rules = hpt_rule_base + , so_top_env_cfg = TopEnvConfig { te_history_size = historySize dflags + , te_tick_factor = simplTickFactor dflags } } in opts ===================================== compiler/GHC/HsToCore/Errors/Ppr.hs ===================================== @@ -86,7 +86,7 @@ instance Diagnostic DsMessage where hang (text "Top-level" <+> text desc <+> text "aren't allowed:") 2 (ppr bind) DsUselessSpecialiseForClassMethodSelector poly_id -> mkSimpleDecorated $ - text "Ignoring useless SPECIALISE pragma for NOINLINE function:" <+> quotes (ppr poly_id) + text "Ignoring useless SPECIALISE pragma for class selector:" <+> quotes (ppr poly_id) DsUselessSpecialiseForNoInlineFunction poly_id -> mkSimpleDecorated $ text "Ignoring useless SPECIALISE pragma for NOINLINE function:" <+> quotes (ppr poly_id) ===================================== compiler/GHC/Unit/External.hs ===================================== @@ -21,11 +21,10 @@ import GHC.Prelude import GHC.Unit import GHC.Unit.Module.ModIface -import GHC.Core ( RuleBase ) import GHC.Core.FamInstEnv import GHC.Core.InstEnv ( InstEnv, emptyInstEnv ) import GHC.Core.Opt.ConstantFold -import GHC.Core.Rules (mkRuleBase) +import GHC.Core.Rules ( RuleBase, mkRuleBase) import GHC.Types.Annotations ( AnnEnv, emptyAnnEnv ) import GHC.Types.CompleteMatch ===================================== libraries/base/GHC/Ix.hs ===================================== @@ -140,12 +140,30 @@ Note [Out-of-bounds error messages] The default method for 'index' generates hoplelessIndexError, because Ix doesn't have Show as a superclass. For particular base types we can do better, so we override the default method for index. --} --- Abstract these errors from the relevant index functions so that --- the guts of the function will be small enough to inline. +Note [indexError] +~~~~~~~~~~~~~~~~~ +We abstract the guts of constructing an out-of-bounds error into `indexError`. +We give it a NOINLINE pragma, because we don't want to duplicate this +cold-path code. + +We give it a SPECIALISE pragma because we really want it to take +its arguments unboxed, to avoid reboxing code in the caller, and +perhaps even some reboxing code in the hot path of a caller. +See Note [Boxity for bottoming functions] in GHC.Core.Opt.DmdAnal. + +The SPECIALISE pragma means that at least the Int-indexed case +of indexError /will/ unbox its arguments. +The [2] phase is because if we don't give an activation we'll get +the one from the inline pragama (i.e. never) which is a bit silly. +See Note [Activation pragmas for SPECIALISE] in GHC.HsToCore.Binds. +-} + +-- indexError: see Note [indexError] {-# NOINLINE indexError #-} +{-# SPECIALISE [2] indexError :: (Int,Int) -> Int -> String -> b #-} + indexError :: Show a => (a,a) -> a -> String -> b indexError rng i tp = errorWithoutStackTrace (showString "Ix{" . showString tp . showString "}.index: Index " . ===================================== libraries/base/GHC/Real.hs ===================================== @@ -701,11 +701,14 @@ half of y - 1 can be computed as y `quot` 2, optimising subtraction away. Note [Inlining (^) ~~~~~~~~~~~~~~~~~~ -The INLINABLE pragma allows (^) to be specialised at its call sites. +The INLINABLE [1] pragma allows (^) to be specialised at its call sites. If it is called repeatedly at the same type, that can make a huge difference, because of those constants which can be repeatedly calculated. +We don't inline until phase 1, to give a chance for the RULES +"^2/Int" etc to fire first. + Currently the fromInteger calls are not floated because we get \d1 d2 x y -> blah after the gentle round of simplification. ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -15,5 +15,3 @@ g' :: Int -> Int g' = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } - - ===================================== testsuite/tests/simplCore/should_compile/T21851_2.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS_GHC -ddump-simpl -dsuppress-uniques -dno-typeable-binds #-} + +module T21851_2 where + +import T21851_2a + +g :: forall a. (Ord a, Num a) => a -> (a,String) +g n | n < 10 = (0, f n True) + | otherwise = g (n-2) +-- The specialised version of g leads to a specialised +-- call to (f @Int @Bool). Then we want to fire f's RULE +-- and specialise 'wombat' + +h = g (3::Int) + ===================================== testsuite/tests/simplCore/should_compile/T21851_2.stderr ===================================== @@ -0,0 +1,120 @@ +[1 of 2] Compiling T21851_2a ( T21851_2a.hs, T21851_2a.o ) +[2 of 2] Compiling T21851_2 ( T21851_2.hs, T21851_2.o ) + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 107, types: 96, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl :: Integer +[GblId, Unf=OtherCon []] +lvl = GHC.Num.Integer.IS 2# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl1 :: Integer +[GblId, Unf=OtherCon []] +lvl1 = GHC.Num.Integer.IS 0# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl2 :: Integer +[GblId, Unf=OtherCon []] +lvl2 = GHC.Num.Integer.IS 10# + +Rec { +-- RHS size: {terms: 25, types: 5, coercions: 0, joins: 0/0} +T21851_2.$s$wwombat [InlPrag=[~], Occ=LoopBreaker] + :: GHC.Prim.Int# -> Bool -> [Char] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +T21851_2.$s$wwombat + = \ (ww :: GHC.Prim.Int#) (y :: Bool) -> + case ww of ds { + __DEFAULT -> + case y of { + False -> + GHC.CString.unpackAppendCString# + GHC.Show.$fShowBool3 + (T21851_2.$s$wwombat (GHC.Prim.-# ds 1#) GHC.Types.False); + True -> + GHC.CString.unpackAppendCString# + GHC.Show.$fShowBool2 + (T21851_2.$s$wwombat (GHC.Prim.-# ds 1#) GHC.Types.True) + }; + 0# -> GHC.Types.[] @Char + } +end Rec } + +Rec { +-- RHS size: {terms: 16, types: 6, coercions: 0, joins: 0/0} +T21851_2.$w$sg [InlPrag=[2], Occ=LoopBreaker] + :: GHC.Prim.Int# -> (# GHC.Prim.Int#, String #) +[GblId, Arity=1, Str=, Unf=OtherCon []] +T21851_2.$w$sg + = \ (ww :: GHC.Prim.Int#) -> + case GHC.Prim.<# ww 10# of { + __DEFAULT -> T21851_2.$w$sg (GHC.Prim.-# ww 2#); + 1# -> (# 0#, T21851_2.$s$wwombat ww GHC.Types.True #) + } +end Rec } + +-- RHS size: {terms: 3, types: 3, coercions: 0, joins: 0/0} +lvl3 :: forall {a}. [Char] +[GblId] +lvl3 = \ (@a) -> T21851_2a.$wf GHC.Prim.(##) @a @Bool + +Rec { +-- RHS size: {terms: 27, types: 18, coercions: 0, joins: 0/0} +T21851_2.$wg [InlPrag=[2], Occ=LoopBreaker] + :: forall {a}. (Ord a, Num a) => a -> (# a, String #) +[GblId[StrictWorker([!])], + Arity=3, + Str=, + Unf=OtherCon []] +T21851_2.$wg + = \ (@a) ($dOrd :: Ord a) ($dNum :: Num a) (n :: a) -> + case < @a $dOrd n (fromInteger @a $dNum lvl2) of { + False -> + T21851_2.$wg + @a $dOrd $dNum (- @a $dNum n (fromInteger @a $dNum lvl)); + True -> (# fromInteger @a $dNum lvl1, lvl3 @a #) + } +end Rec } + +-- RHS size: {terms: 13, types: 16, coercions: 0, joins: 0/0} +g [InlPrag=[2]] :: forall a. (Ord a, Num a) => a -> (a, String) +[GblId, + Arity=3, + Str=, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) + Tmpl= \ (@a) + ($dOrd [Occ=Once1] :: Ord a) + ($dNum [Occ=Once1] :: Num a) + (n [Occ=Once1] :: a) -> + case T21851_2.$wg @a $dOrd $dNum n of + { (# ww [Occ=Once1], ww1 [Occ=Once1] #) -> + (ww, ww1) + }}] +g = \ (@a) ($dOrd :: Ord a) ($dNum :: Num a) (n :: a) -> + case T21851_2.$wg @a $dOrd $dNum n of { (# ww, ww1 #) -> + (ww, ww1) + } + +-- RHS size: {terms: 8, types: 9, coercions: 0, joins: 0/0} +h :: (Int, String) +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, + WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 50 10}] +h = case T21851_2.$w$sg 3# of { (# ww, ww1 #) -> + (GHC.Types.I# ww, ww1) + } + + +------ Local rules for imported ids -------- +"SPEC/T21851_2 $wwombat @Bool" [2] + forall ($dShow :: Show Bool). + T21851_2a.$wwombat @Bool $dShow + = T21851_2.$s$wwombat + + ===================================== testsuite/tests/simplCore/should_compile/T21851_2a.hs ===================================== @@ -0,0 +1,11 @@ +module T21851_2a where + +f :: (Num a, Show b) => a -> b -> String +{-# NOINLINE f #-} +f x y = "no" +{-# RULES "wombat" f = wombat #-} + +wombat :: Show b => Int -> b -> String +{-# INLINEABLE wombat #-} +wombat 0 y = "" +wombat n y = show y ++ wombat (n-1) y ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -442,3 +442,7 @@ test('T22357', normal, compile, ['-O']) # Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) test('T17366', normal, multimod_compile, ['T17366', '-O -v0 -ddump-rule-firings']) test('T17366_AR', [grep_errmsg(r'SPEC')], multimod_compile, ['T17366_AR', '-O -v0 -ddump-rule-firings']) + +# One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl +# Expecting to see $s$wwombat +test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39717dfe7a328dbefe88c62a8208852e95ddcfa4...03e7ad7dac58e0e28685abe3e07fb5f9ed82e1cf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/39717dfe7a328dbefe88c62a8208852e95ddcfa4...03e7ad7dac58e0e28685abe3e07fb5f9ed82e1cf You're receiving 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 Nov 9 17:25:36 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 09 Nov 2022 12:25:36 -0500 Subject: [Git][ghc/ghc][wip/T22434] Add a fast path for data constructor workers Message-ID: <636be290d24d3_10da055ac8adc7168e7@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22434 at Glasgow Haskell Compiler / GHC Commits: e5b02b84 by Simon Peyton Jones at 2022-11-09T17:27:20+00:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration - - - - - 4 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Types/Id/Make.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1497,9 +1497,10 @@ rebuild env expr cont ApplyToTy { sc_arg_ty = ty, sc_cont = cont} -> rebuild env (App expr (Type ty)) cont - ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag, sc_cont = cont} + ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag + , sc_cont = cont, sc_hole_ty = fun_ty } -- See Note [Avoid redundant simplification] - -> do { (_, _, arg') <- simplArg env dup_flag se arg + -> do { (_, _, arg') <- simplArg env dup_flag fun_ty se arg ; rebuild env (App expr arg') cont } completeBindX :: SimplEnv @@ -1598,7 +1599,8 @@ 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_dup = dup, sc_cont = tail + , sc_hole_ty = fun_ty }) | Just (m_co1, m_co2) <- pushCoValArg co , fixed_rep m_co1 = {-#SCC "addCoerce-pushCoValArg" #-} @@ -1610,7 +1612,7 @@ simplCast env body co0 cont0 -- See Note [Avoiding exponential behaviour] MCo co1 -> - do { (dup', arg_se', arg') <- simplArg env dup arg_se arg + do { (dup', arg_se', arg') <- simplArg env dup fun_ty arg_se arg -- When we build the ApplyTo we can't mix the OutCoercion -- 'co' with the InExpr 'arg', so we simplify -- to make it all consistent. It's a bit messy. @@ -1636,14 +1638,16 @@ simplCast env body co0 cont0 -- See Note [Representation polymorphism invariants] in GHC.Core -- test: typecheck/should_run/EtaExpandLevPoly -simplArg :: SimplEnv -> DupFlag -> StaticEnv -> CoreExpr +simplArg :: SimplEnv -> DupFlag + -> OutType -- Type of the function applied to this arg + -> StaticEnv -> CoreExpr -- Expression with its static envt -> SimplM (DupFlag, StaticEnv, OutExpr) -simplArg env dup_flag arg_env arg +simplArg env dup_flag fun_ty arg_env arg | isSimplified dup_flag = return (dup_flag, arg_env, arg) | otherwise = do { let arg_env' = arg_env `setInScopeFromE` env - ; arg' <- simplExpr arg_env' arg + ; arg' <- simplExprC arg_env' arg (mkBoringStop (funArgTy fun_ty)) ; return (Simplified, zapSubstEnv arg_env', arg') } -- Return a StaticEnv that includes the in-scope set from 'env', -- because arg' may well mention those variables (#20639) @@ -2029,6 +2033,21 @@ zap the SubstEnv. This is VITAL. Consider We'll clone the inner \x, adding x->x' in the id_subst Then when we inline y, we must *not* replace x by x' in the inlined copy!! + +Note [Fast path for data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For applications of a data constructor worker, the full glory of +rebuildCall is a waste of effort; +* They never inline, obviously +* They have no rewrite rules +* They are not strict (see Note [Data-con worker strictness] + in GHC.Core.DataCon) +So it's fine to zoom straight to `rebuild` which just rebuilds the +call in a very straightforward way. + +Some programs have a /lot/ of data constructors in the source program +(compiler/perf/T9961 is an example), so this fast path can be very +valuable. -} simplVar :: SimplEnv -> InVar -> SimplM OutExpr @@ -2046,6 +2065,9 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont + | isDataConWorkId var -- See Note [Fast path for data constructors] + = rebuild env (Var var) cont + | otherwise = case substId env var of ContEx tvs cvs ids e -> simplExprF env' e cont -- Don't trimJoinCont; haven't already simplified e, @@ -2315,6 +2337,8 @@ field of the ArgInfo record is the state of a little state-machine: If we inline `f` before simplifying `BIG` well use preInlineUnconditionally, and we'll simplify BIG once, at x's occurrence, rather than twice. +* GHC.Core.Opt.Simplify.Utils. mkRewriteCall: if there are no rules, and no + unfolding, we can skip both TryRules and TryInlining, which saves work. Note [Avoid redundant simplification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3645,7 +3669,7 @@ mkDupableContWithDmds env dmds do { let (dmd:cont_dmds) = dmds -- Never fails ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 - ; (_, se', arg') <- simplArg env' dup se arg + ; (_, se', arg') <- simplArg env' dup hole_ty se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ; let all_floats = floats1 `addLetFloats` let_floats2 ; return ( all_floats ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -425,12 +425,16 @@ decArgCount :: RewriteCall -> RewriteCall decArgCount (TryRules n rules) = TryRules (n-1) rules decArgCount rew = rew -mkTryRules :: [CoreRule] -> RewriteCall +mkRewriteCall :: Id -> RuleEnv -> RewriteCall -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration -mkTryRules [] = TryInlining -mkTryRules rs = TryRules n_required rs +mkRewriteCall fun rule_env + | not (null rules) = TryRules n_required rules + | canUnfold unf = TryInlining + | otherwise = TryNothing where - n_required = maximum (map ruleArity rs) + n_required = maximum (map ruleArity rules) + rules = getRules rule_env fun + unf = idUnfolding fun {- ************************************************************************ @@ -604,21 +608,23 @@ mkArgInfo :: SimplEnv -> RuleEnv -> Id -> SimplCont -> ArgInfo mkArgInfo env rule_base fun cont | n_val_args < idArity fun -- Note [Unsaturated functions] = ArgInfo { ai_fun = fun, ai_args = [] - , ai_rewrite = fun_rules + , ai_rewrite = fun_rewrite , ai_encl = False , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise = ArgInfo { ai_fun = fun , ai_args = [] - , ai_rewrite = fun_rules - , ai_encl = notNull rules || contHasRules cont + , ai_rewrite = fun_rewrite + , ai_encl = fun_has_rules || contHasRules cont , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where - rules = getRules rule_base fun - fun_rules = mkTryRules rules - n_val_args = countValArgs cont + n_val_args = countValArgs cont + fun_rewrite = mkRewriteCall fun rule_base + fun_has_rules = case fun_rewrite of + TryRules {} -> True + _ -> False vanilla_discounts, arg_discounts :: [Int] vanilla_discounts = repeat 0 ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -9,7 +9,7 @@ -- The 'CoreRule' datatype itself is declared elsewhere. module GHC.Core.Rules ( -- ** Looking up rules - lookupRule, + RuleEnv, lookupRule, -- ** RuleBase, RuleEnv emptyRuleBase, mkRuleBase, extendRuleBaseList, ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -585,6 +585,7 @@ mkDataConWorkId wkr_name data_con `setInlinePragInfo` wkr_inline_prag `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated, -- even if arity = 0 + -- No strictness: see Note [Data-con worker strictness] in GHC.Core.DataCon wkr_inline_prag = defaultInlinePragma { inl_rule = ConLike } wkr_arity = dataConRepArity data_con View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5b02b841deee5a8275e1897518c69db64aac53e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e5b02b841deee5a8275e1897518c69db64aac53e You're receiving 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 Nov 9 17:54:24 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 09 Nov 2022 12:54:24 -0500 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] 17 commits: Bump unix submodule to 2.8.0.0 Message-ID: <636be95030dd2_10da05526c0724033@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 97d00423 by Andreas Klebinger at 2022-11-09T14:32:53+01:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 78747086 by Andreas Klebinger at 2022-11-09T14:32:53+01:00 Make mapSumIdBinders take only valid inputs - - - - - 9a7fbc4e by Andreas Klebinger at 2022-11-09T14:32:53+01:00 Uniques wip - - - - - a802552e by Andreas Klebinger at 2022-11-09T14:32:53+01:00 Make sure new vars are unique - - - - - 10114427 by Andreas Klebinger at 2022-11-09T14:32:53+01:00 Remove redundant import - - - - - 2259e580 by Andreas Klebinger at 2022-11-09T18:50:28+01:00 Fix intTy intPrimTy mixup and more - - - - - 30 changed files: - .gitlab-ci.yml - compiler/GHC/Builtin/Names.hs - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/DataCon.hs-boot - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Reduction.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Unify.hs - compiler/GHC/CoreToIface.hs - + compiler/GHC/Data/List/Infinite.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Pmc/Ppr.hs - compiler/GHC/Iface/Make.hs - compiler/GHC/Iface/Rename.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/IfaceToCore.hs - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Tc/Gen/Foreign.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Instance/Typeable.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/20c49025a22eb381ebdb5f0cf34e18e0f9f8d746...2259e580dc2a6987f3534306d6db9400aae4c3ac -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/20c49025a22eb381ebdb5f0cf34e18e0f9f8d746...2259e580dc2a6987f3534306d6db9400aae4c3ac You're receiving 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 Nov 9 17:55:58 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 09 Nov 2022 12:55:58 -0500 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] 3 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636be9ae7e7a_10da054796c98724518@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - 8bd2762e by Andreas Klebinger at 2022-11-09T18:53:46+01:00 Properly convert values before/after storing them in unboxed sums. See Note [Casting slot arguments] for the details. - - - - - 30 changed files: - + compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Stg/Syntax.hs - compiler/GHC/Stg/Unarise.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/RepType.hs - compiler/GHC/Utils/Outputable.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - ghc/GHCi/UI/Tags.hs - testsuite/driver/testlib.py - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2259e580dc2a6987f3534306d6db9400aae4c3ac...8bd2762ea833a310f3680335b9835a1243ecb817 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2259e580dc2a6987f3534306d6db9400aae4c3ac...8bd2762ea833a310f3680335b9835a1243ecb817 You're receiving 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 Nov 9 18:06:37 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 09 Nov 2022 13:06:37 -0500 Subject: [Git][ghc/ghc][wip/fix-ubx-cast] Import fixes Message-ID: <636bec2d19734_10da054a1b7987295f2@gitlab.mail> Andreas Klebinger pushed to branch wip/fix-ubx-cast at Glasgow Haskell Compiler / GHC Commits: bad0e56d by Andreas Klebinger at 2022-11-09T19:04:23+01:00 Import fixes - - - - - 2 changed files: - compiler/GHC/Builtin/PrimOps/Casts.hs - compiler/GHC/Stg/Unarise.hs Changes: ===================================== compiler/GHC/Builtin/PrimOps/Casts.hs ===================================== @@ -17,7 +17,6 @@ import GHC.Utils.Panic.Plain import GHC.Types.RepType import GHC.Core.Type import GHC.Builtin.Types.Prim -import GHC.Builtin.Types import GHC.Builtin.PrimOps import GHC.Plugins (HasDebugCallStack) ===================================== compiler/GHC/Stg/Unarise.hs ===================================== @@ -382,7 +382,7 @@ import GHC.Types.Basic import GHC.Core import GHC.Core.DataCon import GHC.Core.TyCon -import GHC.Data.FastString (FastString, mkFastString, fsLit, appendFS) +import GHC.Data.FastString (FastString, mkFastString, fsLit) import GHC.Types.Id import GHC.Types.Literal import GHC.Core.Make (aBSENT_SUM_FIELD_ERROR_ID) @@ -401,7 +401,6 @@ import GHC.Types.Unique.Supply import GHC.Types.Unique import GHC.Utils.Misc import GHC.Types.Var.Env -import GHC.Types.Name import Data.Bifunctor (second) import Data.Maybe (mapMaybe) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bad0e56d687a0794c33b79452c385a5fdf73d4e2 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bad0e56d687a0794c33b79452c385a5fdf73d4e2 You're receiving 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 Nov 9 18:18:56 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Wed, 09 Nov 2022 13:18:56 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/cmm_invariants Message-ID: <636bef1090c39_10da054050cf4730088@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/cmm_invariants at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/cmm_invariants You're receiving 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 Nov 10 03:05:35 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Wed, 09 Nov 2022 22:05:35 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 20 commits: Introduce blockConcat Message-ID: <636c6a7f42dd3_10da051c787b7c797719@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: f3204501 by Ben Gamari at 2022-11-09T20:58:39-05:00 Introduce blockConcat - - - - - a7b4620a by Ben Gamari at 2022-11-09T20:58:55-05:00 cmm: Introduce MemoryOrderings - - - - - e01250a0 by Ben Gamari at 2022-11-09T21:01:07-05:00 llvm: Respect memory specified orderings - - - - - 4c312a1c by Ben Gamari at 2022-11-09T21:01:07-05:00 cmm/Parser: Reduce some repetition - - - - - 8b68c205 by Ben Gamari at 2022-11-09T21:01:07-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - a2119499 by Ben Gamari at 2022-11-09T22:05:26-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - 66606f1c by Ben Gamari at 2022-11-09T22:05:26-05:00 rts/Messages: Refactor - - - - - 124c88b3 by Ben Gamari at 2022-11-09T22:05:26-05:00 Ordering fixes - - - - - aa0a909e by Ben Gamari at 2022-11-09T22:05:26-05:00 eventlog: Silence spurious data race - - - - - 6d86d01a by Ben Gamari at 2022-11-09T22:05:26-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 2a97a79a by Ben Gamari at 2022-11-09T22:05:26-05:00 unlockClosure - - - - - 298d80e6 by Ben Gamari at 2022-11-09T22:05:26-05:00 Introduce and use GET_INFO_ACQUIRE - - - - - ab7f5966 by Ben Gamari at 2022-11-09T22:05:26-05:00 Fences - - - - - cfc46a86 by Ben Gamari at 2022-11-09T22:05:26-05:00 LOAD_INFO - - - - - 0fb3f624 by Ben Gamari at 2022-11-09T22:05:26-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 4aeb1779 by Ben Gamari at 2022-11-09T22:05:26-05:00 Improve heap memory barrier note - - - - - 2cdb1daf by Ben Gamari at 2022-11-09T22:05:26-05:00 Cmm atomic load syntax - - - - - 565d21a4 by Ben Gamari at 2022-11-09T22:05:26-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 9763b3c2 by Ben Gamari at 2022-11-09T22:05:26-05:00 load_acquire_w - - - - - a2751d71 by Ben Gamari at 2022-11-09T22:05:26-05:00 rts: Introduce getNumCapabilities - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - rts/Apply.cmm - rts/Capability.c - rts/Capability.h - rts/Messages.c - rts/Messages.h - rts/PrimOps.cmm - rts/Printer.c - rts/ProfHeap.c - rts/ProfilerReport.c - rts/ProfilerReportJson.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43509a9f2d745dd4fcc7be52ce24defa5b5df99b...a2751d716045c5ae511ff4091068601cd2566cde -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/43509a9f2d745dd4fcc7be52ce24defa5b5df99b...a2751d716045c5ae511ff4091068601cd2566cde You're receiving 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 Nov 10 10:01:50 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 10 Nov 2022 05:01:50 -0500 Subject: [Git][ghc/ghc][wip/T21623] 5 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636ccc0e5a657_10da053ed19f0831271@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - e2f9360b by Simon Peyton Jones at 2022-11-10T10:03:42+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - fa668d6e by Simon Peyton Jones at 2022-11-10T10:03:42+00:00 Improve the Lint checking for empty cases - - - - - 560300b9 by Simon Peyton Jones at 2022-11-10T10:03:43+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/184e3dcce8c2a539967d3b2ce0d4caf359cdecbb...560300b9fd9987c9ad345da8a59fc9592e13e8b4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/184e3dcce8c2a539967d3b2ce0d4caf359cdecbb...560300b9fd9987c9ad345da8a59fc9592e13e8b4 You're receiving 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 Nov 10 11:50:15 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 10 Nov 2022 06:50:15 -0500 Subject: [Git][ghc/ghc][wip/T21623] Type vs Constraint: finally nailed Message-ID: <636ce577960fd_10da054a1b798845810@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: ec79bb75 by Simon Peyton Jones at 2022-11-10T11:52:07+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec79bb7529b39d546a77bc55ed12117d8288cf2e -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ec79bb7529b39d546a77bc55ed12117d8288cf2e You're receiving 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 Nov 10 11:57:50 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 10 Nov 2022 06:57:50 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22439 Message-ID: <636ce73e26414_10da05526ac850792@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22439 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22439 You're receiving 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 Nov 10 11:57:56 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 10 Nov 2022 06:57:56 -0500 Subject: [Git][ghc/ghc][wip/T22274] 45 commits: CI: Don't run lint-submods on nightly Message-ID: <636ce7448724a_10da0554a248510b7@gitlab.mail> Sebastian Graf pushed to branch wip/T22274 at Glasgow Haskell Compiler / GHC Commits: c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - 2373ad6f by Sebastian Graf at 2022-11-10T08:35:48+01:00 Factor UnVarSet out into UniqSlimSet - - - - - 9206456c by Sebastian Graf at 2022-11-10T12:57:50+01:00 Identify exit cases in OccurAnal Also had to mark a few key WordArray functions as INLINE so that they don't allocate a closure for the continuation. - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - CODEOWNERS - compiler/GHC/Builtin/Names.hs - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/CmmToAsm/X86/Regs.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/DataCon.hs-boot - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/CallArity.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/Core/Opt/CprAnal.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/554ea79fd60e8de15680359fa8a007e4671a4580...9206456c6b0595e424514fd6c9c3fdc34424a455 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/554ea79fd60e8de15680359fa8a007e4671a4580...9206456c6b0595e424514fd6c9c3fdc34424a455 You're receiving 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 Nov 10 12:12:36 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 10 Nov 2022 07:12:36 -0500 Subject: [Git][ghc/ghc][wip/T22434] 3 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636ceab4bb0e4_10da05526ac85527c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22434 at Glasgow Haskell Compiler / GHC Commits: 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - 299d21bb by Simon Peyton Jones at 2022-11-10T12:14:32+00:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 30 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Id/Make.hs - ghc/GHCi/UI/Tags.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.hs - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.stderr - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs-boot - testsuite/tests/indexed-types/should_fail/Overlap3.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5b02b841deee5a8275e1897518c69db64aac53e...299d21bbe03d4e054be7702b495f792f99898dfd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e5b02b841deee5a8275e1897518c69db64aac53e...299d21bbe03d4e054be7702b495f792f99898dfd You're receiving 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 Nov 10 12:16:41 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Thu, 10 Nov 2022 07:16:41 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/andreask/bump-94-index Message-ID: <636ceba9a9970_10da054050cf4855682@gitlab.mail> Andreas Klebinger pushed new branch wip/andreask/bump-94-index at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/andreask/bump-94-index You're receiving 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 Nov 10 12:19:17 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 10 Nov 2022 07:19:17 -0500 Subject: [Git][ghc/ghc][wip/T21851] 5 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636cec45ccfd0_10da0554a248579c5@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21851 at Glasgow Haskell Compiler / GHC Commits: 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - 30 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Unit/External.hs - ghc/GHCi/UI/Tags.hs - libraries/base/GHC/Ix.hs - libraries/base/GHC/Real.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/03e7ad7dac58e0e28685abe3e07fb5f9ed82e1cf...399e921b05493d79f04e77806c1562806f118d4a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/03e7ad7dac58e0e28685abe3e07fb5f9ed82e1cf...399e921b05493d79f04e77806c1562806f118d4a You're receiving 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 Nov 10 12:19:43 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Thu, 10 Nov 2022 07:19:43 -0500 Subject: [Git][ghc/ghc][wip/T22274] Identify exit cases in OccurAnal Message-ID: <636cec5f5545c_10da05526ac8589c5@gitlab.mail> Sebastian Graf pushed to branch wip/T22274 at Glasgow Haskell Compiler / GHC Commits: 0a2b9439 by Sebastian Graf at 2022-11-10T13:19:35+01:00 Identify exit cases in OccurAnal Also had to mark a few key WordArray functions as INLINE so that they don't allocate a closure for the continuation. - - - - - 3 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - compiler/GHC/Types/Unique/SlimSet.hs - libraries/ghc-bignum/src/GHC/Num/WordArray.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -34,7 +34,7 @@ import GHC.Core.Predicate ( isDictId ) import GHC.Core.Type import GHC.Core.TyCo.FVs ( tyCoVarsOfMCo ) -import GHC.Data.Maybe( isJust, orElse ) +import GHC.Data.Maybe( isJust, orElse, mapMaybe, expectJust ) import GHC.Data.Graph.Directed ( SCC(..), Node(..) , stronglyConnCompFromEdgedVerticesUniq , stronglyConnCompFromEdgedVerticesUniqR ) @@ -48,6 +48,7 @@ import GHC.Types.Tickish import GHC.Types.Var.Set import GHC.Types.Var.Env import GHC.Types.Var +import GHC.Types.Unique.SlimSet import GHC.Types.Demand ( argOneShots, argsOneShots ) import GHC.Utils.Outputable @@ -58,6 +59,8 @@ import GHC.Utils.Misc import GHC.Builtin.Names( runRWKey ) import GHC.Unit.Module( Module ) +import Data.IntMap.Strict (IntMap) +import qualified Data.IntMap.Strict as IntMap import Data.List (mapAccumL, mapAccumR) import Data.List.NonEmpty (NonEmpty (..), nonEmpty) import qualified Data.List.NonEmpty as NE @@ -754,7 +757,8 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage = WithUsageDetails body_usage [] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = -- applyWhen (getOccFS bndr `elem` map fsLit ["binder_set","refined_id"]) (pprTrace "NonRec" (ppr bndr $$ ppr body_usage' $$ ppr rhs_usage $$ ppr (body_usage' `andUDs` rhs_usage))) $ + WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] where (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr final_bndr = tagged_bndr `setIdUnfolding` unf' @@ -773,13 +777,13 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env lvl NonRecursive mb_join_arity (idOccInfo tagged_bndr) rhs --------- Unfolding --------- -- See Note [Unfoldings and join points] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env lvl NonRecursive mb_join_arity unf --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] @@ -826,11 +830,13 @@ occAnalRecBind !env lvl imp_rule_edges pairs body_usage nodes :: [LetrecNode] nodes = {-# SCC "occAnalBind.assoc" #-} - map (makeNode rhs_env imp_rule_edges bndr_set) pairs + map (makeNode rhs_env lvl imp_rule_edges bndr_set) pairs bndrs = map fst pairs bndr_set = mkVarSet bndrs - rhs_env = env `addInScope` bndrs + -- enter the loop here and leave it in makeNode + rhs_env = -- pprTrace "entering" (ppr bndrs) $ + env `addInScope` bndrs `enterLoop` bndrs ----------------------------- @@ -851,7 +857,7 @@ occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs (NonRec tagged_bndr rhs : binds) where (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + rhs_uds' = adjustRhsUsage lvl mb_join_arity (idOccInfo tagged_bndr) rhs rhs_uds mb_join_arity = willBeJoinId_maybe tagged_bndr -- The Rec case is the interesting one @@ -862,7 +868,8 @@ occAnalRec env lvl (CyclicSCC details_s) (WithUsageDetails body_uds binds) = WithUsageDetails body_uds binds -- See Note [Dead code] | otherwise -- At this point we always build a single Rec - = -- pprTrace "occAnalRec" (ppr loop_breaker_nodes) + -- = -- pprTrace "occAnalRec" (ppr loop_breaker_nodes) + = -- applyWhen (any (\bndr -> getOccFS bndr `elem` map fsLit ["search"]) bndrs) (pprTrace "Rec" (ppr bndrs <+> ppr (NE.nonEmpty bndrs >>= (lookupVarEnv (occ_loops env) . NE.head)) $$ ppr body_uds $$ ppr (map nd_uds details_s) $$ ppr final_uds)) $ WithUsageDetails final_uds (Rec pairs : binds) where @@ -1375,10 +1382,10 @@ type NodeScore = ( Int -- Rank: lower => more likely to be picked as loop br rank :: NodeScore -> Int rank (r, _, _) = r -makeNode :: OccEnv -> ImpRuleEdges -> VarSet +makeNode :: OccEnv -> TopLevelFlag -> ImpRuleEdges -> VarSet -> (Var, CoreExpr) -> LetrecNode -- See Note [Recursive bindings: the grand plan] -makeNode !env imp_rule_edges bndr_set (bndr, rhs) +makeNode !env lvl imp_rule_edges bndr_set (bndr, rhs) = DigraphNode { node_payload = details , node_key = varUnique bndr , node_dependencies = nonDetKeysUniqSet scope_fvs } @@ -1398,8 +1405,10 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) bndr' = bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' + loop_lvl = lookupLoopLevel env bndr inl_uds = rhs_uds `andUDs` unf_uds - scope_uds = inl_uds `andUDs` rule_uds + scope_uds = -- pprTrace "leaving" (ppr bndr <+> ppr loop_lvl) $ + leaveLoop loop_lvl bndr $ inl_uds `andUDs` rule_uds -- Note [Rules are extra RHSs] -- Note [Rule dependency info] scope_fvs = udFreeVars bndr_set scope_uds @@ -1432,7 +1441,7 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- See Note [Unfoldings and join points] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env lvl Recursive mb_join_arity unf --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1895,16 +1904,17 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity +occAnalRhs :: OccEnv -> TopLevelFlag -> RecFlag -> Maybe JoinArity + -> OccInfo -- How often does the binder of the RHS occur? -> CoreExpr -- RHS -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs +occAnalRhs !env lvl is_rec mb_join_arity occ rhs = let (WithUsageDetails usage rhs1) = occAnalLam env rhs -- We call occAnalLam here, not occAnalExpr, so that it doesn't -- do the markAllInsideLam and markNonTailCall stuff before -- we've had a chance to help with join points; that comes next rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage + rhs_usage = adjustRhsUsage lvl mb_join_arity occ rhs2 usage in WithUsageDetails rhs_usage rhs2 @@ -1928,18 +1938,19 @@ markJoinOneShots _ _ rhs = rhs occAnalUnfolding :: OccEnv + -> TopLevelFlag -> RecFlag -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding -> WithUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; -- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +occAnalUnfolding !env lvl is_rec mb_join_arity unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + (WithUsageDetails usage rhs') = occAnalRhs env lvl is_rec mb_join_arity noOccInfo rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } @@ -2286,7 +2297,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , let (WithUsageDetails usage arg') = occAnalRhs env NotTopLevel NonRecursive (Just 1) IAmDead arg -- IAmDead is OK because we are only interested in whether it is ManyOcc or not = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -2298,7 +2309,7 @@ occAnalApp env (Var fun_id, args, ticks) !(fun', fun_id') = lookupBndrSwap env fun_id !(WithUsageDetails args_uds app') = occAnalArgs env fun' args one_shots - fun_uds = mkOneOcc fun_id' int_cxt n_args + fun_uds = mkOneOcc env fun_id' int_cxt n_args -- NB: fun_uds is computed for fun_id', not fun_id -- See (BS1) in Note [The binder-swap substitution] @@ -2458,6 +2469,8 @@ scrutinised y). data OccEnv = OccEnv { occ_encl :: !OccEncl -- Enclosing context information , occ_one_shots :: !OneShots -- See Note [OneShots] + , occ_cur_lvl :: !LoopLevel -- ^ Current loop level + , occ_loops :: !(IdEnv LoopLevel) -- ^ The loop levels of enclosing letrec binders , occ_unf_act :: Id -> Bool -- Which Id unfoldings are active , occ_rule_act :: Activation -> Bool -- Which rules are active -- See Note [Finding rule RHS free vars] @@ -2506,6 +2519,8 @@ initOccEnv :: OccEnv initOccEnv = OccEnv { occ_encl = OccVanilla , occ_one_shots = [] + , occ_cur_lvl = 0 + , occ_loops = emptyVarEnv -- To be conservative, we say that all -- inlines and rules are active @@ -2545,6 +2560,11 @@ isRhsEnv (OccEnv { occ_encl = cxt }) = case cxt of OccRhs -> True _ -> False +lookupLoopLevel :: OccEnv -> Id -> Int +lookupLoopLevel (OccEnv { occ_loops = loops }) id + | Just lvl <- lookupVarEnv loops id = lvl + | otherwise = 0 + addOneInScope :: OccEnv -> CoreBndr -> OccEnv addOneInScope env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) bndr | bndr `elemVarSet` rng_vars = env { occ_bs_env = emptyVarEnv, occ_bs_rng = emptyVarSet } @@ -2558,6 +2578,29 @@ addInScope env@(OccEnv { occ_bs_env = swap_env, occ_bs_rng = rng_vars }) bndrs | any (`elemVarSet` rng_vars) bndrs = env { occ_bs_env = emptyVarEnv, occ_bs_rng = emptyVarSet } | otherwise = env { occ_bs_env = swap_env `delVarEnvList` bndrs } +enterLoop :: OccEnv -> [Var] -> OccEnv +enterLoop env vs + = env { occ_cur_lvl = new_lvl + , occ_loops = extendVarEnvList (occ_loops env) [(v,new_lvl) | v<-vs] } + where + new_lvl = occ_cur_lvl env + 1 + +leaveLoop :: LoopLevel -> Id -> UsageDetails -> UsageDetails +leaveLoop loop_lvl bndr ud at UD{ud_loop_info=lli} + | loop_lvl > max_lvl = ud + | otherwise = assertPpr (loop_lvl == max_lvl) (text "loop_lvl < max_lvl is wrong" $$ ppr bndr <+> ppr loop_lvl <+> ppr max_lvl $$ ppr ud) $ + -- pprTraceWith "leave interesting" (\r -> ppr lvl $$ ppr ud $$ ppr r) $ + ud { ud_z_in_lam = ud_z_in_lam ud `plusVarEnv` (ud_env ud `minusVarEnv` nml), ud_loop_info = lli' } + where + max_lvl = lli_max (ud_loop_info ud) + nml = lli_non_max_lvls lli + lli' = case IntMap.maxViewWithKey (lli_inv lli) of + Nothing -> emptyLoopLevelInfo + Just ((new_lvl, new_max_occs), inv') -> + lli { lli_max = new_lvl + , lli_inv = inv' + , lli_non_max_lvls = nonDetFoldUniqSlimSet (\u nml -> delFromUFM_Directly nml u) (lli_non_max_lvls lli) new_max_occs + } -------------------- transClosureFV :: VarEnv VarSet -> VarEnv VarSet @@ -2975,34 +3018,83 @@ info then simply means setting the corresponding zapped set to the whole 'OccInfoEnv', a fast O(1) operation. -} -type OccInfoEnv = IdEnv OccInfo -- A finite map from ids to their usage - -- INVARIANT: never IAmDead - -- (Deadness is signalled by not being in the map at all) +type LoopLevel = Int + +-- | Level 0 is the loop level we never exit. Every letrec binder will have loop +-- level at least 1. +notLooping :: LoopLevel +notLooping = 0 + +type LoopLevelMap = IntMap + +type OccInfoEnv = IdEnv OccInfo + -- ^ A finite map from ids to their usage. + -- INVARIANT: The OccInfo is never IAmDead + -- (Deadness is signalled by not being in the map at all) type ZappedSet = OccInfoEnv -- Values are ignored +-- | Represents an efficient bidirectional mapping between occuring 'Id's +-- and the maximum 'LoopLevel' of the recursive binders with which they +-- co-occur. +data LoopLevelInfo + = LLI { lli_max :: !LoopLevel + -- ^ Maximum loop level of a rec binder occuring in the expression + , lli_non_max_lvls :: !(IdEnv Int) + -- ^ Binders that (are not dead, and) do not occur at loop level + -- 'lli_max' will have their loop-level stated here. + , lli_inv :: !(LoopLevelMap VarSlimSet) + -- ^ Inverse mapping of 'lli_non_max_lvls'. + -- If a binder has max loop level l, it will be regarded as "used on an + -- exit path" wrt. the loop with level l. + -- INVARIANT: The sets for different levels are disjoint + } + + data UsageDetails = UD { ud_env :: !OccInfoEnv + , ud_loop_info :: !LoopLevelInfo , ud_z_many :: !ZappedSet -- apply 'markMany' to these , ud_z_in_lam :: !ZappedSet -- apply 'markInsideLam' to these , ud_z_no_tail :: !ZappedSet } -- apply 'markNonTail' to these -- INVARIANT: All three zapped sets are subsets of the OccInfoEnv instance Outputable UsageDetails where - ppr ud = ppr (ud_env (flattenUsageDetails ud)) + ppr ud = ppr (ud_env (flattenUsageDetails ud)) $$ ppr (ud_loop_info ud) + +instance Outputable LoopLevelInfo where + ppr LLI{lli_max=lvl, lli_non_max_lvls=lvls} = int lvl <> ppr lvls ------------------- -- UsageDetails API andUDs, orUDs :: UsageDetails -> UsageDetails -> UsageDetails -andUDs = combineUsageDetailsWith addOccInfo -orUDs = combineUsageDetailsWith orOccInfo +andUDs = combineUsageDetailsWith addOccInfo andLoopLevelInfo +orUDs = combineUsageDetailsWith orOccInfo orLoopLevelInfo + +andLoopLevelInfo :: LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo +andLoopLevelInfo lvl _occs lli = markAllLoopLevel lvl lli + +orLoopLevelInfo :: LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo +orLoopLevelInfo other_max occs lli + | other_max <= our_max = lli + | otherwise = LLI { lli_max = other_max + , lli_non_max_lvls = non_max_lvls' + , lli_inv = inv' + } + where + our_max = lli_max lli + our_max_occs = occs `minusVarEnv` lli_non_max_lvls lli + inv' = IntMap.insert our_max (ufmDom our_max_occs) (lli_inv lli) + non_max_lvls' = mapVarEnv (const our_max) our_max_occs `plusVarEnv` lli_non_max_lvls lli -- NB: plusVarEnv is right-biased, so lower level wins -mkOneOcc :: Id -> InterestingCxt -> JoinArity -> UsageDetails -mkOneOcc id int_cxt arity +mkOneOcc :: OccEnv -> Id -> InterestingCxt -> JoinArity -> UsageDetails +mkOneOcc env id int_cxt arity | isLocalId id - = emptyDetails { ud_env = unitVarEnv id occ_info } + , let !lvl = lookupLoopLevel env id + = emptyDetails { ud_env = unitVarEnv id occ_info + , ud_loop_info = emptyLoopLevelInfo { lli_max = lvl } } | otherwise = emptyDetails where @@ -3037,14 +3129,36 @@ addLamCoVarOccs uds bndrs delDetails :: UsageDetails -> Id -> UsageDetails delDetails ud bndr - = ud `alterUsageDetails` (`delVarEnv` bndr) + = ud `alterUsageDetails` (`delVarEnv` bndr) `alterLoopLevelInfo` (`delLoopLevel` bndr) delDetailsList :: UsageDetails -> [Id] -> UsageDetails delDetailsList ud bndrs - = ud `alterUsageDetails` (`delVarEnvList` bndrs) + = ud `alterUsageDetails` (`delVarEnvList` bndrs) `alterLoopLevelInfo` (`delLoopLevelList` bndrs) + +delLoopLevel :: LoopLevelInfo -> Id -> LoopLevelInfo +delLoopLevel lli@(LLI { lli_non_max_lvls = nml, lli_inv = inv }) id + | Just lvl <- lookupVarEnv (lli_non_max_lvls lli) id + = lli { lli_non_max_lvls = delVarEnv nml id + , lli_inv = IntMap.adjust (`delUniqSlimSet` id) lvl inv } + | otherwise + = lli + +delLoopLevelList :: LoopLevelInfo -> [Id] -> LoopLevelInfo +delLoopLevelList lli@(LLI { lli_non_max_lvls = nml, lli_inv = inv }) ids + = lli { lli_non_max_lvls = delVarEnvList nml ids + , lli_inv = foldr (IntMap.adjust (`minusUniqSlimSet` ids_set)) inv lvls } + where + ids_set = mkUniqSlimSet ids + lvls = mapMaybe (lookupVarEnv (lli_non_max_lvls lli)) ids + +emptyLoopLevelInfo :: LoopLevelInfo +emptyLoopLevelInfo = LLI { lli_max = notLooping + , lli_non_max_lvls = emptyVarEnv + , lli_inv = IntMap.empty } emptyDetails :: UsageDetails emptyDetails = UD { ud_env = emptyVarEnv + , ud_loop_info = emptyLoopLevelInfo , ud_z_many = emptyVarEnv , ud_z_in_lam = emptyVarEnv , ud_z_no_tail = emptyVarEnv } @@ -3066,9 +3180,21 @@ markAllInsideLamIf False ud = ud markAllNonTailIf True ud = markAllNonTail ud markAllNonTailIf False ud = ud - markAllManyNonTail = markAllMany . markAllNonTail -- effectively sets to noOccInfo +markAllLoopLevel :: LoopLevel -> LoopLevelInfo -> LoopLevelInfo +markAllLoopLevel lvl lli + | lvl >= lli_max lli = LLI { lli_max = lvl, lli_non_max_lvls = emptyVarEnv, lli_inv = IntMap.empty } + | otherwise = LLI { lli_max = lli_max lli + , lli_non_max_lvls = non_max_lvls' + , lli_inv = inv' + } + where + (lower, mb_exact, higher) = IntMap.splitLookup lvl (lli_inv lli) + raised_vars = IntMap.foldr unionUniqSlimSet (mb_exact `orElse` emptyUniqSlimSet) lower + inv' = IntMap.insert lvl raised_vars higher + non_max_lvls' = nonDetFoldUniqSlimSet (\u lvls -> addToUFM_Directly lvls u lvl) (lli_non_max_lvls lli) raised_vars + lookupDetails :: UsageDetails -> Id -> OccInfo lookupDetails ud id = case lookupVarEnv (ud_env ud) id of @@ -3089,16 +3215,33 @@ restrictFreeVars bndrs fvs = restrictUniqSetToUFM bndrs fvs -- Auxiliary functions for UsageDetails implementation combineUsageDetailsWith :: (OccInfo -> OccInfo -> OccInfo) + -> (LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo) -> UsageDetails -> UsageDetails -> UsageDetails -combineUsageDetailsWith plus_occ_info ud1 ud2 +combineUsageDetailsWith plus_occ_info bump_loop_info ud1 ud2 | isEmptyDetails ud1 = ud2 | isEmptyDetails ud2 = ud1 | otherwise = UD { ud_env = plusVarEnv_C plus_occ_info (ud_env ud1) (ud_env ud2) + , ud_loop_info = combineLoopLevelInfoWith bump_loop_info (ud_env ud1) (ud_loop_info ud1) (ud_env ud2) (ud_loop_info ud2) , ud_z_many = plusVarEnv (ud_z_many ud1) (ud_z_many ud2) , ud_z_in_lam = plusVarEnv (ud_z_in_lam ud1) (ud_z_in_lam ud2) , ud_z_no_tail = plusVarEnv (ud_z_no_tail ud1) (ud_z_no_tail ud2) } +combineLoopLevelInfoWith :: (LoopLevel -> OccInfoEnv -> LoopLevelInfo -> LoopLevelInfo) + -> OccInfoEnv -> LoopLevelInfo + -> OccInfoEnv -> LoopLevelInfo + -> LoopLevelInfo +combineLoopLevelInfoWith bump_loop_info u1 lli1 u2 lli2 + = assert (lli_max lli1' == lli_max lli2') $ + assert (lli_max lli1' == lli_max lli1 `max` lli_max lli2) $ + LLI { lli_max = lli_max lli1 `max` lli_max lli2 + , lli_non_max_lvls = plusVarEnv_C max (lli_non_max_lvls lli1') (lli_non_max_lvls lli2') + , lli_inv = IntMap.unionWith unionUniqSlimSet (lli_inv lli1') (lli_inv lli2') + } + where + lli1' = bump_loop_info (lli_max lli2) u1 lli1 + lli2' = bump_loop_info (lli_max lli1) u2 lli2 + doZapping :: UsageDetails -> Var -> OccInfo -> OccInfo doZapping ud var occ = doZappingByUnique ud (varUnique var) occ @@ -3118,31 +3261,44 @@ doZappingByUnique (UD { ud_z_many = many alterUsageDetails :: UsageDetails -> (OccInfoEnv -> OccInfoEnv) -> UsageDetails alterUsageDetails !ud f - = UD { ud_env = f (ud_env ud) + = ud { ud_env = f (ud_env ud) , ud_z_many = f (ud_z_many ud) , ud_z_in_lam = f (ud_z_in_lam ud) , ud_z_no_tail = f (ud_z_no_tail ud) } +alterLoopLevelInfo :: UsageDetails -> (LoopLevelInfo -> LoopLevelInfo) -> UsageDetails +alterLoopLevelInfo !ud f + = ud { ud_loop_info = f (ud_loop_info ud) } + flattenUsageDetails :: UsageDetails -> UsageDetails flattenUsageDetails ud@(UD { ud_env = env }) = UD { ud_env = mapUFM_Directly (doZappingByUnique ud) env + , ud_loop_info = ud_loop_info ud , ud_z_many = emptyVarEnv , ud_z_in_lam = emptyVarEnv , ud_z_no_tail = emptyVarEnv } ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity +adjustRhsUsage :: TopLevelFlag + -> Maybe JoinArity + -> OccInfo -> CoreExpr -- Rhs, AFTER occ anal -> UsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustRhsUsage lvl mb_join_arity occ rhs usage = -- c.f. occAnal (Lam {}) - markAllInsideLamIf (not one_shot) $ + -- pprTrace "adjust" (ppr lvl <+> ppr mb_join_arity <+> ppr occ <+> ppr rhs <+> ppr usage) $ + markAllInsideLamIf (not one_shot && not occ_one_shot) $ markAllNonTailIf (not exact_join) $ usage where one_shot = isOneShotFun rhs + occ_one_shot = not (isTopLevel lvl) && case occ of + IAmDead -> True + OneOcc{} -> occ_in_lam occ == NotInsideLam + _ -> False + exact_join = exactJoin mb_join_arity bndrs (bndrs,_) = collectBinders rhs @@ -3192,9 +3348,9 @@ tagNonRecBinder lvl usage binder = let occ = lookupDetails usage binder will_be_join = decideJoinPointHood lvl usage (NE.singleton binder) - occ' | will_be_join = -- must already be marked AlwaysTailCalled - assert (isAlwaysTailCalled occ) occ - | otherwise = markNonTail occ + occ' | will_be_join = -- must already be marked AlwaysTailCalled + assert (isAlwaysTailCalled occ) occ + | otherwise = markNonTail occ binder' = setBinderOcc occ' binder usage' = usage `delDetails` binder in @@ -3211,20 +3367,20 @@ tagRecBinders :: TopLevelFlag -- At top level? tagRecBinders lvl body_uds details_s = let bndrs = map nd_bndr details_s + bndrs_ne = expectJust "empty list of bndrs" $ nonEmpty bndrs rhs_udss = map nd_uds details_s - + body_occ = case filter (not . isDeadOcc) (map (lookupDetails body_uds) bndrs) of + [] -> IAmDead + o:os -> foldr addOccInfo o os -- 1. Determine join-point-hood of whole group, as determined by -- the *unadjusted* usage details unadj_uds = foldr andUDs body_uds rhs_udss - -- This is only used in `mb_join_arity`, to adjust each `Details` in `details_s`, thus, - -- when `bndrs` is non-empty. So, we only write `maybe False` as `decideJoinPointHood` - -- takes a `NonEmpty CoreBndr`; the default value `False` won't affect program behavior. - will_be_joins = maybe False (decideJoinPointHood lvl unadj_uds) (nonEmpty bndrs) + will_be_joins = decideJoinPointHood lvl unadj_uds bndrs_ne -- 2. Adjust usage details of each RHS, taking into account the -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds + rhs_udss' = [ adjustRhsUsage lvl (mb_join_arity bndr) body_occ rhs rhs_uds | ND { nd_bndr = bndr, nd_uds = rhs_uds , nd_rhs = rhs } <- details_s ] ===================================== compiler/GHC/Types/Unique/SlimSet.hs ===================================== @@ -11,7 +11,8 @@ module GHC.Types.Unique.SlimSet ( minusUniqSlimSet, unionUniqSlimSet, unionUniqSlimSets, ufmDom, -- * Querying - isEmptyUniqSlimSet, sizeUniqSlimSet, elemUniqSlimSet + isEmptyUniqSlimSet, sizeUniqSlimSet, elemUniqSlimSet, + nonDetEltsUniqSlimSet, nonDetFoldUniqSlimSet ) where import GHC.Prelude @@ -76,6 +77,12 @@ unionUniqSlimSet (UniqSlimSet set1) (UniqSlimSet set2) = UniqSlimSet (set1 `S.un unionUniqSlimSets :: [UniqSlimSet a] -> UniqSlimSet a unionUniqSlimSets = foldl' (flip unionUniqSlimSet) emptyUniqSlimSet +nonDetEltsUniqSlimSet :: UniqSlimSet a -> [Unique] +nonDetEltsUniqSlimSet (UniqSlimSet s) = map mkUniqueGrimily (S.elems s) + +nonDetFoldUniqSlimSet :: (Unique -> acc -> acc) -> acc -> UniqSlimSet a -> acc +nonDetFoldUniqSlimSet f acc (UniqSlimSet s) = S.foldr (f . mkUniqueGrimily) acc s + instance Outputable (UniqSlimSet a) where ppr (UniqSlimSet s) = braces $ hcat $ punctuate comma [ ppr (getUnique i) | i <- S.toList s] ===================================== libraries/ghc-bignum/src/GHC/Num/WordArray.hs ===================================== @@ -51,6 +51,7 @@ withNewWordArray# sz act = case runRW# io of (# _, a #) -> a case act mwa s of { s -> unsafeFreezeByteArray# mwa s }} +{-# INLINE withNewWordArray# #-} -- | Create two new WordArray# of the given sizes (*in Word#*) and apply the -- action to them before returning them frozen @@ -86,6 +87,7 @@ withNewWordArrayTrimmed# withNewWordArrayTrimmed# sz act = withNewWordArray# sz \mwa s -> case act mwa s of s' -> mwaTrimZeroes# mwa s' +{-# INLINE withNewWordArrayTrimmed# #-} -- | Create two new WordArray# of the given sizes (*in Word#*), apply the action -- to them, trim their most significant zeroes, then return them frozen @@ -101,6 +103,7 @@ withNewWordArray2Trimmed# sz1 sz2 act = withNewWordArray2# sz1 sz2 \mwa1 mwa2 s case act mwa1 mwa2 s of s' -> case mwaTrimZeroes# mwa1 s' of s'' -> mwaTrimZeroes# mwa2 s'' +{-# INLINE withNewWordArray2Trimmed# #-} -- | Create a new WordArray# of the given size (*in Word#*), apply the action to -- it. If the action returns true#, trim its most significant zeroes, then @@ -118,6 +121,7 @@ withNewWordArrayTrimmedMaybe# sz act = case runRW# io of (# _, a #) -> a (# s, _ #) -> case mwaTrimZeroes# mwa s of s -> case unsafeFreezeByteArray# mwa s of (# s, ba #) -> (# s, (# | ba #) #) +{-# INLINE withNewWordArrayTrimmedMaybe# #-} -- | Create a WordArray# from two Word# -- @@ -296,6 +300,7 @@ mwaInitArrayBinOp mwa wa wb op s = go 0# s case indexWordArray# wa i `op` indexWordArray# wb i of v -> case mwaWrite# mwa i v s' of s'' -> go (i +# 1#) s'' +{-# INLINE mwaInitArrayBinOp #-} -- | Write an element of the MutableWordArray mwaWrite# :: MutableWordArray# s -> Int# -> Word# -> State# s -> State# s View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a2b943982715f21de58eeeff6c1831f158a660f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0a2b943982715f21de58eeeff6c1831f158a660f You're receiving 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 Nov 10 14:12:57 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 10 Nov 2022 09:12:57 -0500 Subject: [Git][ghc/ghc][wip/T21623] Type vs Constraint: finally nailed Message-ID: <636d06e9be339_10da055ac8adc882667@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 30ee3c05 by Simon Peyton Jones at 2022-11-10T14:14:47+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30ee3c05985e5c9e64f66dbdde88db5cfc8a3af6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/30ee3c05985e5c9e64f66dbdde88db5cfc8a3af6 You're receiving 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 Nov 10 14:15:38 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 10 Nov 2022 09:15:38 -0500 Subject: [Git][ghc/ghc][wip/T22439] Wibbles Message-ID: <636d078a8eb00_10da0554a24883422@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22439 at Glasgow Haskell Compiler / GHC Commits: 5c5092ac by Simon Peyton Jones at 2022-11-10T14:17:22+00:00 Wibbles Fix up SetLevels - - - - - 2 changed files: - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs Changes: ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -27,7 +27,8 @@ module GHC.Core.Opt.Arity , arityTypeArity, idArityType -- ** Bottoming things - , exprIsDeadEnd, exprBotStrictness_maybe, arityTypeBotSigs_maybe + , exprIsDeadEnd, arityTypeBotSigs_maybe + , exprBotStrictness_maybe, idBotStrictness_maybe -- ** typeArity and the state hack , typeArity, typeOneShots, typeOneShot @@ -146,13 +147,21 @@ exprBotStrictness_maybe e = arityTypeBotSigs_maybe (cheapArityType e) arityTypeBotSigs_maybe :: ArityType -> Maybe (Arity, DmdSig, CprSig) -- Arity of a divergent function arityTypeBotSigs_maybe (AT lams div) - | isDeadEndDiv div = Just ( arity - , mkVanillaDmdSig arity botDiv + | isDeadEndDiv div = Just (arity + , mkVanillaDmdSig arity div , mkCprSig arity botCpr) | otherwise = Nothing where arity = length lams +idBotStrictness_maybe :: Id -> Maybe (Arity, DmdSig, CprSig) +idBotStrictness_maybe id + | isDeadEndDiv div = Just (length dmds, dmd_sig, idCprSig id) + | otherwise = Nothing + where + (dmds, div) = splitDmdSig dmd_sig + dmd_sig = idDmdSig id + {- Note [exprArity for applications] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -73,7 +73,7 @@ import GHC.Core.Utils ( exprType, exprIsHNF , collectMakeStaticArgs , mkLamTypes, extendInScopeSetBndrs ) -import GHC.Core.Opt.Arity ( exprBotStrictness_maybe, isOneShotBndr ) +import GHC.Core.Opt.Arity ( exprBotStrictness_maybe, idBotStrictness_maybe, isOneShotBndr ) import GHC.Core.FVs -- all of it import GHC.Core.Subst import GHC.Core.Make ( sortQuantVars ) @@ -1128,6 +1128,7 @@ lvlBind env (AnnNonRec bndr rhs) ; return (NonRec (TB bndr2 (FloatMe dest_lvl)) rhs', env') } where + deann_rhs = deAnnotate rhs bndr_ty = idType bndr ty_fvs = tyCoVarsOfType bndr_ty rhs_fvs = freeVarsOf rhs @@ -1135,11 +1136,12 @@ lvlBind env (AnnNonRec bndr rhs) abs_vars = abstractVars dest_lvl env bind_fvs dest_lvl = destLevel env bind_fvs ty_fvs (isFunction rhs) is_bot_lam is_join - deann_rhs = deAnnotate rhs - mb_bot_str = exprBotStrictness_maybe deann_rhs + mb_bot_str = idBotStrictness_maybe bndr is_bot_lam = isJust mb_bot_str - -- is_bot_lam: looks like (\xy. bot), maybe zero lams - -- NB: not isBottomThunk! See Note [Bottoming floats] point (3) + -- The Simplifier pins on strictness info, based on a call to arityType + -- Using that is faster and more accurate than calling exprBotStrictness_maybe + -- is_bot_lam: looks like (\xy. bot), maybe zero lams + -- NB: not isBottomThunk! See Note [Bottoming floats] point (3) n_extra = count isId abs_vars mb_join_arity = isJoinId_maybe bndr View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c5092ac4c9f2620b8cd38737040358781c99d54 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5c5092ac4c9f2620b8cd38737040358781c99d54 You're receiving 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 Nov 10 14:34:32 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 10 Nov 2022 09:34:32 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636d0bf82288a_10da054050cf49096bc@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - 689a2ab9 by Sebastian Graf at 2022-11-10T09:34:22-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - a1bb2aa0 by Sebastian Graf at 2022-11-10T09:34:22-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - cd1d2d1a by Simon Peyton Jones at 2022-11-10T09:34:23-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 30 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/TyCl/Instance.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Id/Make.hs - ghc/GHCi/UI/Tags.hs - testsuite/tests/backpack/should_compile/bkp47.stderr - testsuite/tests/backpack/should_fail/bkpfail25.stderr - testsuite/tests/deSugar/should_compile/T14546d.stderr - testsuite/tests/deriving/should_compile/T14094.stderr - testsuite/tests/deriving/should_compile/T4966.stderr - testsuite/tests/deriving/should_compile/T9968a.stderr - testsuite/tests/deriving/should_compile/deriving-1935.stderr - testsuite/tests/deriving/should_compile/drv003.stderr - testsuite/tests/ghci/scripts/T5820.stderr - testsuite/tests/ghci/scripts/ghci019.stderr - testsuite/tests/indexed-types/should_compile/Class3.stderr - testsuite/tests/indexed-types/should_compile/Simple2.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.hs - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl.stderr - + testsuite/tests/indexed-types/should_fail/BadFamInstDecl_aux.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.hs - + testsuite/tests/indexed-types/should_fail/HsBootFam.stderr - + testsuite/tests/indexed-types/should_fail/HsBootFam_aux.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e26bdb17f207db1e6aa626b61fcef7782999346c...cd1d2d1a49bf96ffff9772bf60a820e1d0bbbc7b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e26bdb17f207db1e6aa626b61fcef7782999346c...cd1d2d1a49bf96ffff9772bf60a820e1d0bbbc7b You're receiving 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 Nov 10 15:25:37 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Thu, 10 Nov 2022 10:25:37 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 22 commits: cmm: Introduce MemoryOrderings Message-ID: <636d17f1e9ccf_10da054050cf49330fe@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 1e025fb8 by Ben Gamari at 2022-11-10T09:28:42-05:00 cmm: Introduce MemoryOrderings - - - - - 82739430 by Ben Gamari at 2022-11-10T09:28:42-05:00 llvm: Respect memory specified orderings - - - - - 9281c802 by Ben Gamari at 2022-11-10T09:30:59-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - 4415c1ef by Ben Gamari at 2022-11-10T09:30:59-05:00 cmm/Parser: Reduce some repetition - - - - - 86ded8b8 by Ben Gamari at 2022-11-10T09:30:59-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - e95581e5 by Ben Gamari at 2022-11-10T09:42:58-05:00 cmm/Parser: Atomic load syntax - - - - - 5569a9f6 by Ben Gamari at 2022-11-10T09:43:02-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - b12d07cb by Ben Gamari at 2022-11-10T09:43:02-05:00 rts/Messages: Refactor - - - - - 7ac21924 by Ben Gamari at 2022-11-10T09:43:02-05:00 Ordering fixes - - - - - d41c6a8c by Ben Gamari at 2022-11-10T09:43:02-05:00 eventlog: Silence spurious data race - - - - - 2f896ba9 by Ben Gamari at 2022-11-10T09:43:02-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 7dabeb15 by Ben Gamari at 2022-11-10T09:43:02-05:00 unlockClosure - - - - - 6970367a by Ben Gamari at 2022-11-10T09:43:02-05:00 Introduce and use GET_INFO_ACQUIRE - - - - - beddf374 by Ben Gamari at 2022-11-10T09:43:02-05:00 Fences - - - - - 8965eebb by Ben Gamari at 2022-11-10T09:43:02-05:00 LOAD_INFO - - - - - eaf72829 by Ben Gamari at 2022-11-10T09:43:02-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 8ece45a1 by Ben Gamari at 2022-11-10T09:43:02-05:00 Improve heap memory barrier note - - - - - 37af3f28 by Ben Gamari at 2022-11-10T09:43:02-05:00 load_acquire_w - - - - - a3dac035 by Ben Gamari at 2022-11-10T09:43:02-05:00 rts: Introduce getNumCapabilities - - - - - 24260401 by Ben Gamari at 2022-11-10T09:43:03-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - ca2bbba1 by Ben Gamari at 2022-11-10T09:43:03-05:00 rts: Mark accesses to Capability.context_switch as relaxed Also Capability.interrupt. - - - - - d883495c by Ben Gamari at 2022-11-10T10:11:05-05:00 Note - - - - - 30 changed files: - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToC.hs - compiler/GHC/CmmToLlvm/CodeGen.hs - compiler/GHC/Driver/Config/Cmm.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/StgToCmm/ExtCode.hs - compiler/GHC/StgToCmm/Prim.hs - compiler/GHC/Utils/Logger.hs - compiler/ghc.cabal.in - docs/users_guide/debugging.rst - rts/Apply.cmm - rts/Capability.c - rts/Capability.h - rts/HeapStackCheck.cmm - rts/Messages.c - rts/Messages.h - rts/PrimOps.cmm - rts/Printer.c - rts/ProfHeap.c - rts/ProfilerReport.c - rts/ProfilerReportJson.c The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a2751d716045c5ae511ff4091068601cd2566cde...d883495cd2d6c5370d5db83171355be9dc17a629 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a2751d716045c5ae511ff4091068601cd2566cde...d883495cd2d6c5370d5db83171355be9dc17a629 You're receiving 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 Nov 10 17:44:53 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 10 Nov 2022 12:44:53 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: WorkWrap: Unboxing unboxed tuples is not always useful (#22388) Message-ID: <636d38953a54e_10da054796c98977192@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: b85a8080 by Sebastian Graf at 2022-11-10T12:44:36-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - b69660e3 by Sebastian Graf at 2022-11-10T12:44:36-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 7027c04d by Simon Peyton Jones at 2022-11-10T12:44:37-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 12 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Types/Id/Make.hs - + testsuite/tests/stranal/should_compile/T22388.hs - + testsuite/tests/stranal/should_compile/T22388.stderr - testsuite/tests/stranal/should_compile/all.T - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1762,7 +1763,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1772,91 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Recall that unboxed tuples will be flattened to individual arguments during +unarisation. Here, `unboxed` will have 5 arguments at runtime because of the +nested unboxed tuple, which will be flattened to 4 args. So it's best to leave +`(a,b)` boxed (because we already are above our arg threshold), but unbox `c` +through `f` because that doesn't increase the number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. For example at the top-level, `(# x,y #)` is to be +treated just like two arguments `x` and `y`. +Of course, for that to work, our budget calculations must initialise +'max_wkr_args' to 5, based on the 'unariseArity' of each Core arg: That would be +1 for the pair and 4 for the unboxed pair. Then when we decide whether to unbox +the unboxed pair, we *directly* recurse into the fields, spending our budget +on retaining `c` and (after recursing once more) `d` through `f` as arguments, +depleting our budget completely in the first layer. Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1877,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets + +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1900,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1913,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1960,49 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg + -- The unboxed case does happen here, for example + -- app g x = g x :: (# Int, Int #) + -- here, `x` is used `L`azy and thus Boxed + + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- We currently don't return DoUnbox for unboxed sums. + -- But hopefully we will at some point. When that happens, + -- it would still be impossible to predict the effect + -- of dropping absent fields and unboxing others on the + -- unariseArity of the sum without losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) + where + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) -- "~": This match *must* be lazy! | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) - where - decremented_bg = MkB (bg_top-1) bg_inner add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1497,9 +1497,10 @@ rebuild env expr cont ApplyToTy { sc_arg_ty = ty, sc_cont = cont} -> rebuild env (App expr (Type ty)) cont - ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag, sc_cont = cont} + ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag + , sc_cont = cont, sc_hole_ty = fun_ty } -- See Note [Avoid redundant simplification] - -> do { (_, _, arg') <- simplArg env dup_flag se arg + -> do { (_, _, arg') <- simplArg env dup_flag fun_ty se arg ; rebuild env (App expr arg') cont } completeBindX :: SimplEnv @@ -1598,7 +1599,8 @@ 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_dup = dup, sc_cont = tail + , sc_hole_ty = fun_ty }) | Just (m_co1, m_co2) <- pushCoValArg co , fixed_rep m_co1 = {-#SCC "addCoerce-pushCoValArg" #-} @@ -1610,7 +1612,7 @@ simplCast env body co0 cont0 -- See Note [Avoiding exponential behaviour] MCo co1 -> - do { (dup', arg_se', arg') <- simplArg env dup arg_se arg + do { (dup', arg_se', arg') <- simplArg env dup fun_ty arg_se arg -- When we build the ApplyTo we can't mix the OutCoercion -- 'co' with the InExpr 'arg', so we simplify -- to make it all consistent. It's a bit messy. @@ -1636,14 +1638,16 @@ simplCast env body co0 cont0 -- See Note [Representation polymorphism invariants] in GHC.Core -- test: typecheck/should_run/EtaExpandLevPoly -simplArg :: SimplEnv -> DupFlag -> StaticEnv -> CoreExpr +simplArg :: SimplEnv -> DupFlag + -> OutType -- Type of the function applied to this arg + -> StaticEnv -> CoreExpr -- Expression with its static envt -> SimplM (DupFlag, StaticEnv, OutExpr) -simplArg env dup_flag arg_env arg +simplArg env dup_flag fun_ty arg_env arg | isSimplified dup_flag = return (dup_flag, arg_env, arg) | otherwise = do { let arg_env' = arg_env `setInScopeFromE` env - ; arg' <- simplExpr arg_env' arg + ; arg' <- simplExprC arg_env' arg (mkBoringStop (funArgTy fun_ty)) ; return (Simplified, zapSubstEnv arg_env', arg') } -- Return a StaticEnv that includes the in-scope set from 'env', -- because arg' may well mention those variables (#20639) @@ -2029,6 +2033,21 @@ zap the SubstEnv. This is VITAL. Consider We'll clone the inner \x, adding x->x' in the id_subst Then when we inline y, we must *not* replace x by x' in the inlined copy!! + +Note [Fast path for data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For applications of a data constructor worker, the full glory of +rebuildCall is a waste of effort; +* They never inline, obviously +* They have no rewrite rules +* They are not strict (see Note [Data-con worker strictness] + in GHC.Core.DataCon) +So it's fine to zoom straight to `rebuild` which just rebuilds the +call in a very straightforward way. + +Some programs have a /lot/ of data constructors in the source program +(compiler/perf/T9961 is an example), so this fast path can be very +valuable. -} simplVar :: SimplEnv -> InVar -> SimplM OutExpr @@ -2046,6 +2065,9 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont + | isDataConWorkId var -- See Note [Fast path for data constructors] + = rebuild env (Var var) cont + | otherwise = case substId env var of ContEx tvs cvs ids e -> simplExprF env' e cont -- Don't trimJoinCont; haven't already simplified e, @@ -2315,6 +2337,8 @@ field of the ArgInfo record is the state of a little state-machine: If we inline `f` before simplifying `BIG` well use preInlineUnconditionally, and we'll simplify BIG once, at x's occurrence, rather than twice. +* GHC.Core.Opt.Simplify.Utils. mkRewriteCall: if there are no rules, and no + unfolding, we can skip both TryRules and TryInlining, which saves work. Note [Avoid redundant simplification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3645,7 +3669,7 @@ mkDupableContWithDmds env dmds do { let (dmd:cont_dmds) = dmds -- Never fails ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 - ; (_, se', arg') <- simplArg env' dup se arg + ; (_, se', arg') <- simplArg env' dup hole_ty se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ; let all_floats = floats1 `addLetFloats` let_floats2 ; return ( all_floats ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -425,12 +425,22 @@ decArgCount :: RewriteCall -> RewriteCall decArgCount (TryRules n rules) = TryRules (n-1) rules decArgCount rew = rew -mkTryRules :: [CoreRule] -> RewriteCall +mkRewriteCall :: Id -> RuleEnv -> RewriteCall -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration -mkTryRules [] = TryInlining -mkTryRules rs = TryRules n_required rs +-- We try to skip any unnecessary stages: +-- No rules => skip TryRules +-- No unfolding => skip TryInlining +-- This skipping is "just" for efficiency. But rebuildCall is +-- quite a heavy hammer, so skipping stages is a good plan. +-- And it's extremely simple to do. +mkRewriteCall fun rule_env + | not (null rules) = TryRules n_required rules + | canUnfold unf = TryInlining + | otherwise = TryNothing where - n_required = maximum (map ruleArity rs) + n_required = maximum (map ruleArity rules) + rules = getRules rule_env fun + unf = idUnfolding fun {- ************************************************************************ @@ -604,21 +614,23 @@ mkArgInfo :: SimplEnv -> RuleEnv -> Id -> SimplCont -> ArgInfo mkArgInfo env rule_base fun cont | n_val_args < idArity fun -- Note [Unsaturated functions] = ArgInfo { ai_fun = fun, ai_args = [] - , ai_rewrite = fun_rules + , ai_rewrite = fun_rewrite , ai_encl = False , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise = ArgInfo { ai_fun = fun , ai_args = [] - , ai_rewrite = fun_rules - , ai_encl = notNull rules || contHasRules cont + , ai_rewrite = fun_rewrite + , ai_encl = fun_has_rules || contHasRules cont , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where - rules = getRules rule_base fun - fun_rules = mkTryRules rules - n_val_args = countValArgs cont + n_val_args = countValArgs cont + fun_rewrite = mkRewriteCall fun rule_base + fun_has_rules = case fun_rewrite of + TryRules {} -> True + _ -> False vanilla_discounts, arg_discounts :: [Int] vanilla_discounts = repeat 0 ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , isGoodWorker, badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,23 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True - -isGoodWorker :: Bool -> Bool -isGoodWorker = id +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -826,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -843,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -855,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -875,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -887,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -895,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -910,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts - -> Var-> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> Var -> DataConPatContext Demand + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -939,13 +940,14 @@ unbox_one_arg opts arg_var -- See Note [Call-by-value for worker args] all_str_marks = (map (const NotMarkedStrict) ex_tvs') ++ con_str_marks - ; (_sub_args_quality, worker_args, wrap_fn, wrap_args) + ; (nested_useful, worker_args, wrap_fn, wrap_args) <- mkWWstr opts (ex_tvs' ++ arg_ids') all_str_marks ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co - - ; return (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } - -- Don't pass the arg, rebox instead + -- See Note [Unboxing through unboxed tuples] + ; return $ if isUnboxedTupleDataCon dc && not nested_useful + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1195,6 +1197,26 @@ fragile because `MkT` is strict in its Int# argument, so we get an absentError exception when we shouldn't. Very annoying! +Note [Unboxing through unboxed tuples] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We should not to a worker/wrapper split just for unboxing the components of +an unboxed tuple (in the result *or* argument, #22388). Consider + boring_res x y = (# y, x #) +It's entirely pointless to split for the constructed unboxed pair to + $wboring_res x y = (# y, x #) + boring_res = case $wboring_res x y of (# a, b #) -> (# a, b #) +`boring_res` will immediately simplify to an alias for `$wboring_res`! + +Similarly, the unboxed tuple might occur in argument position + boring_arg (# x, y, z #) = (# z, x, y #) +It's entirely pointless to "unbox" the triple + $wboring_arg x y z = (# z, x, y #) + boring_arg (# x, y, z #) = $wboring_arg x y z +because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. + +Conclusion: Only consider unboxing an unboxed tuple useful when we will +also unbox its components. That is governed by the `usefulSplit` mechanism. + ************************************************************************ * * Type scrutiny that is specific to demand analysis @@ -1376,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1398,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1411,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1441,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1467,11 +1489,10 @@ unbox_one_result opts res_bndr -- this_work_unbox_res alt = (case res_bndr |> co of C a b -> [a,b]) this_work_unbox_res = mkUnpackCase (Var res_bndr) co cprCaseBndrMult dc arg_ids - -- Don't try to WW an unboxed tuple return type when there's nothing inside - -- to unbox further. + -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -9,7 +9,7 @@ -- The 'CoreRule' datatype itself is declared elsewhere. module GHC.Core.Rules ( -- ** Looking up rules - lookupRule, + RuleEnv, lookupRule, -- ** RuleBase, RuleEnv emptyRuleBase, mkRuleBase, extendRuleBaseList, ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -585,6 +585,7 @@ mkDataConWorkId wkr_name data_con `setInlinePragInfo` wkr_inline_prag `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated, -- even if arity = 0 + -- No strictness: see Note [Data-con worker strictness] in GHC.Core.DataCon wkr_inline_prag = defaultInlinePragma { inl_rule = ConLike } wkr_arity = dataConRepArity data_con ===================================== testsuite/tests/stranal/should_compile/T22388.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Unboxing through unboxed tuples] +module T22388 where + +-- Don't split, because neither the result not arg cancels away a box. +boring :: (# Int, Int, Int #) -> (# Int, Int, Int #) +boring (# x, y, z #) = (# y, z, x #) +{-# NOINLINE boring #-} + +-- Do split, because we get to drop z and pass x and y unboxed +interesting :: (# Int, Int, Int #) -> (# Int #) +interesting (# x, y, z #) = let !t = x + y in (# t #) +{-# NOINLINE interesting #-} ===================================== testsuite/tests/stranal/should_compile/T22388.stderr ===================================== @@ -0,0 +1,92 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 48, types: 81, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 8, types: 23, coercions: 0, joins: 0/0} +boring [InlPrag=NOINLINE] + :: (# Int, Int, Int #) -> (# Int, Int, Int #) +[GblId, Arity=1, Str=<1!P(L,L,L)>, Cpr=1, Unf=OtherCon []] +boring + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# x, y, z #) -> (# y, z, x #) } + +-- RHS size: {terms: 5, types: 2, coercions: 0, joins: 0/0} +T22388.$winteresting [InlPrag=NOINLINE] + :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=, Unf=OtherCon []] +T22388.$winteresting + = \ (ww :: GHC.Prim.Int#) (ww1 :: GHC.Prim.Int#) -> + GHC.Prim.+# ww ww1 + +-- RHS size: {terms: 18, types: 24, coercions: 0, joins: 0/0} +interesting [InlPrag=NOINLINE[final]] + :: (# Int, Int, Int #) -> (# Int #) +[GblId, + Arity=1, + Str=<1!P(1!P(L),1!P(L),A)>, + Cpr=1(1), + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (ds [Occ=Once1!] :: (# Int, Int, Int #)) -> + case ds of + { (# ww [Occ=Once1!], ww1 [Occ=Once1!], _ [Occ=Dead] #) -> + case ww of { GHC.Types.I# ww3 [Occ=Once1] -> + case ww1 of { GHC.Types.I# ww4 [Occ=Once1] -> + case T22388.$winteresting ww3 ww4 of ww5 [Occ=Once1] { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + }}] +interesting + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# ww, ww1, ww2 #) -> + case ww of { GHC.Types.I# ww3 -> + case ww1 of { GHC.Types.I# ww4 -> + case T22388.$winteresting ww3 ww4 of ww5 { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + } + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T22388.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule3 = GHC.Types.TrNameS T22388.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T22388.$trModule2 = "T22388"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule1 = GHC.Types.TrNameS T22388.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule + = GHC.Types.Module T22388.$trModule3 T22388.$trModule1 + + + ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -86,3 +86,5 @@ test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', ' test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) test('T22039', normal, compile, ['']) +# T22388: Should see $winteresting but not $wboring +test('T22388', [ grep_errmsg(r'^\S+\$w\S+') ], compile, ['-dsuppress-uniques -ddump-simpl']) ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,47 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} + +-- Point: Demand on `x` is lazy and thus Unboxed +app :: ((# Int, Int #) -> (# Int, Int #)) -> (# Int, Int #) -> (# Int, Int #) +app g x = g x ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.app: +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd1d2d1a49bf96ffff9772bf60a820e1d0bbbc7b...7027c04d6f373607bb15ce3ad403b14feb3302ab -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cd1d2d1a49bf96ffff9772bf60a820e1d0bbbc7b...7027c04d6f373607bb15ce3ad403b14feb3302ab You're receiving 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 Nov 10 17:58:29 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Thu, 10 Nov 2022 12:58:29 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22416 Message-ID: <636d3bc546385_10da05526c0980284@gitlab.mail> Simon Peyton Jones pushed new branch wip/T22416 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22416 You're receiving 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 Nov 10 20:55:16 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 10 Nov 2022 15:55:16 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Fire RULES in the Specialiser Message-ID: <636d6534e9000_10da0554a241002818@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - 48088c7c by Sebastian Graf at 2022-11-10T15:54:48-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - ec91ec94 by Sebastian Graf at 2022-11-10T15:54:48-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 34937a6f by Simon Peyton Jones at 2022-11-10T15:54:49-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 29 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Unit/External.hs - libraries/base/GHC/Ix.hs - libraries/base/GHC/Real.hs - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T21851_2.hs - + testsuite/tests/simplCore/should_compile/T21851_2.stderr - + testsuite/tests/simplCore/should_compile/T21851_2a.hs - testsuite/tests/simplCore/should_compile/all.T - + testsuite/tests/stranal/should_compile/T22388.hs - + testsuite/tests/stranal/should_compile/T22388.stderr - testsuite/tests/stranal/should_compile/all.T - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -85,9 +85,8 @@ module GHC.Core ( IsOrphan(..), isOrphan, notOrphan, chooseOrphanAnchor, -- * Core rule data types - CoreRule(..), RuleBase, - RuleName, RuleFun, IdUnfoldingFun, InScopeEnv, - RuleEnv(..), RuleOpts, mkRuleEnv, emptyRuleEnv, + CoreRule(..), + RuleName, RuleFun, IdUnfoldingFun, InScopeEnv, RuleOpts, -- ** Operations on 'CoreRule's ruleArity, ruleName, ruleIdName, ruleActivation, @@ -105,7 +104,6 @@ import GHC.Core.Coercion import GHC.Core.Rules.Config ( RuleOpts ) import GHC.Types.Name import GHC.Types.Name.Set -import GHC.Types.Name.Env( NameEnv ) import GHC.Types.Literal import GHC.Types.Tickish import GHC.Core.DataCon @@ -1062,6 +1060,12 @@ has two major consequences M. But it's painful, because it means we need to keep track of all the orphan modules below us. + * The "visible orphan modules" are all the orphan module in the transitive + closure of the imports of this module. + + * During instance lookup, we filter orphan instances depending on + whether or not the instance is in a visible orphan module. + * A non-orphan is not finger-printed separately. Instead, for fingerprinting purposes it is treated as part of the entity it mentions on the LHS. For example @@ -1076,12 +1080,20 @@ has two major consequences Orphan-hood is computed * For class instances: - when we make a ClsInst - (because it is needed during instance lookup) + when we make a ClsInst in GHC.Core.InstEnv.mkLocalInstance + (because it is needed during instance lookup) + See Note [When exactly is an instance decl an orphan?] + in GHC.Core.InstEnv + + * For rules + when we generate a CoreRule (GHC.Core.Rules.mkRule) + + * For family instances: + when we generate an IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst) + +Orphan-hood is persisted into interface files, in ClsInst, FamInst, +and CoreRules. - * For rules and family instances: - when we generate an IfaceRule (GHC.Iface.Make.coreRuleToIfaceRule) - or IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst) -} {- @@ -1096,49 +1108,6 @@ GHC.Core.FVs, GHC.Core.Subst, GHC.Core.Ppr, GHC.Core.Tidy also inspect the representation. -} --- | Gathers a collection of 'CoreRule's. Maps (the name of) an 'Id' to its rules -type RuleBase = NameEnv [CoreRule] - -- The rules are unordered; - -- we sort out any overlaps on lookup - --- | A full rule environment which we can apply rules from. Like a 'RuleBase', --- but it also includes the set of visible orphans we use to filter out orphan --- rules which are not visible (even though we can see them...) -data RuleEnv - = RuleEnv { re_base :: [RuleBase] -- See Note [Why re_base is a list] - , re_visible_orphs :: ModuleSet - } - -mkRuleEnv :: RuleBase -> [Module] -> RuleEnv -mkRuleEnv rules vis_orphs = RuleEnv [rules] (mkModuleSet vis_orphs) - -emptyRuleEnv :: RuleEnv -emptyRuleEnv = RuleEnv [] emptyModuleSet - -{- -Note [Why re_base is a list] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In Note [Overall plumbing for rules], it is explained that the final -RuleBase which we must consider is combined from 4 different sources. - -During simplifier runs, the fourth source of rules is constantly being updated -as new interfaces are loaded into the EPS. Therefore just before we check to see -if any rules match we get the EPS RuleBase and combine it with the existing RuleBase -and then perform exactly 1 lookup into the new map. - -It is more efficient to avoid combining the environments and store the uncombined -environments as we can instead perform 1 lookup into each environment and then combine -the results. - -Essentially we use the identity: - -> lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) -> = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 - -The latter being more efficient as we don't construct an intermediate -map. --} -- | A 'CoreRule' is: -- ===================================== compiler/GHC/Core/InstEnv.hs ===================================== @@ -323,7 +323,9 @@ mkImportedInstance cls_nm mb_tcs dfun_name dfun oflag orphan {- Note [When exactly is an instance decl an orphan?] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - (see GHC.Iface.Make.instanceToIfaceInst, which implements this) +(See GHC.Iface.Make.instanceToIfaceInst, which implements this.) +See Note [Orphans] in GHC.Core + Roughly speaking, an instance is an orphan if its head (after the =>) mentions nothing defined in this module. ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1520,6 +1521,9 @@ $wtheresCrud = \ ww ww1 -> ... ``` This is currently a bug that we willingly accept and it's documented in #21128. + +See also Note [indexError] in base:GHC.Ix, which describes how we use +SPECIALISE to mitigate this problem for indexError. -} {- ********************************************************************* @@ -1762,7 +1766,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1775,91 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Recall that unboxed tuples will be flattened to individual arguments during +unarisation. Here, `unboxed` will have 5 arguments at runtime because of the +nested unboxed tuple, which will be flattened to 4 args. So it's best to leave +`(a,b)` boxed (because we already are above our arg threshold), but unbox `c` +through `f` because that doesn't increase the number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. For example at the top-level, `(# x,y #)` is to be +treated just like two arguments `x` and `y`. +Of course, for that to work, our budget calculations must initialise +'max_wkr_args' to 5, based on the 'unariseArity' of each Core arg: That would be +1 for the pair and 4 for the unboxed pair. Then when we decide whether to unbox +the unboxed pair, we *directly* recurse into the fields, spending our budget +on retaining `c` and (after recursing once more) `d` through `f` as arguments, +depleting our budget completely in the first layer. Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1880,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) + +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1903,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1916,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1963,49 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg + -- The unboxed case does happen here, for example + -- app g x = g x :: (# Int, Int #) + -- here, `x` is used `L`azy and thus Boxed + + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- We currently don't return DoUnbox for unboxed sums. + -- But hopefully we will at some point. When that happens, + -- it would still be impossible to predict the effect + -- of dropping absent fields and unboxing others on the + -- unariseArity of the sum without losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) + where + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) -- "~": This match *must* be lazy! | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) - where - decremented_bg = MkB (bg_top-1) bg_inner add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/Monad.hs ===================================== @@ -19,10 +19,10 @@ module GHC.Core.Opt.Monad ( -- ** Reading from the monad getHscEnv, getModule, - getRuleBase, getExternalRuleBase, + initRuleEnv, getExternalRuleBase, getDynFlags, getPackageFamInstEnv, getInteractiveContext, - getVisibleOrphanMods, getUniqMask, + getUniqMask, getPrintUnqualified, getSrcSpanM, -- ** Writing to the monad @@ -45,7 +45,7 @@ import GHC.Prelude hiding ( read ) import GHC.Driver.Session import GHC.Driver.Env -import GHC.Core +import GHC.Core.Rules ( RuleBase, RuleEnv, mkRuleEnv ) import GHC.Core.Opt.Stats ( SimplCount, zeroSimplCount, plusSimplCount ) import GHC.Types.Annotations @@ -114,12 +114,11 @@ pprFloatOutSwitches sw data CoreReader = CoreReader { cr_hsc_env :: HscEnv, - cr_rule_base :: RuleBase, + cr_rule_base :: RuleBase, -- Home package table rules cr_module :: Module, cr_print_unqual :: PrintUnqualified, cr_loc :: SrcSpan, -- Use this for log/error messages so they -- are at least tagged with the right source file - cr_visible_orphan_mods :: !ModuleSet, cr_uniq_mask :: !Char -- Mask for creating unique values } @@ -181,19 +180,17 @@ runCoreM :: HscEnv -> RuleBase -> Char -- ^ Mask -> Module - -> ModuleSet -> PrintUnqualified -> SrcSpan -> CoreM a -> IO (a, SimplCount) -runCoreM hsc_env rule_base mask mod orph_imps print_unqual loc m +runCoreM hsc_env rule_base mask mod print_unqual loc m = liftM extract $ runIOEnv reader $ unCoreM m where reader = CoreReader { cr_hsc_env = hsc_env, cr_rule_base = rule_base, cr_module = mod, - cr_visible_orphan_mods = orph_imps, cr_print_unqual = print_unqual, cr_loc = loc, cr_uniq_mask = mask @@ -245,15 +242,18 @@ liftIOWithCount what = liftIO what >>= (\(count, x) -> addSimplCount count >> re getHscEnv :: CoreM HscEnv getHscEnv = read cr_hsc_env -getRuleBase :: CoreM RuleBase -getRuleBase = read cr_rule_base +getHomeRuleBase :: CoreM RuleBase +getHomeRuleBase = read cr_rule_base + +initRuleEnv :: ModGuts -> CoreM RuleEnv +initRuleEnv guts + = do { hpt_rules <- getHomeRuleBase + ; eps_rules <- getExternalRuleBase + ; return (mkRuleEnv guts eps_rules hpt_rules) } getExternalRuleBase :: CoreM RuleBase getExternalRuleBase = eps_rule_base <$> get_eps -getVisibleOrphanMods :: CoreM ModuleSet -getVisibleOrphanMods = read cr_visible_orphan_mods - getPrintUnqualified :: CoreM PrintUnqualified getPrintUnqualified = read cr_print_unqual ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -22,7 +22,7 @@ import GHC.Platform.Ways ( hasWay, Way(WayProf) ) import GHC.Core import GHC.Core.Opt.CSE ( cseProgram ) -import GHC.Core.Rules ( mkRuleBase, ruleCheckProgram, getRules ) +import GHC.Core.Rules ( RuleBase, mkRuleBase, ruleCheckProgram, getRules ) import GHC.Core.Ppr ( pprCoreBindings ) import GHC.Core.Utils ( dumpIdInfoOfProgram ) import GHC.Core.Lint ( lintAnnots ) @@ -53,9 +53,7 @@ import GHC.Utils.Logger as Logger import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Unit.Module.Env import GHC.Unit.Module.ModGuts -import GHC.Unit.Module.Deps import GHC.Types.Id.Info import GHC.Types.Basic @@ -78,14 +76,12 @@ import GHC.Unit.Module core2core :: HscEnv -> ModGuts -> IO ModGuts core2core hsc_env guts@(ModGuts { mg_module = mod , mg_loc = loc - , mg_deps = deps , mg_rdr_env = rdr_env }) = do { let builtin_passes = getCoreToDo dflags hpt_rule_base extra_vars - orph_mods = mkModuleSet (mod : dep_orphs deps) uniq_mask = 's' - ; + ; (guts2, stats) <- runCoreM hsc_env hpt_rule_base uniq_mask mod - orph_mods print_unqual loc $ + print_unqual loc $ do { hsc_env' <- getHscEnv ; all_passes <- withPlugins (hsc_plugins hsc_env') installCoreToDos @@ -121,7 +117,8 @@ core2core hsc_env guts@(ModGuts { mg_module = mod -} getCoreToDo :: DynFlags -> RuleBase -> [Var] -> [CoreToDo] -getCoreToDo dflags rule_base extra_vars +-- This function builds the pipeline of optimisations +getCoreToDo dflags hpt_rule_base extra_vars = flatten_todos core_todo where phases = simplPhases dflags @@ -176,7 +173,7 @@ getCoreToDo dflags rule_base extra_vars ---------------------------- run_simplifier mode iter - = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode rule_base + = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode hpt_rule_base simpl_phase phase name iter = CoreDoPasses $ [ maybe_strictness_before phase @@ -573,11 +570,9 @@ ruleCheckPass current_phase pat guts = do logger <- getLogger withTiming logger (text "RuleCheck"<+>brackets (ppr $ mg_module guts)) (const ()) $ do - rb <- getRuleBase - vis_orphs <- getVisibleOrphanMods - let rule_fn fn = getRules (RuleEnv [rb] vis_orphs) fn - ++ (mg_rules guts) - let ropts = initRuleOpts dflags + rule_env <- initRuleEnv guts + let rule_fn fn = getRules rule_env fn + ropts = initRuleOpts dflags liftIO $ logDumpMsg logger "Rule check" (ruleCheckProgram ropts current_phase pat rule_fn (mg_binds guts)) ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -10,7 +10,7 @@ import GHC.Prelude import GHC.Driver.Flags import GHC.Core -import GHC.Core.Rules ( extendRuleBaseList, extendRuleEnv, addRuleInfo ) +import GHC.Core.Rules import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize ) @@ -31,7 +31,6 @@ import GHC.Utils.Constants (debugIsOn) import GHC.Unit.Env ( UnitEnv, ueEPS ) import GHC.Unit.External import GHC.Unit.Module.ModGuts -import GHC.Unit.Module.Deps import GHC.Types.Id import GHC.Types.Id.Info @@ -81,7 +80,7 @@ simplifyExpr logger euc opts expr simpl_env = mkSimplEnv (se_mode opts) fam_envs top_env_cfg = se_top_env_cfg opts read_eps_rules = eps_rule_base <$> eucEPS euc - read_ruleenv = extendRuleEnv emptyRuleEnv <$> read_eps_rules + read_ruleenv = updExternalPackageRules emptyRuleEnv <$> read_eps_rules ; let sz = exprSize expr @@ -132,11 +131,11 @@ simplExprGently env expr = do -- The values of this datatype are /only/ driven by the demands of that function. data SimplifyOpts = SimplifyOpts { so_dump_core_sizes :: !Bool - , so_iterations :: !Int - , so_mode :: !SimplMode + , so_iterations :: !Int + , so_mode :: !SimplMode , so_pass_result_cfg :: !(Maybe LintPassResultConfig) - , so_rule_base :: !RuleBase - , so_top_env_cfg :: !TopEnvConfig + , so_hpt_rules :: !RuleBase + , so_top_env_cfg :: !TopEnvConfig } simplifyPgm :: Logger @@ -148,11 +147,10 @@ simplifyPgm :: Logger simplifyPgm logger unit_env opts guts@(ModGuts { mg_module = this_mod , mg_rdr_env = rdr_env - , mg_deps = deps - , mg_binds = binds, mg_rules = rules + , mg_binds = binds, mg_rules = local_rules , mg_fam_inst_env = fam_inst_env }) = do { (termination_msg, it_count, counts_out, guts') - <- do_iteration 1 [] binds rules + <- do_iteration 1 [] binds local_rules ; when (logHasDumpFlag logger Opt_D_verbose_core2core && logHasDumpFlag logger Opt_D_dump_simpl_stats) $ @@ -169,7 +167,6 @@ simplifyPgm logger unit_env opts dump_core_sizes = so_dump_core_sizes opts mode = so_mode opts max_iterations = so_iterations opts - hpt_rule_base = so_rule_base opts top_env_cfg = so_top_env_cfg opts print_unqual = mkPrintUnqualified unit_env rdr_env active_rule = activeRule mode @@ -178,13 +175,18 @@ simplifyPgm logger unit_env opts -- the old bindings are retained until the end of all simplifier iterations !guts_no_binds = guts { mg_binds = [], mg_rules = [] } + hpt_rule_env :: RuleEnv + hpt_rule_env = mkRuleEnv guts emptyRuleBase (so_hpt_rules opts) + -- emptyRuleBase: no EPS rules yet; we will update + -- them on each iteration to pick up the most up to date set + do_iteration :: Int -- Counts iterations -> [SimplCount] -- Counts from earlier iterations, reversed - -> CoreProgram -- Bindings in - -> [CoreRule] -- and orphan rules + -> CoreProgram -- Bindings + -> [CoreRule] -- Local rules for imported Ids -> IO (String, Int, SimplCount, ModGuts) - do_iteration iteration_no counts_so_far binds rules + do_iteration iteration_no counts_so_far binds local_rules -- iteration_no is the number of the iteration we are -- about to begin, with '1' for the first | iteration_no > max_iterations -- Stop if we've run out of iterations @@ -200,7 +202,7 @@ simplifyPgm logger unit_env opts -- number of iterations we actually completed return ( "Simplifier baled out", iteration_no - 1 , totalise counts_so_far - , guts_no_binds { mg_binds = binds, mg_rules = rules } ) + , guts_no_binds { mg_binds = binds, mg_rules = local_rules } ) -- Try and force thunks off the binds; significantly reduces -- space usage, especially with -O. JRS, 000620. @@ -209,8 +211,8 @@ simplifyPgm logger unit_env opts = do { -- Occurrence analysis let { tagged_binds = {-# SCC "OccAnal" #-} - occurAnalysePgm this_mod active_unf active_rule rules - binds + occurAnalysePgm this_mod active_unf active_rule + local_rules binds } ; Logger.putDumpFileMaybe logger Opt_D_dump_occur_anal "Occurrence analysis" FormatCore @@ -221,24 +223,29 @@ simplifyPgm logger unit_env opts -- poke on IdInfo thunks, which in turn brings in new rules -- behind the scenes. Otherwise there's a danger we'll simply -- miss the rules for Ids hidden inside imported inlinings - -- Hence just before attempting to match rules we read on the EPS - -- value and then combine it when the existing rule base. + -- Hence just before attempting to match a rule we read the EPS + -- value (via read_rule_env) and then combine it with the existing rule base. -- See `GHC.Core.Opt.Simplify.Monad.getSimplRules`. - eps <- ueEPS unit_env ; - let { -- Forcing this value to avoid unnessecary allocations. + eps <- ueEPS unit_env ; + let { -- base_rule_env contains + -- (a) home package rules, fixed across all iterations + -- (b) local rules (substituted) from `local_rules` arg to do_iteration + -- Forcing base_rule_env to avoid unnecessary allocations. -- Not doing so results in +25.6% allocations of LargeRecord. - ; !rule_base = extendRuleBaseList hpt_rule_base rules - ; vis_orphs = this_mod : dep_orphs deps - ; base_ruleenv = mkRuleEnv rule_base vis_orphs + ; !base_rule_env = updLocalRules hpt_rule_env local_rules + + ; read_eps_rules :: IO PackageRuleBase ; read_eps_rules = eps_rule_base <$> ueEPS unit_env - ; read_ruleenv = extendRuleEnv base_ruleenv <$> read_eps_rules + + ; read_rule_env :: IO RuleEnv + ; read_rule_env = updExternalPackageRules base_rule_env <$> read_eps_rules ; fam_envs = (eps_fam_inst_env eps, fam_inst_env) ; simpl_env = mkSimplEnv mode fam_envs } ; -- Simplify the program ((binds1, rules1), counts1) <- - initSmpl logger read_ruleenv top_env_cfg sz $ + initSmpl logger read_rule_env top_env_cfg sz $ do { (floats, env1) <- {-# SCC "SimplTopBinds" #-} simplTopBinds simpl_env tagged_binds @@ -246,7 +253,7 @@ simplifyPgm logger unit_env opts -- for imported Ids. Eg RULE map my_f = blah -- If we have a substitution my_f :-> other_f, we'd better -- apply it to the rule to, or it'll never match - ; rules1 <- simplImpRules env1 rules + ; rules1 <- simplImpRules env1 local_rules ; return (getTopFloatBinds floats, rules1) } ; ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1497,9 +1497,10 @@ rebuild env expr cont ApplyToTy { sc_arg_ty = ty, sc_cont = cont} -> rebuild env (App expr (Type ty)) cont - ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag, sc_cont = cont} + ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag + , sc_cont = cont, sc_hole_ty = fun_ty } -- See Note [Avoid redundant simplification] - -> do { (_, _, arg') <- simplArg env dup_flag se arg + -> do { (_, _, arg') <- simplArg env dup_flag fun_ty se arg ; rebuild env (App expr arg') cont } completeBindX :: SimplEnv @@ -1598,7 +1599,8 @@ 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_dup = dup, sc_cont = tail + , sc_hole_ty = fun_ty }) | Just (m_co1, m_co2) <- pushCoValArg co , fixed_rep m_co1 = {-#SCC "addCoerce-pushCoValArg" #-} @@ -1610,7 +1612,7 @@ simplCast env body co0 cont0 -- See Note [Avoiding exponential behaviour] MCo co1 -> - do { (dup', arg_se', arg') <- simplArg env dup arg_se arg + do { (dup', arg_se', arg') <- simplArg env dup fun_ty arg_se arg -- When we build the ApplyTo we can't mix the OutCoercion -- 'co' with the InExpr 'arg', so we simplify -- to make it all consistent. It's a bit messy. @@ -1636,14 +1638,16 @@ simplCast env body co0 cont0 -- See Note [Representation polymorphism invariants] in GHC.Core -- test: typecheck/should_run/EtaExpandLevPoly -simplArg :: SimplEnv -> DupFlag -> StaticEnv -> CoreExpr +simplArg :: SimplEnv -> DupFlag + -> OutType -- Type of the function applied to this arg + -> StaticEnv -> CoreExpr -- Expression with its static envt -> SimplM (DupFlag, StaticEnv, OutExpr) -simplArg env dup_flag arg_env arg +simplArg env dup_flag fun_ty arg_env arg | isSimplified dup_flag = return (dup_flag, arg_env, arg) | otherwise = do { let arg_env' = arg_env `setInScopeFromE` env - ; arg' <- simplExpr arg_env' arg + ; arg' <- simplExprC arg_env' arg (mkBoringStop (funArgTy fun_ty)) ; return (Simplified, zapSubstEnv arg_env', arg') } -- Return a StaticEnv that includes the in-scope set from 'env', -- because arg' may well mention those variables (#20639) @@ -2029,6 +2033,21 @@ zap the SubstEnv. This is VITAL. Consider We'll clone the inner \x, adding x->x' in the id_subst Then when we inline y, we must *not* replace x by x' in the inlined copy!! + +Note [Fast path for data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For applications of a data constructor worker, the full glory of +rebuildCall is a waste of effort; +* They never inline, obviously +* They have no rewrite rules +* They are not strict (see Note [Data-con worker strictness] + in GHC.Core.DataCon) +So it's fine to zoom straight to `rebuild` which just rebuilds the +call in a very straightforward way. + +Some programs have a /lot/ of data constructors in the source program +(compiler/perf/T9961 is an example), so this fast path can be very +valuable. -} simplVar :: SimplEnv -> InVar -> SimplM OutExpr @@ -2046,6 +2065,9 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont + | isDataConWorkId var -- See Note [Fast path for data constructors] + = rebuild env (Var var) cont + | otherwise = case substId env var of ContEx tvs cvs ids e -> simplExprF env' e cont -- Don't trimJoinCont; haven't already simplified e, @@ -2315,6 +2337,8 @@ field of the ArgInfo record is the state of a little state-machine: If we inline `f` before simplifying `BIG` well use preInlineUnconditionally, and we'll simplify BIG once, at x's occurrence, rather than twice. +* GHC.Core.Opt.Simplify.Utils. mkRewriteCall: if there are no rules, and no + unfolding, we can skip both TryRules and TryInlining, which saves work. Note [Avoid redundant simplification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3645,7 +3669,7 @@ mkDupableContWithDmds env dmds do { let (dmd:cont_dmds) = dmds -- Never fails ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 - ; (_, se', arg') <- simplArg env' dup se arg + ; (_, se', arg') <- simplArg env' dup hole_ty se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ; let all_floats = floats1 `addLetFloats` let_floats2 ; return ( all_floats ===================================== compiler/GHC/Core/Opt/Simplify/Monad.hs ===================================== @@ -27,8 +27,8 @@ import GHC.Types.Name ( mkSystemVarName ) import GHC.Types.Id ( Id, mkSysLocalOrCoVarM ) import GHC.Types.Id.Info ( IdDetails(..), vanillaIdInfo, setArityInfo ) import GHC.Core.Type ( Type, Mult ) -import GHC.Core ( RuleEnv(..) ) import GHC.Core.Opt.Stats +import GHC.Core.Rules import GHC.Core.Utils ( mkLamTypes ) import GHC.Types.Unique.Supply import GHC.Driver.Flags ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -53,7 +53,7 @@ import GHC.Core.Ppr import GHC.Core.TyCo.Ppr ( pprParendType ) import GHC.Core.FVs import GHC.Core.Utils -import GHC.Core.Rules( getRules ) +import GHC.Core.Rules( RuleEnv, getRules ) import GHC.Core.Opt.Arity import GHC.Core.Unfold import GHC.Core.Unfold.Make @@ -425,12 +425,22 @@ decArgCount :: RewriteCall -> RewriteCall decArgCount (TryRules n rules) = TryRules (n-1) rules decArgCount rew = rew -mkTryRules :: [CoreRule] -> RewriteCall +mkRewriteCall :: Id -> RuleEnv -> RewriteCall -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration -mkTryRules [] = TryInlining -mkTryRules rs = TryRules n_required rs +-- We try to skip any unnecessary stages: +-- No rules => skip TryRules +-- No unfolding => skip TryInlining +-- This skipping is "just" for efficiency. But rebuildCall is +-- quite a heavy hammer, so skipping stages is a good plan. +-- And it's extremely simple to do. +mkRewriteCall fun rule_env + | not (null rules) = TryRules n_required rules + | canUnfold unf = TryInlining + | otherwise = TryNothing where - n_required = maximum (map ruleArity rs) + n_required = maximum (map ruleArity rules) + rules = getRules rule_env fun + unf = idUnfolding fun {- ************************************************************************ @@ -604,21 +614,23 @@ mkArgInfo :: SimplEnv -> RuleEnv -> Id -> SimplCont -> ArgInfo mkArgInfo env rule_base fun cont | n_val_args < idArity fun -- Note [Unsaturated functions] = ArgInfo { ai_fun = fun, ai_args = [] - , ai_rewrite = fun_rules + , ai_rewrite = fun_rewrite , ai_encl = False , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise = ArgInfo { ai_fun = fun , ai_args = [] - , ai_rewrite = fun_rules - , ai_encl = notNull rules || contHasRules cont + , ai_rewrite = fun_rewrite + , ai_encl = fun_has_rules || contHasRules cont , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where - rules = getRules rule_base fun - fun_rules = mkTryRules rules - n_val_args = countValArgs cont + n_val_args = countValArgs cont + fun_rewrite = mkRewriteCall fun rule_base + fun_has_rules = case fun_rewrite of + TryRules {} -> True + _ -> False vanilla_discounts, arg_discounts :: [Int] vanilla_discounts = repeat 0 ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -17,6 +17,7 @@ import GHC.Driver.Config.Core.Rules ( initRuleOpts ) import GHC.Core.Type hiding( substTy, substCo, extendTvSubst, zapSubst ) import GHC.Core.Multiplicity +import GHC.Core.SimpleOpt( defaultSimpleOpts, simpleOptExprWith ) import GHC.Core.Predicate import GHC.Core.Coercion( Coercion ) import GHC.Core.Opt.Monad @@ -636,9 +637,11 @@ Hence, the invariant is this: -- | Specialise calls to type-class overloaded functions occurring in a program. specProgram :: ModGuts -> CoreM ModGuts specProgram guts@(ModGuts { mg_module = this_mod - , mg_rules = local_rules - , mg_binds = binds }) - = do { dflags <- getDynFlags + , mg_rules = local_rules + , mg_binds = binds }) + = do { dflags <- getDynFlags + ; rule_env <- initRuleEnv guts + -- See Note [Fire rules in the specialiser] -- We need to start with a Subst that knows all the things -- that are in scope, so that the substitution engine doesn't @@ -650,6 +653,7 @@ specProgram guts@(ModGuts { mg_module = this_mod -- mkInScopeSetList $ -- bindersOfBinds binds , se_module = this_mod + , se_rules = rule_env , se_dflags = dflags } go [] = return ([], emptyUDs) @@ -660,7 +664,7 @@ specProgram guts@(ModGuts { mg_module = this_mod -- Specialise the bindings of this module ; (binds', uds) <- runSpecM (go binds) - ; (spec_rules, spec_binds) <- specImports top_env local_rules uds + ; (spec_rules, spec_binds) <- specImports top_env uds ; return (guts { mg_binds = spec_binds ++ binds' , mg_rules = spec_rules ++ local_rules }) } @@ -725,21 +729,15 @@ specialisation (see canSpecImport): -} specImports :: SpecEnv - -> [CoreRule] -> UsageDetails -> CoreM ([CoreRule], [CoreBind]) -specImports top_env local_rules - (MkUD { ud_binds = dict_binds, ud_calls = calls }) +specImports top_env (MkUD { ud_binds = dict_binds, ud_calls = calls }) | not $ gopt Opt_CrossModuleSpecialise (se_dflags top_env) -- See Note [Disabling cross-module specialisation] = return ([], wrapDictBinds dict_binds []) | otherwise - = do { hpt_rules <- getRuleBase - ; let rule_base = extendRuleBaseList hpt_rules local_rules - - ; (spec_rules, spec_binds) <- spec_imports top_env [] rule_base - dict_binds calls + = do { (_env, spec_rules, spec_binds) <- spec_imports top_env [] dict_binds calls -- Don't forget to wrap the specialized bindings with -- bindings for the needed dictionaries. @@ -757,89 +755,91 @@ specImports top_env local_rules spec_imports :: SpecEnv -- Passed in so that all top-level Ids are in scope -> [Id] -- Stack of imported functions being specialised -- See Note [specImport call stack] - -> RuleBase -- Rules from this module and the home package - -- (but not external packages, which can change) -> FloatedDictBinds -- Dict bindings, used /only/ for filterCalls -- See Note [Avoiding loops in specImports] -> CallDetails -- Calls for imported things - -> CoreM ( [CoreRule] -- New rules + -> CoreM ( SpecEnv -- Env contains the new rules + , [CoreRule] -- New rules , [CoreBind] ) -- Specialised bindings -spec_imports top_env callers rule_base dict_binds calls +spec_imports env callers dict_binds calls = do { let import_calls = dVarEnvElts calls -- ; debugTraceMsg (text "specImports {" <+> -- vcat [ text "calls:" <+> ppr import_calls -- , text "dict_binds:" <+> ppr dict_binds ]) - ; (rules, spec_binds) <- go rule_base import_calls + ; (env, rules, spec_binds) <- go env import_calls -- ; debugTraceMsg (text "End specImports }" <+> ppr import_calls) - ; return (rules, spec_binds) } + ; return (env, rules, spec_binds) } where - go :: RuleBase -> [CallInfoSet] -> CoreM ([CoreRule], [CoreBind]) - go _ [] = return ([], []) - go rb (cis : other_calls) + go :: SpecEnv -> [CallInfoSet] -> CoreM (SpecEnv, [CoreRule], [CoreBind]) + go env [] = return (env, [], []) + go env (cis : other_calls) = do { -- debugTraceMsg (text "specImport {" <+> ppr cis) - ; (rules1, spec_binds1) <- spec_import top_env callers rb dict_binds cis + ; (env, rules1, spec_binds1) <- spec_import env callers dict_binds cis ; -- debugTraceMsg (text "specImport }" <+> ppr cis) - ; (rules2, spec_binds2) <- go (extendRuleBaseList rb rules1) other_calls - ; return (rules1 ++ rules2, spec_binds1 ++ spec_binds2) } + ; (env, rules2, spec_binds2) <- go env other_calls + ; return (env, rules1 ++ rules2, spec_binds1 ++ spec_binds2) } spec_import :: SpecEnv -- Passed in so that all top-level Ids are in scope -> [Id] -- Stack of imported functions being specialised -- See Note [specImport call stack] - -> RuleBase -- Rules from this module -> FloatedDictBinds -- Dict bindings, used /only/ for filterCalls -- See Note [Avoiding loops in specImports] -> CallInfoSet -- Imported function and calls for it - -> CoreM ( [CoreRule] -- New rules + -> CoreM ( SpecEnv + , [CoreRule] -- New rules , [CoreBind] ) -- Specialised bindings -spec_import top_env callers rb dict_binds cis@(CIS fn _) +spec_import env callers dict_binds cis@(CIS fn _) | isIn "specImport" fn callers - = return ([], []) -- No warning. This actually happens all the time - -- when specialising a recursive function, because - -- the RHS of the specialised function contains a recursive - -- call to the original function + = return (env, [], []) -- No warning. This actually happens all the time + -- when specialising a recursive function, because + -- the RHS of the specialised function contains a recursive + -- call to the original function | null good_calls - = return ([], []) + = return (env, [], []) | Just rhs <- canSpecImport dflags fn = do { -- Get rules from the external package state -- We keep doing this in case we "page-fault in" -- more rules as we go along - ; external_rule_base <- getExternalRuleBase - ; vis_orphs <- getVisibleOrphanMods - ; let rules_for_fn = getRules (RuleEnv [rb, external_rule_base] vis_orphs) fn + ; eps_rules <- getExternalRuleBase + ; let rule_env = se_rules env `updExternalPackageRules` eps_rules - ; -- debugTraceMsg (text "specImport1" <+> vcat [ppr fn, ppr good_calls, ppr rhs]) +-- ; debugTraceMsg (text "specImport1" <+> vcat [ppr fn, ppr good_calls +-- , ppr (getRules rule_env fn), ppr rhs]) ; (rules1, spec_pairs, MkUD { ud_binds = dict_binds1, ud_calls = new_calls }) - <- runSpecM $ specCalls True top_env dict_binds - rules_for_fn good_calls fn rhs + <- runSpecM $ specCalls True env dict_binds + (getRules rule_env fn) good_calls fn rhs ; let spec_binds1 = [NonRec b r | (b,r) <- spec_pairs] -- After the rules kick in we may get recursion, but -- we rely on a global GlomBinds to sort that out later -- See Note [Glom the bindings if imported functions are specialised] + new_subst = se_subst env `Core.extendSubstInScopeList` map fst spec_pairs + new_env = env { se_rules = rule_env `addLocalRules` rules1 + , se_subst = new_subst } + -- Now specialise any cascaded calls - ; -- debugTraceMsg (text "specImport 2" <+> (ppr fn $$ ppr rules1 $$ ppr spec_binds1)) - ; (rules2, spec_binds2) <- spec_imports top_env - (fn:callers) - (extendRuleBaseList rb rules1) - (dict_binds `thenFDBs` dict_binds1) - new_calls +-- ; debugTraceMsg (text "specImport 2" <+> (ppr fn $$ ppr rules1 $$ ppr spec_binds1)) + ; (env, rules2, spec_binds2) + <- spec_imports new_env (fn:callers) + (dict_binds `thenFDBs` dict_binds1) + new_calls ; let final_binds = wrapDictBinds dict_binds1 $ spec_binds2 ++ spec_binds1 - ; return (rules2 ++ rules1, final_binds) } + ; return (env, rules2 ++ rules1, final_binds) } | otherwise = do { tryWarnMissingSpecs dflags callers fn good_calls - ; return ([], [])} + ; return (env, [], [])} where - dflags = se_dflags top_env + dflags = se_dflags env good_calls = filterCalls cis dict_binds -- SUPER IMPORTANT! Drop calls that (directly or indirectly) refer to fn -- See Note [Avoiding loops in specImports] @@ -1134,6 +1134,7 @@ data SpecEnv -- the RHS of specialised bindings (no type-let!) , se_module :: Module + , se_rules :: RuleEnv -- From the home package and this module , se_dflags :: DynFlags } @@ -1172,8 +1173,8 @@ specExpr env expr@(App {}) ; (args_out, uds_args) <- mapAndCombineSM (specExpr env) args_in ; let env_args = env `bringFloatedDictsIntoScope` ud_binds uds_args -- Some dicts may have floated out of args_in; - -- they should be in scope for rewriteClassOps (#21689) - (fun_in', args_out') = rewriteClassOps env_args fun_in args_out + -- they should be in scope for fireRewriteRules (#21689) + (fun_in', args_out') = fireRewriteRules env_args fun_in args_out ; (fun_out', uds_fun) <- specExpr env fun_in' ; let uds_call = mkCallUDs env fun_out' args_out' ; return (fun_out' `mkApps` args_out', uds_fun `thenUDs` uds_call `thenUDs` uds_args) } @@ -1208,17 +1209,19 @@ specExpr env (Let bind body) ; return (foldr Let body' binds', uds) } -- See Note [Specialisation modulo dictionary selectors] --- and Note [ClassOp/DFun selection] -rewriteClassOps :: SpecEnv -> InExpr -> [OutExpr] -> (InExpr, [OutExpr]) -rewriteClassOps env (Var f) args - | isClassOpId f -- If we see `op_sel $fCInt`, we rewrite to `$copInt` - , Just (rule, expr) <- -- pprTrace "rewriteClassOps" (ppr f $$ ppr args $$ ppr (se_subst env)) $ - specLookupRule env f args (idCoreRules f) - , let rest_args = drop (ruleArity rule) args -- See Note [Extra args in the target] --- , pprTrace "class op rewritten" (ppr f <+> ppr args $$ ppr expr <+> ppr rest_args) True - , (fun, args) <- collectArgs expr - = rewriteClassOps env fun (args++rest_args) -rewriteClassOps _ fun args = (fun, args) +-- Note [ClassOp/DFun selection] +-- Note [Fire rules in the specialiser] +fireRewriteRules :: SpecEnv -> InExpr -> [OutExpr] -> (InExpr, [OutExpr]) +fireRewriteRules env (Var f) args + | Just (rule, expr) <- specLookupRule env f args InitialPhase (getRules (se_rules env) f) + , let rest_args = drop (ruleArity rule) args -- See Note [Extra args in the target] + zapped_subst = Core.zapSubst (se_subst env) + expr' = simpleOptExprWith defaultSimpleOpts zapped_subst expr + -- simplOptExpr needed because lookupRule returns + -- (\x y. rhs) arg1 arg2 + , (fun, args) <- collectArgs expr' + = fireRewriteRules env fun (args++rest_args) +fireRewriteRules _ fun args = (fun, args) -------------- specLam :: SpecEnv -> [OutBndr] -> InExpr -> SpecM (OutExpr, UsageDetails) @@ -1324,7 +1327,67 @@ specCase env scrut case_bndr alts where (env_rhs, args') = substBndrs env_alt args -{- +{- Note [Fire rules in the specialiser] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this (#21851) + + module A where + f :: Num b => b -> (b, b) + f x = (x + 1, snd (f x)) + {-# SPECIALIZE f :: Int -> (Int, Int) #-} + + module B (g') where + import A + + g :: Num a => a -> a + g x = fst (f x) + {-# NOINLINE[99] g #-} + + h :: Int -> Int + h = g + +Note that `f` has the CPR property, and so will worker/wrapper. + +The call to `g` in `h` will make us specialise `g @Int`. And the specialised +version of `g` will contain the call `f @Int`; but in the subsequent run of +the Simplifier, there will be a competition between: +* The user-supplied SPECIALISE rule for `f` +* The inlining of the wrapper for `f` +In fact, the latter wins -- see Note [Rewrite rules and inlining] in +GHC.Core.Opt.Simplify.Iteration. However, it a bit fragile. + +Moreover consider (test T21851_2): + + module A + f :: (Ord a, Show b) => a -> b -> blah + {-# RULE forall b. f @Int @b = wombat #-} + + wombat :: Show b => Int -> b -> blah + wombat = blah + + module B + import A + g :: forall a. Ord a => blah + g @a = ...g...f @a @Char.... + + h = ....g @Int.... + +Now, in module B, GHC will specialise `g @Int`, which will lead to a +call `f @Int @Char`. If we immediately (in the specialiser) rewrite +that to `womabat @Char`, we have a chance to specialise `wombat`. + +Conclusion: it's treat if the Specialiser fires RULEs itself. +It's not hard to achieve: see `fireRewriteRules`. The only tricky bit is +making sure that we have a reasonably up to date EPS rule base. Currently +we load it up just once, in `initRuleEnv`, called at the beginning of +`specProgram`. + +NB: you might wonder if running rules in the specialiser (this Note) +renders Note [Rewrite rules and inlining] in the Simplifier redundant. +That is, if we run rules in the specialiser, does it matter if we make +rules "win" over inlining in the Simplifier? Yes, it does! See the +discussion in #21851. + Note [Floating dictionaries out of cases] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -1415,13 +1478,12 @@ specBind top_lvl env (NonRec fn rhs) do_body final_binds :: [DictBind] -- See Note [From non-recursive to recursive] - final_binds - | not (isNilOL dump_dbs) - , not (null spec_defns) - = [recWithDumpedDicts pairs dump_dbs] - | otherwise - = [mkDB $ NonRec b r | (b,r) <- pairs] - ++ fromOL dump_dbs + final_binds | not (isNilOL dump_dbs) + , not (null spec_defns) + = [recWithDumpedDicts pairs dump_dbs] + | otherwise + = [mkDB $ NonRec b r | (b,r) <- pairs] + ++ fromOL dump_dbs ; if float_all then -- Rather than discard the calls mentioning the bound variables @@ -1553,8 +1615,10 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs foldlM spec_call ([], [], emptyUDs) calls_for_me | otherwise -- No calls or RHS doesn't fit our preconceptions - = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me) + = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me && not (isClassOpId fn)) "Missed specialisation opportunity for" (ppr fn $$ trace_doc) $ + -- isClassOpId: class-op Ids never inline; we specialise them + -- through fireRewriteRules. So don't complain about missed opportunities -- Note [Specialisation shape] -- pprTrace "specCalls: none" (ppr fn <+> ppr calls_for_me) $ return ([], [], emptyUDs) @@ -1581,9 +1645,13 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs already_covered :: SpecEnv -> [CoreRule] -> [CoreExpr] -> Bool already_covered env new_rules args -- Note [Specialisations already covered] - = isJust (specLookupRule env fn args (new_rules ++ existing_rules)) - -- NB: we look both in the new_rules (generated by this invocation - -- of specCalls), and in existing_rules (passed in to specCalls) + = isJust (specLookupRule env fn args (beginPhase inl_act) + (new_rules ++ existing_rules)) + -- Rules: we look both in the new_rules (generated by this invocation + -- of specCalls), and in existing_rules (passed in to specCalls) + -- inl_act: is the activation we are going to put in the new SPEC + -- rule; so we want to see if it is covered by another rule with + -- that same activation. ---------------------------------------------------------- -- Specialise to one particular call pattern @@ -1708,13 +1776,16 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs -- Convenience function for invoking lookupRule from Specialise -- The SpecEnv's InScopeSet should include all the Vars in the [CoreExpr] -specLookupRule :: SpecEnv -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr) -specLookupRule env fn args rules - = lookupRule ropts (in_scope, realIdUnfolding) (const True) fn args rules +specLookupRule :: SpecEnv -> Id -> [CoreExpr] + -> CompilerPhase -- Look up rules as if we were in this phase + -> [CoreRule] -> Maybe (CoreRule, CoreExpr) +specLookupRule env fn args phase rules + = lookupRule ropts (in_scope, realIdUnfolding) is_active fn args rules where - dflags = se_dflags env - in_scope = getSubstInScope (se_subst env) - ropts = initRuleOpts dflags + dflags = se_dflags env + in_scope = getSubstInScope (se_subst env) + ropts = initRuleOpts dflags + is_active = isActive phase {- Note [Specialising DFuns] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1913,10 +1984,10 @@ We want to specialise this! How? By doing the method-selection rewrite in the Specialiser. Hence 1. In the App case of 'specExpr', try to apply the ClassOp/DFun rule on the - head of the application, repeatedly, via 'rewriteClassOps'. + head of the application, repeatedly, via 'fireRewriteRules'. 2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and `$dShow` in `bindAuxiliaryDict`, so that we can exploit the unfolding - in 'rewriteClassOps' to do the ClassOp/DFun rewrite. + in 'fireRewriteRules' to do the ClassOp/DFun rewrite. NB: Without (2), (1) would be pointless, because 'lookupRule' wouldn't be able to look into the RHS of `$dC` to see the DFun. ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , isGoodWorker, badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,23 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True - -isGoodWorker :: Bool -> Bool -isGoodWorker = id +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -826,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -843,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -855,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -875,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -887,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -895,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -910,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts - -> Var-> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> Var -> DataConPatContext Demand + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -939,13 +940,14 @@ unbox_one_arg opts arg_var -- See Note [Call-by-value for worker args] all_str_marks = (map (const NotMarkedStrict) ex_tvs') ++ con_str_marks - ; (_sub_args_quality, worker_args, wrap_fn, wrap_args) + ; (nested_useful, worker_args, wrap_fn, wrap_args) <- mkWWstr opts (ex_tvs' ++ arg_ids') all_str_marks ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co - - ; return (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } - -- Don't pass the arg, rebox instead + -- See Note [Unboxing through unboxed tuples] + ; return $ if isUnboxedTupleDataCon dc && not nested_useful + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1195,6 +1197,26 @@ fragile because `MkT` is strict in its Int# argument, so we get an absentError exception when we shouldn't. Very annoying! +Note [Unboxing through unboxed tuples] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We should not to a worker/wrapper split just for unboxing the components of +an unboxed tuple (in the result *or* argument, #22388). Consider + boring_res x y = (# y, x #) +It's entirely pointless to split for the constructed unboxed pair to + $wboring_res x y = (# y, x #) + boring_res = case $wboring_res x y of (# a, b #) -> (# a, b #) +`boring_res` will immediately simplify to an alias for `$wboring_res`! + +Similarly, the unboxed tuple might occur in argument position + boring_arg (# x, y, z #) = (# z, x, y #) +It's entirely pointless to "unbox" the triple + $wboring_arg x y z = (# z, x, y #) + boring_arg (# x, y, z #) = $wboring_arg x y z +because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. + +Conclusion: Only consider unboxing an unboxed tuple useful when we will +also unbox its components. That is governed by the `usefulSplit` mechanism. + ************************************************************************ * * Type scrutiny that is specific to demand analysis @@ -1376,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1398,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1411,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1441,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1467,11 +1489,10 @@ unbox_one_result opts res_bndr -- this_work_unbox_res alt = (case res_bndr |> co of C a b -> [a,b]) this_work_unbox_res = mkUnpackCase (Var res_bndr) co cprCaseBndrMult dc arg_ids - -- Don't try to WW an unboxed tuple return type when there's nothing inside - -- to unbox further. + -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -9,11 +9,13 @@ -- The 'CoreRule' datatype itself is declared elsewhere. module GHC.Core.Rules ( -- ** Looking up rules - lookupRule, + RuleEnv, lookupRule, -- ** RuleBase, RuleEnv + RuleBase, RuleEnv(..), mkRuleEnv, emptyRuleEnv, + updExternalPackageRules, addLocalRules, updLocalRules, emptyRuleBase, mkRuleBase, extendRuleBaseList, - pprRuleBase, extendRuleEnv, + pprRuleBase, -- ** Checking rule applications ruleCheckProgram, @@ -22,6 +24,8 @@ module GHC.Core.Rules ( extendRuleInfo, addRuleInfo, addIdSpecialisations, + -- ** RuleBase and RuleEnv + -- * Misc. CoreRule helpers rulesOfBinds, getRules, pprRulesForUser, @@ -34,6 +38,8 @@ import GHC.Prelude import GHC.Unit.Module ( Module ) import GHC.Unit.Module.Env +import GHC.Unit.Module.ModGuts( ModGuts(..) ) +import GHC.Unit.Module.Deps( Dependencies(..) ) import GHC.Driver.Session( DynFlags ) import GHC.Driver.Ppr( showSDoc ) @@ -135,7 +141,7 @@ Note [Overall plumbing for rules] * At the moment (c) is carried in a reader-monad way by the GHC.Core.Opt.Monad. The HomePackageTable doesn't have a single RuleBase because technically we should only be able to "see" rules "below" this module; so we - generate a RuleBase for (c) by combing rules from all the modules + generate a RuleBase for (c) by combining rules from all the modules "below" us. That's why we can't just select the home-package RuleBase from HscEnv. @@ -339,12 +345,106 @@ addIdSpecialisations id rules rulesOfBinds :: [CoreBind] -> [CoreRule] rulesOfBinds binds = concatMap (concatMap idCoreRules . bindersOf) binds + +{- +************************************************************************ +* * + RuleBase +* * +************************************************************************ +-} + +-- | Gathers a collection of 'CoreRule's. Maps (the name of) an 'Id' to its rules +type RuleBase = NameEnv [CoreRule] + -- The rules are unordered; + -- we sort out any overlaps on lookup + +emptyRuleBase :: RuleBase +emptyRuleBase = emptyNameEnv + +mkRuleBase :: [CoreRule] -> RuleBase +mkRuleBase rules = extendRuleBaseList emptyRuleBase rules + +extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase +extendRuleBaseList rule_base new_guys + = foldl' extendRuleBase rule_base new_guys + +extendRuleBase :: RuleBase -> CoreRule -> RuleBase +extendRuleBase rule_base rule + = extendNameEnv_Acc (:) Utils.singleton rule_base (ruleIdName rule) rule + +pprRuleBase :: RuleBase -> SDoc +pprRuleBase rules = pprUFM rules $ \rss -> + vcat [ pprRules (tidyRules emptyTidyEnv rs) + | rs <- rss ] + +-- | A full rule environment which we can apply rules from. Like a 'RuleBase', +-- but it also includes the set of visible orphans we use to filter out orphan +-- rules which are not visible (even though we can see them...) +-- See Note [Orphans] in GHC.Core +data RuleEnv + = RuleEnv { re_local_rules :: !RuleBase -- Rules from this module + , re_home_rules :: !RuleBase -- Rule from the home package + -- (excl this module) + , re_eps_rules :: !RuleBase -- Rules from other packages + -- see Note [External package rules] + , re_visible_orphs :: !ModuleSet + } + +mkRuleEnv :: ModGuts -> RuleBase -> RuleBase -> RuleEnv +mkRuleEnv (ModGuts { mg_module = this_mod + , mg_deps = deps + , mg_rules = local_rules }) + eps_rules hpt_rules + = RuleEnv { re_local_rules = mkRuleBase local_rules + , re_home_rules = hpt_rules + , re_eps_rules = eps_rules + , re_visible_orphs = mkModuleSet vis_orphs } + where + vis_orphs = this_mod : dep_orphs deps + +updExternalPackageRules :: RuleEnv -> RuleBase -> RuleEnv +-- Completely over-ride the external rules in RuleEnv +updExternalPackageRules rule_env eps_rules + = rule_env { re_eps_rules = eps_rules } + +updLocalRules :: RuleEnv -> [CoreRule] -> RuleEnv +-- Completely over-ride the local rules in RuleEnv +updLocalRules rule_env local_rules + = rule_env { re_local_rules = mkRuleBase local_rules } + +addLocalRules :: RuleEnv -> [CoreRule] -> RuleEnv +-- Add new local rules +addLocalRules rule_env rules + = rule_env { re_local_rules = extendRuleBaseList (re_local_rules rule_env) rules } + +emptyRuleEnv :: RuleEnv +emptyRuleEnv = RuleEnv { re_local_rules = emptyNameEnv + , re_home_rules = emptyNameEnv + , re_eps_rules = emptyNameEnv + , re_visible_orphs = emptyModuleSet } + getRules :: RuleEnv -> Id -> [CoreRule] +-- Given a RuleEnv and an Id, find the visible rules for that Id -- See Note [Where rules are found] -getRules (RuleEnv { re_base = rule_base, re_visible_orphs = orphs }) fn - = idCoreRules fn ++ concatMap imp_rules rule_base +getRules (RuleEnv { re_local_rules = local_rules + , re_home_rules = home_rules + , re_eps_rules = eps_rules + , re_visible_orphs = orphs }) fn + + | Just {} <- isDataConId_maybe fn -- Short cut for data constructor workers + = [] -- and wrappers, which never have any rules + + | otherwise + = idCoreRules fn ++ + get local_rules ++ + find_visible home_rules ++ + find_visible eps_rules + where - imp_rules rb = filter (ruleIsVisible orphs) (lookupNameEnv rb (idName fn) `orElse` []) + fn_name = idName fn + find_visible rb = filter (ruleIsVisible orphs) (get rb) + get rb = lookupNameEnv rb fn_name `orElse` [] ruleIsVisible :: ModuleSet -> CoreRule -> Bool ruleIsVisible _ BuiltinRule{} = True @@ -370,37 +470,28 @@ but that isn't quite right: in the module defining the Id (when it's a LocalId), but the rules are kept in the global RuleBase + Note [External package rules] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In Note [Overall plumbing for rules], it is explained that the final +RuleBase which we must consider is combined from 4 different sources. -************************************************************************ -* * - RuleBase -* * -************************************************************************ --} - --- RuleBase itself is defined in GHC.Core, along with CoreRule - -emptyRuleBase :: RuleBase -emptyRuleBase = emptyNameEnv - -mkRuleBase :: [CoreRule] -> RuleBase -mkRuleBase rules = extendRuleBaseList emptyRuleBase rules +During simplifier runs, the fourth source of rules is constantly being updated +as new interfaces are loaded into the EPS. Therefore just before we check to see +if any rules match we get the EPS RuleBase and combine it with the existing RuleBase +and then perform exactly 1 lookup into the new map. -extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase -extendRuleBaseList rule_base new_guys - = foldl' extendRuleBase rule_base new_guys +It is more efficient to avoid combining the environments and store the uncombined +environments as we can instead perform 1 lookup into each environment and then combine +the results. -extendRuleBase :: RuleBase -> CoreRule -> RuleBase -extendRuleBase rule_base rule - = extendNameEnv_Acc (:) Utils.singleton rule_base (ruleIdName rule) rule +Essentially we use the identity: -extendRuleEnv :: RuleEnv -> RuleBase -> RuleEnv -extendRuleEnv (RuleEnv rules orphs) rb = (RuleEnv (rb:rules) orphs) +> lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) +> = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 -pprRuleBase :: RuleBase -> SDoc -pprRuleBase rules = pprUFM rules $ \rss -> - vcat [ pprRules (tidyRules emptyTidyEnv rs) - | rs <- rss ] +The latter being more efficient as we don't construct an intermediate +map. +-} {- ************************************************************************ @@ -1575,7 +1666,7 @@ ruleCheckFun env fn args | otherwise = unitBag (ruleAppCheck_help env fn args name_match_rules) where name_match_rules = filter match (rc_rules env fn) - match rule = (rc_pattern env) `isPrefixOf` unpackFS (ruleName rule) + match rule = rc_pattern env `isPrefixOf` unpackFS (ruleName rule) ruleAppCheck_help :: RuleCheckEnv -> Id -> [CoreExpr] -> [CoreRule] -> SDoc ruleAppCheck_help env fn args rules ===================================== compiler/GHC/Driver/Config/Core/Opt/Simplify.hs ===================================== @@ -6,7 +6,7 @@ module GHC.Driver.Config.Core.Opt.Simplify import GHC.Prelude -import GHC.Core ( RuleBase ) +import GHC.Core.Rules ( RuleBase ) import GHC.Core.Opt.Pipeline.Types ( CoreToDo(..) ) import GHC.Core.Opt.Simplify ( SimplifyExprOpts(..), SimplifyOpts(..) ) import GHC.Core.Opt.Simplify.Env ( FloatEnable(..), SimplMode(..) ) @@ -40,20 +40,19 @@ initSimplifyExprOpts dflags ic = SimplifyExprOpts } initSimplifyOpts :: DynFlags -> [Var] -> Int -> SimplMode -> RuleBase -> SimplifyOpts -initSimplifyOpts dflags extra_vars iterations mode rule_base = let +initSimplifyOpts dflags extra_vars iterations mode hpt_rule_base = let -- This is a particularly ugly construction, but we will get rid of it in !8341. opts = SimplifyOpts { so_dump_core_sizes = not $ gopt Opt_SuppressCoreSizes dflags - , so_iterations = iterations - , so_mode = mode + , so_iterations = iterations + , so_mode = mode , so_pass_result_cfg = if gopt Opt_DoCoreLinting dflags - then Just $ initLintPassResultConfig dflags extra_vars (CoreDoSimplify opts) - else Nothing - , so_rule_base = rule_base - , so_top_env_cfg = TopEnvConfig - { te_history_size = historySize dflags - , te_tick_factor = simplTickFactor dflags - } + then Just $ initLintPassResultConfig dflags extra_vars + (CoreDoSimplify opts) + else Nothing + , so_hpt_rules = hpt_rule_base + , so_top_env_cfg = TopEnvConfig { te_history_size = historySize dflags + , te_tick_factor = simplTickFactor dflags } } in opts ===================================== compiler/GHC/HsToCore/Errors/Ppr.hs ===================================== @@ -86,7 +86,7 @@ instance Diagnostic DsMessage where hang (text "Top-level" <+> text desc <+> text "aren't allowed:") 2 (ppr bind) DsUselessSpecialiseForClassMethodSelector poly_id -> mkSimpleDecorated $ - text "Ignoring useless SPECIALISE pragma for NOINLINE function:" <+> quotes (ppr poly_id) + text "Ignoring useless SPECIALISE pragma for class selector:" <+> quotes (ppr poly_id) DsUselessSpecialiseForNoInlineFunction poly_id -> mkSimpleDecorated $ text "Ignoring useless SPECIALISE pragma for NOINLINE function:" <+> quotes (ppr poly_id) ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -585,6 +585,7 @@ mkDataConWorkId wkr_name data_con `setInlinePragInfo` wkr_inline_prag `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated, -- even if arity = 0 + -- No strictness: see Note [Data-con worker strictness] in GHC.Core.DataCon wkr_inline_prag = defaultInlinePragma { inl_rule = ConLike } wkr_arity = dataConRepArity data_con ===================================== compiler/GHC/Unit/External.hs ===================================== @@ -21,11 +21,10 @@ import GHC.Prelude import GHC.Unit import GHC.Unit.Module.ModIface -import GHC.Core ( RuleBase ) import GHC.Core.FamInstEnv import GHC.Core.InstEnv ( InstEnv, emptyInstEnv ) import GHC.Core.Opt.ConstantFold -import GHC.Core.Rules (mkRuleBase) +import GHC.Core.Rules ( RuleBase, mkRuleBase) import GHC.Types.Annotations ( AnnEnv, emptyAnnEnv ) import GHC.Types.CompleteMatch ===================================== libraries/base/GHC/Ix.hs ===================================== @@ -140,12 +140,30 @@ Note [Out-of-bounds error messages] The default method for 'index' generates hoplelessIndexError, because Ix doesn't have Show as a superclass. For particular base types we can do better, so we override the default method for index. --} --- Abstract these errors from the relevant index functions so that --- the guts of the function will be small enough to inline. +Note [indexError] +~~~~~~~~~~~~~~~~~ +We abstract the guts of constructing an out-of-bounds error into `indexError`. +We give it a NOINLINE pragma, because we don't want to duplicate this +cold-path code. + +We give it a SPECIALISE pragma because we really want it to take +its arguments unboxed, to avoid reboxing code in the caller, and +perhaps even some reboxing code in the hot path of a caller. +See Note [Boxity for bottoming functions] in GHC.Core.Opt.DmdAnal. + +The SPECIALISE pragma means that at least the Int-indexed case +of indexError /will/ unbox its arguments. +The [2] phase is because if we don't give an activation we'll get +the one from the inline pragama (i.e. never) which is a bit silly. +See Note [Activation pragmas for SPECIALISE] in GHC.HsToCore.Binds. +-} + +-- indexError: see Note [indexError] {-# NOINLINE indexError #-} +{-# SPECIALISE [2] indexError :: (Int,Int) -> Int -> String -> b #-} + indexError :: Show a => (a,a) -> a -> String -> b indexError rng i tp = errorWithoutStackTrace (showString "Ix{" . showString tp . showString "}.index: Index " . ===================================== libraries/base/GHC/Real.hs ===================================== @@ -701,11 +701,14 @@ half of y - 1 can be computed as y `quot` 2, optimising subtraction away. Note [Inlining (^) ~~~~~~~~~~~~~~~~~~ -The INLINABLE pragma allows (^) to be specialised at its call sites. +The INLINABLE [1] pragma allows (^) to be specialised at its call sites. If it is called repeatedly at the same type, that can make a huge difference, because of those constants which can be repeatedly calculated. +We don't inline until phase 1, to give a chance for the RULES +"^2/Int" etc to fire first. + Currently the fromInteger calls are not floated because we get \d1 d2 x y -> blah after the gentle round of simplification. ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -15,5 +15,3 @@ g' :: Int -> Int g' = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } - - ===================================== testsuite/tests/simplCore/should_compile/T21851_2.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS_GHC -ddump-simpl -dsuppress-uniques -dno-typeable-binds #-} + +module T21851_2 where + +import T21851_2a + +g :: forall a. (Ord a, Num a) => a -> (a,String) +g n | n < 10 = (0, f n True) + | otherwise = g (n-2) +-- The specialised version of g leads to a specialised +-- call to (f @Int @Bool). Then we want to fire f's RULE +-- and specialise 'wombat' + +h = g (3::Int) + ===================================== testsuite/tests/simplCore/should_compile/T21851_2.stderr ===================================== @@ -0,0 +1,120 @@ +[1 of 2] Compiling T21851_2a ( T21851_2a.hs, T21851_2a.o ) +[2 of 2] Compiling T21851_2 ( T21851_2.hs, T21851_2.o ) + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 107, types: 96, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl :: Integer +[GblId, Unf=OtherCon []] +lvl = GHC.Num.Integer.IS 2# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl1 :: Integer +[GblId, Unf=OtherCon []] +lvl1 = GHC.Num.Integer.IS 0# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl2 :: Integer +[GblId, Unf=OtherCon []] +lvl2 = GHC.Num.Integer.IS 10# + +Rec { +-- RHS size: {terms: 25, types: 5, coercions: 0, joins: 0/0} +T21851_2.$s$wwombat [InlPrag=[~], Occ=LoopBreaker] + :: GHC.Prim.Int# -> Bool -> [Char] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +T21851_2.$s$wwombat + = \ (ww :: GHC.Prim.Int#) (y :: Bool) -> + case ww of ds { + __DEFAULT -> + case y of { + False -> + GHC.CString.unpackAppendCString# + GHC.Show.$fShowBool3 + (T21851_2.$s$wwombat (GHC.Prim.-# ds 1#) GHC.Types.False); + True -> + GHC.CString.unpackAppendCString# + GHC.Show.$fShowBool2 + (T21851_2.$s$wwombat (GHC.Prim.-# ds 1#) GHC.Types.True) + }; + 0# -> GHC.Types.[] @Char + } +end Rec } + +Rec { +-- RHS size: {terms: 16, types: 6, coercions: 0, joins: 0/0} +T21851_2.$w$sg [InlPrag=[2], Occ=LoopBreaker] + :: GHC.Prim.Int# -> (# GHC.Prim.Int#, String #) +[GblId, Arity=1, Str=, Unf=OtherCon []] +T21851_2.$w$sg + = \ (ww :: GHC.Prim.Int#) -> + case GHC.Prim.<# ww 10# of { + __DEFAULT -> T21851_2.$w$sg (GHC.Prim.-# ww 2#); + 1# -> (# 0#, T21851_2.$s$wwombat ww GHC.Types.True #) + } +end Rec } + +-- RHS size: {terms: 3, types: 3, coercions: 0, joins: 0/0} +lvl3 :: forall {a}. [Char] +[GblId] +lvl3 = \ (@a) -> T21851_2a.$wf GHC.Prim.(##) @a @Bool + +Rec { +-- RHS size: {terms: 27, types: 18, coercions: 0, joins: 0/0} +T21851_2.$wg [InlPrag=[2], Occ=LoopBreaker] + :: forall {a}. (Ord a, Num a) => a -> (# a, String #) +[GblId[StrictWorker([!])], + Arity=3, + Str=, + Unf=OtherCon []] +T21851_2.$wg + = \ (@a) ($dOrd :: Ord a) ($dNum :: Num a) (n :: a) -> + case < @a $dOrd n (fromInteger @a $dNum lvl2) of { + False -> + T21851_2.$wg + @a $dOrd $dNum (- @a $dNum n (fromInteger @a $dNum lvl)); + True -> (# fromInteger @a $dNum lvl1, lvl3 @a #) + } +end Rec } + +-- RHS size: {terms: 13, types: 16, coercions: 0, joins: 0/0} +g [InlPrag=[2]] :: forall a. (Ord a, Num a) => a -> (a, String) +[GblId, + Arity=3, + Str=, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) + Tmpl= \ (@a) + ($dOrd [Occ=Once1] :: Ord a) + ($dNum [Occ=Once1] :: Num a) + (n [Occ=Once1] :: a) -> + case T21851_2.$wg @a $dOrd $dNum n of + { (# ww [Occ=Once1], ww1 [Occ=Once1] #) -> + (ww, ww1) + }}] +g = \ (@a) ($dOrd :: Ord a) ($dNum :: Num a) (n :: a) -> + case T21851_2.$wg @a $dOrd $dNum n of { (# ww, ww1 #) -> + (ww, ww1) + } + +-- RHS size: {terms: 8, types: 9, coercions: 0, joins: 0/0} +h :: (Int, String) +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, + WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 50 10}] +h = case T21851_2.$w$sg 3# of { (# ww, ww1 #) -> + (GHC.Types.I# ww, ww1) + } + + +------ Local rules for imported ids -------- +"SPEC/T21851_2 $wwombat @Bool" [2] + forall ($dShow :: Show Bool). + T21851_2a.$wwombat @Bool $dShow + = T21851_2.$s$wwombat + + ===================================== testsuite/tests/simplCore/should_compile/T21851_2a.hs ===================================== @@ -0,0 +1,11 @@ +module T21851_2a where + +f :: (Num a, Show b) => a -> b -> String +{-# NOINLINE f #-} +f x y = "no" +{-# RULES "wombat" f = wombat #-} + +wombat :: Show b => Int -> b -> String +{-# INLINEABLE wombat #-} +wombat 0 y = "" +wombat n y = show y ++ wombat (n-1) y ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -442,3 +442,7 @@ test('T22357', normal, compile, ['-O']) # Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) test('T17366', normal, multimod_compile, ['T17366', '-O -v0 -ddump-rule-firings']) test('T17366_AR', [grep_errmsg(r'SPEC')], multimod_compile, ['T17366_AR', '-O -v0 -ddump-rule-firings']) + +# One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl +# Expecting to see $s$wwombat +test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) ===================================== testsuite/tests/stranal/should_compile/T22388.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Unboxing through unboxed tuples] +module T22388 where + +-- Don't split, because neither the result not arg cancels away a box. +boring :: (# Int, Int, Int #) -> (# Int, Int, Int #) +boring (# x, y, z #) = (# y, z, x #) +{-# NOINLINE boring #-} + +-- Do split, because we get to drop z and pass x and y unboxed +interesting :: (# Int, Int, Int #) -> (# Int #) +interesting (# x, y, z #) = let !t = x + y in (# t #) +{-# NOINLINE interesting #-} ===================================== testsuite/tests/stranal/should_compile/T22388.stderr ===================================== @@ -0,0 +1,92 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 48, types: 81, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 8, types: 23, coercions: 0, joins: 0/0} +boring [InlPrag=NOINLINE] + :: (# Int, Int, Int #) -> (# Int, Int, Int #) +[GblId, Arity=1, Str=<1!P(L,L,L)>, Cpr=1, Unf=OtherCon []] +boring + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# x, y, z #) -> (# y, z, x #) } + +-- RHS size: {terms: 5, types: 2, coercions: 0, joins: 0/0} +T22388.$winteresting [InlPrag=NOINLINE] + :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=, Unf=OtherCon []] +T22388.$winteresting + = \ (ww :: GHC.Prim.Int#) (ww1 :: GHC.Prim.Int#) -> + GHC.Prim.+# ww ww1 + +-- RHS size: {terms: 18, types: 24, coercions: 0, joins: 0/0} +interesting [InlPrag=NOINLINE[final]] + :: (# Int, Int, Int #) -> (# Int #) +[GblId, + Arity=1, + Str=<1!P(1!P(L),1!P(L),A)>, + Cpr=1(1), + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (ds [Occ=Once1!] :: (# Int, Int, Int #)) -> + case ds of + { (# ww [Occ=Once1!], ww1 [Occ=Once1!], _ [Occ=Dead] #) -> + case ww of { GHC.Types.I# ww3 [Occ=Once1] -> + case ww1 of { GHC.Types.I# ww4 [Occ=Once1] -> + case T22388.$winteresting ww3 ww4 of ww5 [Occ=Once1] { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + }}] +interesting + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# ww, ww1, ww2 #) -> + case ww of { GHC.Types.I# ww3 -> + case ww1 of { GHC.Types.I# ww4 -> + case T22388.$winteresting ww3 ww4 of ww5 { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + } + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T22388.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule3 = GHC.Types.TrNameS T22388.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T22388.$trModule2 = "T22388"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule1 = GHC.Types.TrNameS T22388.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule + = GHC.Types.Module T22388.$trModule3 T22388.$trModule1 + + + ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -86,3 +86,5 @@ test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', ' test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) test('T22039', normal, compile, ['']) +# T22388: Should see $winteresting but not $wboring +test('T22388', [ grep_errmsg(r'^\S+\$w\S+') ], compile, ['-dsuppress-uniques -ddump-simpl']) ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,47 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} + +-- Point: Demand on `x` is lazy and thus Unboxed +app :: ((# Int, Int #) -> (# Int, Int #)) -> (# Int, Int #) -> (# Int, Int #) +app g x = g x ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.app: +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7027c04d6f373607bb15ce3ad403b14feb3302ab...34937a6f9c1452c8cf3d54938224ccec16c173f6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7027c04d6f373607bb15ce3ad403b14feb3302ab...34937a6f9c1452c8cf3d54938224ccec16c173f6 You're receiving 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 Nov 10 22:30:26 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Thu, 10 Nov 2022 17:30:26 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/accept-T18355 Message-ID: <636d7b82e608c_10da055ac8adc1017598@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/accept-T18355 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/accept-T18355 You're receiving 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 Nov 10 22:31:45 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Thu, 10 Nov 2022 17:31:45 -0500 Subject: [Git][ghc/ghc][wip/accept-T18355] Fix merge conflict in T18355.stderr Message-ID: <636d7bd134599_10da05526c01019685@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/accept-T18355 at Glasgow Haskell Compiler / GHC Commits: 08cb5234 by Krzysztof Gogolewski at 2022-11-10T23:31:32+01:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 1 changed file: - testsuite/tests/simplCore/should_compile/T18355.stderr Changes: ===================================== testsuite/tests/simplCore/should_compile/T18355.stderr ===================================== @@ -7,16 +7,8 @@ Result size of Tidy Core f :: forall {a}. Num a => a -> Bool -> a -> a [GblId, Arity=4, -<<<<<<< HEAD - Str=<1P(MC1(C1(L)),MC1(C1(L)),A,A,A,A,A)><1L>, + Str=<1P(MC(1,C(1,L)),MC(1,C(1,L)),A,A,A,A,A)><1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, -||||||| parent of 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, -======= - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, ->>>>>>> 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 0 70 0] 100 0}] f = \ (@a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08cb52348c762c5f4363d3ee9243160e8fc43c58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/08cb52348c762c5f4363d3ee9243160e8fc43c58 You're receiving 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 Nov 10 23:25:24 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 10 Nov 2022 18:25:24 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: WorkWrap: Unboxing unboxed tuples is not always useful (#22388) Message-ID: <636d88645292a_10da05526ac1030376@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6de295c3 by Sebastian Graf at 2022-11-10T18:25:14-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 5252c7f8 by Sebastian Graf at 2022-11-10T18:25:14-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 8 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/should_compile/T22388.hs - + testsuite/tests/stranal/should_compile/T22388.stderr - testsuite/tests/stranal/should_compile/all.T - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1765,7 +1766,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1774,10 +1775,91 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Recall that unboxed tuples will be flattened to individual arguments during +unarisation. Here, `unboxed` will have 5 arguments at runtime because of the +nested unboxed tuple, which will be flattened to 4 args. So it's best to leave +`(a,b)` boxed (because we already are above our arg threshold), but unbox `c` +through `f` because that doesn't increase the number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. For example at the top-level, `(# x,y #)` is to be +treated just like two arguments `x` and `y`. +Of course, for that to work, our budget calculations must initialise +'max_wkr_args' to 5, based on the 'unariseArity' of each Core arg: That would be +1 for the pair and 4 for the unboxed pair. Then when we decide whether to unbox +the unboxed pair, we *directly* recurse into the fields, spending our budget +on retaining `c` and (after recursing once more) `d` through `f` as arguments, +depleting our budget completely in the first layer. Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1798,10 +1880,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets + +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1814,7 +1903,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1826,8 +1916,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1871,22 +1963,49 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg + -- The unboxed case does happen here, for example + -- app g x = g x :: (# Int, Int #) + -- here, `x` is used `L`azy and thus Boxed + + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- We currently don't return DoUnbox for unboxed sums. + -- But hopefully we will at some point. When that happens, + -- it would still be impossible to predict the effect + -- of dropping absent fields and unboxing others on the + -- unariseArity of the sum without losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) + where + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) -- "~": This match *must* be lazy! | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) - where - decremented_bg = MkB (bg_top-1) bg_inner add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , isGoodWorker, badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,23 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True - -isGoodWorker :: Bool -> Bool -isGoodWorker = id +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -826,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -843,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -855,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -875,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -887,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -895,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -910,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts - -> Var-> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> Var -> DataConPatContext Demand + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -939,13 +940,14 @@ unbox_one_arg opts arg_var -- See Note [Call-by-value for worker args] all_str_marks = (map (const NotMarkedStrict) ex_tvs') ++ con_str_marks - ; (_sub_args_quality, worker_args, wrap_fn, wrap_args) + ; (nested_useful, worker_args, wrap_fn, wrap_args) <- mkWWstr opts (ex_tvs' ++ arg_ids') all_str_marks ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co - - ; return (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } - -- Don't pass the arg, rebox instead + -- See Note [Unboxing through unboxed tuples] + ; return $ if isUnboxedTupleDataCon dc && not nested_useful + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1195,6 +1197,26 @@ fragile because `MkT` is strict in its Int# argument, so we get an absentError exception when we shouldn't. Very annoying! +Note [Unboxing through unboxed tuples] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We should not to a worker/wrapper split just for unboxing the components of +an unboxed tuple (in the result *or* argument, #22388). Consider + boring_res x y = (# y, x #) +It's entirely pointless to split for the constructed unboxed pair to + $wboring_res x y = (# y, x #) + boring_res = case $wboring_res x y of (# a, b #) -> (# a, b #) +`boring_res` will immediately simplify to an alias for `$wboring_res`! + +Similarly, the unboxed tuple might occur in argument position + boring_arg (# x, y, z #) = (# z, x, y #) +It's entirely pointless to "unbox" the triple + $wboring_arg x y z = (# z, x, y #) + boring_arg (# x, y, z #) = $wboring_arg x y z +because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. + +Conclusion: Only consider unboxing an unboxed tuple useful when we will +also unbox its components. That is governed by the `usefulSplit` mechanism. + ************************************************************************ * * Type scrutiny that is specific to demand analysis @@ -1376,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1398,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1411,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1441,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1467,11 +1489,10 @@ unbox_one_result opts res_bndr -- this_work_unbox_res alt = (case res_bndr |> co of C a b -> [a,b]) this_work_unbox_res = mkUnpackCase (Var res_bndr) co cprCaseBndrMult dc arg_ids - -- Don't try to WW an unboxed tuple return type when there's nothing inside - -- to unbox further. + -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/should_compile/T22388.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Unboxing through unboxed tuples] +module T22388 where + +-- Don't split, because neither the result not arg cancels away a box. +boring :: (# Int, Int, Int #) -> (# Int, Int, Int #) +boring (# x, y, z #) = (# y, z, x #) +{-# NOINLINE boring #-} + +-- Do split, because we get to drop z and pass x and y unboxed +interesting :: (# Int, Int, Int #) -> (# Int #) +interesting (# x, y, z #) = let !t = x + y in (# t #) +{-# NOINLINE interesting #-} ===================================== testsuite/tests/stranal/should_compile/T22388.stderr ===================================== @@ -0,0 +1,92 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 48, types: 81, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 8, types: 23, coercions: 0, joins: 0/0} +boring [InlPrag=NOINLINE] + :: (# Int, Int, Int #) -> (# Int, Int, Int #) +[GblId, Arity=1, Str=<1!P(L,L,L)>, Cpr=1, Unf=OtherCon []] +boring + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# x, y, z #) -> (# y, z, x #) } + +-- RHS size: {terms: 5, types: 2, coercions: 0, joins: 0/0} +T22388.$winteresting [InlPrag=NOINLINE] + :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=, Unf=OtherCon []] +T22388.$winteresting + = \ (ww :: GHC.Prim.Int#) (ww1 :: GHC.Prim.Int#) -> + GHC.Prim.+# ww ww1 + +-- RHS size: {terms: 18, types: 24, coercions: 0, joins: 0/0} +interesting [InlPrag=NOINLINE[final]] + :: (# Int, Int, Int #) -> (# Int #) +[GblId, + Arity=1, + Str=<1!P(1!P(L),1!P(L),A)>, + Cpr=1(1), + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (ds [Occ=Once1!] :: (# Int, Int, Int #)) -> + case ds of + { (# ww [Occ=Once1!], ww1 [Occ=Once1!], _ [Occ=Dead] #) -> + case ww of { GHC.Types.I# ww3 [Occ=Once1] -> + case ww1 of { GHC.Types.I# ww4 [Occ=Once1] -> + case T22388.$winteresting ww3 ww4 of ww5 [Occ=Once1] { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + }}] +interesting + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# ww, ww1, ww2 #) -> + case ww of { GHC.Types.I# ww3 -> + case ww1 of { GHC.Types.I# ww4 -> + case T22388.$winteresting ww3 ww4 of ww5 { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + } + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T22388.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule3 = GHC.Types.TrNameS T22388.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T22388.$trModule2 = "T22388"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule1 = GHC.Types.TrNameS T22388.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule + = GHC.Types.Module T22388.$trModule3 T22388.$trModule1 + + + ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -86,3 +86,5 @@ test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', ' test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) test('T22039', normal, compile, ['']) +# T22388: Should see $winteresting but not $wboring +test('T22388', [ grep_errmsg(r'^\S+\$w\S+') ], compile, ['-dsuppress-uniques -ddump-simpl']) ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,47 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} + +-- Point: Demand on `x` is lazy and thus Unboxed +app :: ((# Int, Int #) -> (# Int, Int #)) -> (# Int, Int #) -> (# Int, Int #) +app g x = g x ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.app: +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34937a6f9c1452c8cf3d54938224ccec16c173f6...5252c7f8ad22433c9b10d11907772c582e40f227 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/34937a6f9c1452c8cf3d54938224ccec16c173f6...5252c7f8ad22433c9b10d11907772c582e40f227 You're receiving 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 Nov 11 02:15:51 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 10 Nov 2022 21:15:51 -0500 Subject: [Git][ghc/ghc][master] 3 commits: Fire RULES in the Specialiser Message-ID: <636db057799b9_10da054a1b79810652eb@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - 20 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/Unit/External.hs - libraries/base/GHC/Ix.hs - libraries/base/GHC/Real.hs - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T21851_2.hs - + testsuite/tests/simplCore/should_compile/T21851_2.stderr - + testsuite/tests/simplCore/should_compile/T21851_2a.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -85,9 +85,8 @@ module GHC.Core ( IsOrphan(..), isOrphan, notOrphan, chooseOrphanAnchor, -- * Core rule data types - CoreRule(..), RuleBase, - RuleName, RuleFun, IdUnfoldingFun, InScopeEnv, - RuleEnv(..), RuleOpts, mkRuleEnv, emptyRuleEnv, + CoreRule(..), + RuleName, RuleFun, IdUnfoldingFun, InScopeEnv, RuleOpts, -- ** Operations on 'CoreRule's ruleArity, ruleName, ruleIdName, ruleActivation, @@ -105,7 +104,6 @@ import GHC.Core.Coercion import GHC.Core.Rules.Config ( RuleOpts ) import GHC.Types.Name import GHC.Types.Name.Set -import GHC.Types.Name.Env( NameEnv ) import GHC.Types.Literal import GHC.Types.Tickish import GHC.Core.DataCon @@ -1062,6 +1060,12 @@ has two major consequences M. But it's painful, because it means we need to keep track of all the orphan modules below us. + * The "visible orphan modules" are all the orphan module in the transitive + closure of the imports of this module. + + * During instance lookup, we filter orphan instances depending on + whether or not the instance is in a visible orphan module. + * A non-orphan is not finger-printed separately. Instead, for fingerprinting purposes it is treated as part of the entity it mentions on the LHS. For example @@ -1076,12 +1080,20 @@ has two major consequences Orphan-hood is computed * For class instances: - when we make a ClsInst - (because it is needed during instance lookup) + when we make a ClsInst in GHC.Core.InstEnv.mkLocalInstance + (because it is needed during instance lookup) + See Note [When exactly is an instance decl an orphan?] + in GHC.Core.InstEnv + + * For rules + when we generate a CoreRule (GHC.Core.Rules.mkRule) + + * For family instances: + when we generate an IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst) + +Orphan-hood is persisted into interface files, in ClsInst, FamInst, +and CoreRules. - * For rules and family instances: - when we generate an IfaceRule (GHC.Iface.Make.coreRuleToIfaceRule) - or IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst) -} {- @@ -1096,49 +1108,6 @@ GHC.Core.FVs, GHC.Core.Subst, GHC.Core.Ppr, GHC.Core.Tidy also inspect the representation. -} --- | Gathers a collection of 'CoreRule's. Maps (the name of) an 'Id' to its rules -type RuleBase = NameEnv [CoreRule] - -- The rules are unordered; - -- we sort out any overlaps on lookup - --- | A full rule environment which we can apply rules from. Like a 'RuleBase', --- but it also includes the set of visible orphans we use to filter out orphan --- rules which are not visible (even though we can see them...) -data RuleEnv - = RuleEnv { re_base :: [RuleBase] -- See Note [Why re_base is a list] - , re_visible_orphs :: ModuleSet - } - -mkRuleEnv :: RuleBase -> [Module] -> RuleEnv -mkRuleEnv rules vis_orphs = RuleEnv [rules] (mkModuleSet vis_orphs) - -emptyRuleEnv :: RuleEnv -emptyRuleEnv = RuleEnv [] emptyModuleSet - -{- -Note [Why re_base is a list] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In Note [Overall plumbing for rules], it is explained that the final -RuleBase which we must consider is combined from 4 different sources. - -During simplifier runs, the fourth source of rules is constantly being updated -as new interfaces are loaded into the EPS. Therefore just before we check to see -if any rules match we get the EPS RuleBase and combine it with the existing RuleBase -and then perform exactly 1 lookup into the new map. - -It is more efficient to avoid combining the environments and store the uncombined -environments as we can instead perform 1 lookup into each environment and then combine -the results. - -Essentially we use the identity: - -> lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) -> = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 - -The latter being more efficient as we don't construct an intermediate -map. --} -- | A 'CoreRule' is: -- ===================================== compiler/GHC/Core/InstEnv.hs ===================================== @@ -323,7 +323,9 @@ mkImportedInstance cls_nm mb_tcs dfun_name dfun oflag orphan {- Note [When exactly is an instance decl an orphan?] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - (see GHC.Iface.Make.instanceToIfaceInst, which implements this) +(See GHC.Iface.Make.instanceToIfaceInst, which implements this.) +See Note [Orphans] in GHC.Core + Roughly speaking, an instance is an orphan if its head (after the =>) mentions nothing defined in this module. ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -1520,6 +1520,9 @@ $wtheresCrud = \ ww ww1 -> ... ``` This is currently a bug that we willingly accept and it's documented in #21128. + +See also Note [indexError] in base:GHC.Ix, which describes how we use +SPECIALISE to mitigate this problem for indexError. -} {- ********************************************************************* ===================================== compiler/GHC/Core/Opt/Monad.hs ===================================== @@ -19,10 +19,10 @@ module GHC.Core.Opt.Monad ( -- ** Reading from the monad getHscEnv, getModule, - getRuleBase, getExternalRuleBase, + initRuleEnv, getExternalRuleBase, getDynFlags, getPackageFamInstEnv, getInteractiveContext, - getVisibleOrphanMods, getUniqMask, + getUniqMask, getPrintUnqualified, getSrcSpanM, -- ** Writing to the monad @@ -45,7 +45,7 @@ import GHC.Prelude hiding ( read ) import GHC.Driver.Session import GHC.Driver.Env -import GHC.Core +import GHC.Core.Rules ( RuleBase, RuleEnv, mkRuleEnv ) import GHC.Core.Opt.Stats ( SimplCount, zeroSimplCount, plusSimplCount ) import GHC.Types.Annotations @@ -114,12 +114,11 @@ pprFloatOutSwitches sw data CoreReader = CoreReader { cr_hsc_env :: HscEnv, - cr_rule_base :: RuleBase, + cr_rule_base :: RuleBase, -- Home package table rules cr_module :: Module, cr_print_unqual :: PrintUnqualified, cr_loc :: SrcSpan, -- Use this for log/error messages so they -- are at least tagged with the right source file - cr_visible_orphan_mods :: !ModuleSet, cr_uniq_mask :: !Char -- Mask for creating unique values } @@ -181,19 +180,17 @@ runCoreM :: HscEnv -> RuleBase -> Char -- ^ Mask -> Module - -> ModuleSet -> PrintUnqualified -> SrcSpan -> CoreM a -> IO (a, SimplCount) -runCoreM hsc_env rule_base mask mod orph_imps print_unqual loc m +runCoreM hsc_env rule_base mask mod print_unqual loc m = liftM extract $ runIOEnv reader $ unCoreM m where reader = CoreReader { cr_hsc_env = hsc_env, cr_rule_base = rule_base, cr_module = mod, - cr_visible_orphan_mods = orph_imps, cr_print_unqual = print_unqual, cr_loc = loc, cr_uniq_mask = mask @@ -245,15 +242,18 @@ liftIOWithCount what = liftIO what >>= (\(count, x) -> addSimplCount count >> re getHscEnv :: CoreM HscEnv getHscEnv = read cr_hsc_env -getRuleBase :: CoreM RuleBase -getRuleBase = read cr_rule_base +getHomeRuleBase :: CoreM RuleBase +getHomeRuleBase = read cr_rule_base + +initRuleEnv :: ModGuts -> CoreM RuleEnv +initRuleEnv guts + = do { hpt_rules <- getHomeRuleBase + ; eps_rules <- getExternalRuleBase + ; return (mkRuleEnv guts eps_rules hpt_rules) } getExternalRuleBase :: CoreM RuleBase getExternalRuleBase = eps_rule_base <$> get_eps -getVisibleOrphanMods :: CoreM ModuleSet -getVisibleOrphanMods = read cr_visible_orphan_mods - getPrintUnqualified :: CoreM PrintUnqualified getPrintUnqualified = read cr_print_unqual ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -22,7 +22,7 @@ import GHC.Platform.Ways ( hasWay, Way(WayProf) ) import GHC.Core import GHC.Core.Opt.CSE ( cseProgram ) -import GHC.Core.Rules ( mkRuleBase, ruleCheckProgram, getRules ) +import GHC.Core.Rules ( RuleBase, mkRuleBase, ruleCheckProgram, getRules ) import GHC.Core.Ppr ( pprCoreBindings ) import GHC.Core.Utils ( dumpIdInfoOfProgram ) import GHC.Core.Lint ( lintAnnots ) @@ -53,9 +53,7 @@ import GHC.Utils.Logger as Logger import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Unit.Module.Env import GHC.Unit.Module.ModGuts -import GHC.Unit.Module.Deps import GHC.Types.Id.Info import GHC.Types.Basic @@ -78,14 +76,12 @@ import GHC.Unit.Module core2core :: HscEnv -> ModGuts -> IO ModGuts core2core hsc_env guts@(ModGuts { mg_module = mod , mg_loc = loc - , mg_deps = deps , mg_rdr_env = rdr_env }) = do { let builtin_passes = getCoreToDo dflags hpt_rule_base extra_vars - orph_mods = mkModuleSet (mod : dep_orphs deps) uniq_mask = 's' - ; + ; (guts2, stats) <- runCoreM hsc_env hpt_rule_base uniq_mask mod - orph_mods print_unqual loc $ + print_unqual loc $ do { hsc_env' <- getHscEnv ; all_passes <- withPlugins (hsc_plugins hsc_env') installCoreToDos @@ -121,7 +117,8 @@ core2core hsc_env guts@(ModGuts { mg_module = mod -} getCoreToDo :: DynFlags -> RuleBase -> [Var] -> [CoreToDo] -getCoreToDo dflags rule_base extra_vars +-- This function builds the pipeline of optimisations +getCoreToDo dflags hpt_rule_base extra_vars = flatten_todos core_todo where phases = simplPhases dflags @@ -176,7 +173,7 @@ getCoreToDo dflags rule_base extra_vars ---------------------------- run_simplifier mode iter - = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode rule_base + = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode hpt_rule_base simpl_phase phase name iter = CoreDoPasses $ [ maybe_strictness_before phase @@ -573,11 +570,9 @@ ruleCheckPass current_phase pat guts = do logger <- getLogger withTiming logger (text "RuleCheck"<+>brackets (ppr $ mg_module guts)) (const ()) $ do - rb <- getRuleBase - vis_orphs <- getVisibleOrphanMods - let rule_fn fn = getRules (RuleEnv [rb] vis_orphs) fn - ++ (mg_rules guts) - let ropts = initRuleOpts dflags + rule_env <- initRuleEnv guts + let rule_fn fn = getRules rule_env fn + ropts = initRuleOpts dflags liftIO $ logDumpMsg logger "Rule check" (ruleCheckProgram ropts current_phase pat rule_fn (mg_binds guts)) ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -10,7 +10,7 @@ import GHC.Prelude import GHC.Driver.Flags import GHC.Core -import GHC.Core.Rules ( extendRuleBaseList, extendRuleEnv, addRuleInfo ) +import GHC.Core.Rules import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize ) @@ -31,7 +31,6 @@ import GHC.Utils.Constants (debugIsOn) import GHC.Unit.Env ( UnitEnv, ueEPS ) import GHC.Unit.External import GHC.Unit.Module.ModGuts -import GHC.Unit.Module.Deps import GHC.Types.Id import GHC.Types.Id.Info @@ -81,7 +80,7 @@ simplifyExpr logger euc opts expr simpl_env = mkSimplEnv (se_mode opts) fam_envs top_env_cfg = se_top_env_cfg opts read_eps_rules = eps_rule_base <$> eucEPS euc - read_ruleenv = extendRuleEnv emptyRuleEnv <$> read_eps_rules + read_ruleenv = updExternalPackageRules emptyRuleEnv <$> read_eps_rules ; let sz = exprSize expr @@ -132,11 +131,11 @@ simplExprGently env expr = do -- The values of this datatype are /only/ driven by the demands of that function. data SimplifyOpts = SimplifyOpts { so_dump_core_sizes :: !Bool - , so_iterations :: !Int - , so_mode :: !SimplMode + , so_iterations :: !Int + , so_mode :: !SimplMode , so_pass_result_cfg :: !(Maybe LintPassResultConfig) - , so_rule_base :: !RuleBase - , so_top_env_cfg :: !TopEnvConfig + , so_hpt_rules :: !RuleBase + , so_top_env_cfg :: !TopEnvConfig } simplifyPgm :: Logger @@ -148,11 +147,10 @@ simplifyPgm :: Logger simplifyPgm logger unit_env opts guts@(ModGuts { mg_module = this_mod , mg_rdr_env = rdr_env - , mg_deps = deps - , mg_binds = binds, mg_rules = rules + , mg_binds = binds, mg_rules = local_rules , mg_fam_inst_env = fam_inst_env }) = do { (termination_msg, it_count, counts_out, guts') - <- do_iteration 1 [] binds rules + <- do_iteration 1 [] binds local_rules ; when (logHasDumpFlag logger Opt_D_verbose_core2core && logHasDumpFlag logger Opt_D_dump_simpl_stats) $ @@ -169,7 +167,6 @@ simplifyPgm logger unit_env opts dump_core_sizes = so_dump_core_sizes opts mode = so_mode opts max_iterations = so_iterations opts - hpt_rule_base = so_rule_base opts top_env_cfg = so_top_env_cfg opts print_unqual = mkPrintUnqualified unit_env rdr_env active_rule = activeRule mode @@ -178,13 +175,18 @@ simplifyPgm logger unit_env opts -- the old bindings are retained until the end of all simplifier iterations !guts_no_binds = guts { mg_binds = [], mg_rules = [] } + hpt_rule_env :: RuleEnv + hpt_rule_env = mkRuleEnv guts emptyRuleBase (so_hpt_rules opts) + -- emptyRuleBase: no EPS rules yet; we will update + -- them on each iteration to pick up the most up to date set + do_iteration :: Int -- Counts iterations -> [SimplCount] -- Counts from earlier iterations, reversed - -> CoreProgram -- Bindings in - -> [CoreRule] -- and orphan rules + -> CoreProgram -- Bindings + -> [CoreRule] -- Local rules for imported Ids -> IO (String, Int, SimplCount, ModGuts) - do_iteration iteration_no counts_so_far binds rules + do_iteration iteration_no counts_so_far binds local_rules -- iteration_no is the number of the iteration we are -- about to begin, with '1' for the first | iteration_no > max_iterations -- Stop if we've run out of iterations @@ -200,7 +202,7 @@ simplifyPgm logger unit_env opts -- number of iterations we actually completed return ( "Simplifier baled out", iteration_no - 1 , totalise counts_so_far - , guts_no_binds { mg_binds = binds, mg_rules = rules } ) + , guts_no_binds { mg_binds = binds, mg_rules = local_rules } ) -- Try and force thunks off the binds; significantly reduces -- space usage, especially with -O. JRS, 000620. @@ -209,8 +211,8 @@ simplifyPgm logger unit_env opts = do { -- Occurrence analysis let { tagged_binds = {-# SCC "OccAnal" #-} - occurAnalysePgm this_mod active_unf active_rule rules - binds + occurAnalysePgm this_mod active_unf active_rule + local_rules binds } ; Logger.putDumpFileMaybe logger Opt_D_dump_occur_anal "Occurrence analysis" FormatCore @@ -221,24 +223,29 @@ simplifyPgm logger unit_env opts -- poke on IdInfo thunks, which in turn brings in new rules -- behind the scenes. Otherwise there's a danger we'll simply -- miss the rules for Ids hidden inside imported inlinings - -- Hence just before attempting to match rules we read on the EPS - -- value and then combine it when the existing rule base. + -- Hence just before attempting to match a rule we read the EPS + -- value (via read_rule_env) and then combine it with the existing rule base. -- See `GHC.Core.Opt.Simplify.Monad.getSimplRules`. - eps <- ueEPS unit_env ; - let { -- Forcing this value to avoid unnessecary allocations. + eps <- ueEPS unit_env ; + let { -- base_rule_env contains + -- (a) home package rules, fixed across all iterations + -- (b) local rules (substituted) from `local_rules` arg to do_iteration + -- Forcing base_rule_env to avoid unnecessary allocations. -- Not doing so results in +25.6% allocations of LargeRecord. - ; !rule_base = extendRuleBaseList hpt_rule_base rules - ; vis_orphs = this_mod : dep_orphs deps - ; base_ruleenv = mkRuleEnv rule_base vis_orphs + ; !base_rule_env = updLocalRules hpt_rule_env local_rules + + ; read_eps_rules :: IO PackageRuleBase ; read_eps_rules = eps_rule_base <$> ueEPS unit_env - ; read_ruleenv = extendRuleEnv base_ruleenv <$> read_eps_rules + + ; read_rule_env :: IO RuleEnv + ; read_rule_env = updExternalPackageRules base_rule_env <$> read_eps_rules ; fam_envs = (eps_fam_inst_env eps, fam_inst_env) ; simpl_env = mkSimplEnv mode fam_envs } ; -- Simplify the program ((binds1, rules1), counts1) <- - initSmpl logger read_ruleenv top_env_cfg sz $ + initSmpl logger read_rule_env top_env_cfg sz $ do { (floats, env1) <- {-# SCC "SimplTopBinds" #-} simplTopBinds simpl_env tagged_binds @@ -246,7 +253,7 @@ simplifyPgm logger unit_env opts -- for imported Ids. Eg RULE map my_f = blah -- If we have a substitution my_f :-> other_f, we'd better -- apply it to the rule to, or it'll never match - ; rules1 <- simplImpRules env1 rules + ; rules1 <- simplImpRules env1 local_rules ; return (getTopFloatBinds floats, rules1) } ; ===================================== compiler/GHC/Core/Opt/Simplify/Monad.hs ===================================== @@ -27,8 +27,8 @@ import GHC.Types.Name ( mkSystemVarName ) import GHC.Types.Id ( Id, mkSysLocalOrCoVarM ) import GHC.Types.Id.Info ( IdDetails(..), vanillaIdInfo, setArityInfo ) import GHC.Core.Type ( Type, Mult ) -import GHC.Core ( RuleEnv(..) ) import GHC.Core.Opt.Stats +import GHC.Core.Rules import GHC.Core.Utils ( mkLamTypes ) import GHC.Types.Unique.Supply import GHC.Driver.Flags ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -53,7 +53,7 @@ import GHC.Core.Ppr import GHC.Core.TyCo.Ppr ( pprParendType ) import GHC.Core.FVs import GHC.Core.Utils -import GHC.Core.Rules( getRules ) +import GHC.Core.Rules( RuleEnv, getRules ) import GHC.Core.Opt.Arity import GHC.Core.Unfold import GHC.Core.Unfold.Make ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -17,6 +17,7 @@ import GHC.Driver.Config.Core.Rules ( initRuleOpts ) import GHC.Core.Type hiding( substTy, substCo, extendTvSubst, zapSubst ) import GHC.Core.Multiplicity +import GHC.Core.SimpleOpt( defaultSimpleOpts, simpleOptExprWith ) import GHC.Core.Predicate import GHC.Core.Coercion( Coercion ) import GHC.Core.Opt.Monad @@ -636,9 +637,11 @@ Hence, the invariant is this: -- | Specialise calls to type-class overloaded functions occurring in a program. specProgram :: ModGuts -> CoreM ModGuts specProgram guts@(ModGuts { mg_module = this_mod - , mg_rules = local_rules - , mg_binds = binds }) - = do { dflags <- getDynFlags + , mg_rules = local_rules + , mg_binds = binds }) + = do { dflags <- getDynFlags + ; rule_env <- initRuleEnv guts + -- See Note [Fire rules in the specialiser] -- We need to start with a Subst that knows all the things -- that are in scope, so that the substitution engine doesn't @@ -650,6 +653,7 @@ specProgram guts@(ModGuts { mg_module = this_mod -- mkInScopeSetList $ -- bindersOfBinds binds , se_module = this_mod + , se_rules = rule_env , se_dflags = dflags } go [] = return ([], emptyUDs) @@ -660,7 +664,7 @@ specProgram guts@(ModGuts { mg_module = this_mod -- Specialise the bindings of this module ; (binds', uds) <- runSpecM (go binds) - ; (spec_rules, spec_binds) <- specImports top_env local_rules uds + ; (spec_rules, spec_binds) <- specImports top_env uds ; return (guts { mg_binds = spec_binds ++ binds' , mg_rules = spec_rules ++ local_rules }) } @@ -725,21 +729,15 @@ specialisation (see canSpecImport): -} specImports :: SpecEnv - -> [CoreRule] -> UsageDetails -> CoreM ([CoreRule], [CoreBind]) -specImports top_env local_rules - (MkUD { ud_binds = dict_binds, ud_calls = calls }) +specImports top_env (MkUD { ud_binds = dict_binds, ud_calls = calls }) | not $ gopt Opt_CrossModuleSpecialise (se_dflags top_env) -- See Note [Disabling cross-module specialisation] = return ([], wrapDictBinds dict_binds []) | otherwise - = do { hpt_rules <- getRuleBase - ; let rule_base = extendRuleBaseList hpt_rules local_rules - - ; (spec_rules, spec_binds) <- spec_imports top_env [] rule_base - dict_binds calls + = do { (_env, spec_rules, spec_binds) <- spec_imports top_env [] dict_binds calls -- Don't forget to wrap the specialized bindings with -- bindings for the needed dictionaries. @@ -757,89 +755,91 @@ specImports top_env local_rules spec_imports :: SpecEnv -- Passed in so that all top-level Ids are in scope -> [Id] -- Stack of imported functions being specialised -- See Note [specImport call stack] - -> RuleBase -- Rules from this module and the home package - -- (but not external packages, which can change) -> FloatedDictBinds -- Dict bindings, used /only/ for filterCalls -- See Note [Avoiding loops in specImports] -> CallDetails -- Calls for imported things - -> CoreM ( [CoreRule] -- New rules + -> CoreM ( SpecEnv -- Env contains the new rules + , [CoreRule] -- New rules , [CoreBind] ) -- Specialised bindings -spec_imports top_env callers rule_base dict_binds calls +spec_imports env callers dict_binds calls = do { let import_calls = dVarEnvElts calls -- ; debugTraceMsg (text "specImports {" <+> -- vcat [ text "calls:" <+> ppr import_calls -- , text "dict_binds:" <+> ppr dict_binds ]) - ; (rules, spec_binds) <- go rule_base import_calls + ; (env, rules, spec_binds) <- go env import_calls -- ; debugTraceMsg (text "End specImports }" <+> ppr import_calls) - ; return (rules, spec_binds) } + ; return (env, rules, spec_binds) } where - go :: RuleBase -> [CallInfoSet] -> CoreM ([CoreRule], [CoreBind]) - go _ [] = return ([], []) - go rb (cis : other_calls) + go :: SpecEnv -> [CallInfoSet] -> CoreM (SpecEnv, [CoreRule], [CoreBind]) + go env [] = return (env, [], []) + go env (cis : other_calls) = do { -- debugTraceMsg (text "specImport {" <+> ppr cis) - ; (rules1, spec_binds1) <- spec_import top_env callers rb dict_binds cis + ; (env, rules1, spec_binds1) <- spec_import env callers dict_binds cis ; -- debugTraceMsg (text "specImport }" <+> ppr cis) - ; (rules2, spec_binds2) <- go (extendRuleBaseList rb rules1) other_calls - ; return (rules1 ++ rules2, spec_binds1 ++ spec_binds2) } + ; (env, rules2, spec_binds2) <- go env other_calls + ; return (env, rules1 ++ rules2, spec_binds1 ++ spec_binds2) } spec_import :: SpecEnv -- Passed in so that all top-level Ids are in scope -> [Id] -- Stack of imported functions being specialised -- See Note [specImport call stack] - -> RuleBase -- Rules from this module -> FloatedDictBinds -- Dict bindings, used /only/ for filterCalls -- See Note [Avoiding loops in specImports] -> CallInfoSet -- Imported function and calls for it - -> CoreM ( [CoreRule] -- New rules + -> CoreM ( SpecEnv + , [CoreRule] -- New rules , [CoreBind] ) -- Specialised bindings -spec_import top_env callers rb dict_binds cis@(CIS fn _) +spec_import env callers dict_binds cis@(CIS fn _) | isIn "specImport" fn callers - = return ([], []) -- No warning. This actually happens all the time - -- when specialising a recursive function, because - -- the RHS of the specialised function contains a recursive - -- call to the original function + = return (env, [], []) -- No warning. This actually happens all the time + -- when specialising a recursive function, because + -- the RHS of the specialised function contains a recursive + -- call to the original function | null good_calls - = return ([], []) + = return (env, [], []) | Just rhs <- canSpecImport dflags fn = do { -- Get rules from the external package state -- We keep doing this in case we "page-fault in" -- more rules as we go along - ; external_rule_base <- getExternalRuleBase - ; vis_orphs <- getVisibleOrphanMods - ; let rules_for_fn = getRules (RuleEnv [rb, external_rule_base] vis_orphs) fn + ; eps_rules <- getExternalRuleBase + ; let rule_env = se_rules env `updExternalPackageRules` eps_rules - ; -- debugTraceMsg (text "specImport1" <+> vcat [ppr fn, ppr good_calls, ppr rhs]) +-- ; debugTraceMsg (text "specImport1" <+> vcat [ppr fn, ppr good_calls +-- , ppr (getRules rule_env fn), ppr rhs]) ; (rules1, spec_pairs, MkUD { ud_binds = dict_binds1, ud_calls = new_calls }) - <- runSpecM $ specCalls True top_env dict_binds - rules_for_fn good_calls fn rhs + <- runSpecM $ specCalls True env dict_binds + (getRules rule_env fn) good_calls fn rhs ; let spec_binds1 = [NonRec b r | (b,r) <- spec_pairs] -- After the rules kick in we may get recursion, but -- we rely on a global GlomBinds to sort that out later -- See Note [Glom the bindings if imported functions are specialised] + new_subst = se_subst env `Core.extendSubstInScopeList` map fst spec_pairs + new_env = env { se_rules = rule_env `addLocalRules` rules1 + , se_subst = new_subst } + -- Now specialise any cascaded calls - ; -- debugTraceMsg (text "specImport 2" <+> (ppr fn $$ ppr rules1 $$ ppr spec_binds1)) - ; (rules2, spec_binds2) <- spec_imports top_env - (fn:callers) - (extendRuleBaseList rb rules1) - (dict_binds `thenFDBs` dict_binds1) - new_calls +-- ; debugTraceMsg (text "specImport 2" <+> (ppr fn $$ ppr rules1 $$ ppr spec_binds1)) + ; (env, rules2, spec_binds2) + <- spec_imports new_env (fn:callers) + (dict_binds `thenFDBs` dict_binds1) + new_calls ; let final_binds = wrapDictBinds dict_binds1 $ spec_binds2 ++ spec_binds1 - ; return (rules2 ++ rules1, final_binds) } + ; return (env, rules2 ++ rules1, final_binds) } | otherwise = do { tryWarnMissingSpecs dflags callers fn good_calls - ; return ([], [])} + ; return (env, [], [])} where - dflags = se_dflags top_env + dflags = se_dflags env good_calls = filterCalls cis dict_binds -- SUPER IMPORTANT! Drop calls that (directly or indirectly) refer to fn -- See Note [Avoiding loops in specImports] @@ -1134,6 +1134,7 @@ data SpecEnv -- the RHS of specialised bindings (no type-let!) , se_module :: Module + , se_rules :: RuleEnv -- From the home package and this module , se_dflags :: DynFlags } @@ -1172,8 +1173,8 @@ specExpr env expr@(App {}) ; (args_out, uds_args) <- mapAndCombineSM (specExpr env) args_in ; let env_args = env `bringFloatedDictsIntoScope` ud_binds uds_args -- Some dicts may have floated out of args_in; - -- they should be in scope for rewriteClassOps (#21689) - (fun_in', args_out') = rewriteClassOps env_args fun_in args_out + -- they should be in scope for fireRewriteRules (#21689) + (fun_in', args_out') = fireRewriteRules env_args fun_in args_out ; (fun_out', uds_fun) <- specExpr env fun_in' ; let uds_call = mkCallUDs env fun_out' args_out' ; return (fun_out' `mkApps` args_out', uds_fun `thenUDs` uds_call `thenUDs` uds_args) } @@ -1208,17 +1209,19 @@ specExpr env (Let bind body) ; return (foldr Let body' binds', uds) } -- See Note [Specialisation modulo dictionary selectors] --- and Note [ClassOp/DFun selection] -rewriteClassOps :: SpecEnv -> InExpr -> [OutExpr] -> (InExpr, [OutExpr]) -rewriteClassOps env (Var f) args - | isClassOpId f -- If we see `op_sel $fCInt`, we rewrite to `$copInt` - , Just (rule, expr) <- -- pprTrace "rewriteClassOps" (ppr f $$ ppr args $$ ppr (se_subst env)) $ - specLookupRule env f args (idCoreRules f) - , let rest_args = drop (ruleArity rule) args -- See Note [Extra args in the target] --- , pprTrace "class op rewritten" (ppr f <+> ppr args $$ ppr expr <+> ppr rest_args) True - , (fun, args) <- collectArgs expr - = rewriteClassOps env fun (args++rest_args) -rewriteClassOps _ fun args = (fun, args) +-- Note [ClassOp/DFun selection] +-- Note [Fire rules in the specialiser] +fireRewriteRules :: SpecEnv -> InExpr -> [OutExpr] -> (InExpr, [OutExpr]) +fireRewriteRules env (Var f) args + | Just (rule, expr) <- specLookupRule env f args InitialPhase (getRules (se_rules env) f) + , let rest_args = drop (ruleArity rule) args -- See Note [Extra args in the target] + zapped_subst = Core.zapSubst (se_subst env) + expr' = simpleOptExprWith defaultSimpleOpts zapped_subst expr + -- simplOptExpr needed because lookupRule returns + -- (\x y. rhs) arg1 arg2 + , (fun, args) <- collectArgs expr' + = fireRewriteRules env fun (args++rest_args) +fireRewriteRules _ fun args = (fun, args) -------------- specLam :: SpecEnv -> [OutBndr] -> InExpr -> SpecM (OutExpr, UsageDetails) @@ -1324,7 +1327,67 @@ specCase env scrut case_bndr alts where (env_rhs, args') = substBndrs env_alt args -{- +{- Note [Fire rules in the specialiser] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this (#21851) + + module A where + f :: Num b => b -> (b, b) + f x = (x + 1, snd (f x)) + {-# SPECIALIZE f :: Int -> (Int, Int) #-} + + module B (g') where + import A + + g :: Num a => a -> a + g x = fst (f x) + {-# NOINLINE[99] g #-} + + h :: Int -> Int + h = g + +Note that `f` has the CPR property, and so will worker/wrapper. + +The call to `g` in `h` will make us specialise `g @Int`. And the specialised +version of `g` will contain the call `f @Int`; but in the subsequent run of +the Simplifier, there will be a competition between: +* The user-supplied SPECIALISE rule for `f` +* The inlining of the wrapper for `f` +In fact, the latter wins -- see Note [Rewrite rules and inlining] in +GHC.Core.Opt.Simplify.Iteration. However, it a bit fragile. + +Moreover consider (test T21851_2): + + module A + f :: (Ord a, Show b) => a -> b -> blah + {-# RULE forall b. f @Int @b = wombat #-} + + wombat :: Show b => Int -> b -> blah + wombat = blah + + module B + import A + g :: forall a. Ord a => blah + g @a = ...g...f @a @Char.... + + h = ....g @Int.... + +Now, in module B, GHC will specialise `g @Int`, which will lead to a +call `f @Int @Char`. If we immediately (in the specialiser) rewrite +that to `womabat @Char`, we have a chance to specialise `wombat`. + +Conclusion: it's treat if the Specialiser fires RULEs itself. +It's not hard to achieve: see `fireRewriteRules`. The only tricky bit is +making sure that we have a reasonably up to date EPS rule base. Currently +we load it up just once, in `initRuleEnv`, called at the beginning of +`specProgram`. + +NB: you might wonder if running rules in the specialiser (this Note) +renders Note [Rewrite rules and inlining] in the Simplifier redundant. +That is, if we run rules in the specialiser, does it matter if we make +rules "win" over inlining in the Simplifier? Yes, it does! See the +discussion in #21851. + Note [Floating dictionaries out of cases] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -1415,13 +1478,12 @@ specBind top_lvl env (NonRec fn rhs) do_body final_binds :: [DictBind] -- See Note [From non-recursive to recursive] - final_binds - | not (isNilOL dump_dbs) - , not (null spec_defns) - = [recWithDumpedDicts pairs dump_dbs] - | otherwise - = [mkDB $ NonRec b r | (b,r) <- pairs] - ++ fromOL dump_dbs + final_binds | not (isNilOL dump_dbs) + , not (null spec_defns) + = [recWithDumpedDicts pairs dump_dbs] + | otherwise + = [mkDB $ NonRec b r | (b,r) <- pairs] + ++ fromOL dump_dbs ; if float_all then -- Rather than discard the calls mentioning the bound variables @@ -1553,8 +1615,10 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs foldlM spec_call ([], [], emptyUDs) calls_for_me | otherwise -- No calls or RHS doesn't fit our preconceptions - = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me) + = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me && not (isClassOpId fn)) "Missed specialisation opportunity for" (ppr fn $$ trace_doc) $ + -- isClassOpId: class-op Ids never inline; we specialise them + -- through fireRewriteRules. So don't complain about missed opportunities -- Note [Specialisation shape] -- pprTrace "specCalls: none" (ppr fn <+> ppr calls_for_me) $ return ([], [], emptyUDs) @@ -1581,9 +1645,13 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs already_covered :: SpecEnv -> [CoreRule] -> [CoreExpr] -> Bool already_covered env new_rules args -- Note [Specialisations already covered] - = isJust (specLookupRule env fn args (new_rules ++ existing_rules)) - -- NB: we look both in the new_rules (generated by this invocation - -- of specCalls), and in existing_rules (passed in to specCalls) + = isJust (specLookupRule env fn args (beginPhase inl_act) + (new_rules ++ existing_rules)) + -- Rules: we look both in the new_rules (generated by this invocation + -- of specCalls), and in existing_rules (passed in to specCalls) + -- inl_act: is the activation we are going to put in the new SPEC + -- rule; so we want to see if it is covered by another rule with + -- that same activation. ---------------------------------------------------------- -- Specialise to one particular call pattern @@ -1708,13 +1776,16 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs -- Convenience function for invoking lookupRule from Specialise -- The SpecEnv's InScopeSet should include all the Vars in the [CoreExpr] -specLookupRule :: SpecEnv -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr) -specLookupRule env fn args rules - = lookupRule ropts (in_scope, realIdUnfolding) (const True) fn args rules +specLookupRule :: SpecEnv -> Id -> [CoreExpr] + -> CompilerPhase -- Look up rules as if we were in this phase + -> [CoreRule] -> Maybe (CoreRule, CoreExpr) +specLookupRule env fn args phase rules + = lookupRule ropts (in_scope, realIdUnfolding) is_active fn args rules where - dflags = se_dflags env - in_scope = getSubstInScope (se_subst env) - ropts = initRuleOpts dflags + dflags = se_dflags env + in_scope = getSubstInScope (se_subst env) + ropts = initRuleOpts dflags + is_active = isActive phase {- Note [Specialising DFuns] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1913,10 +1984,10 @@ We want to specialise this! How? By doing the method-selection rewrite in the Specialiser. Hence 1. In the App case of 'specExpr', try to apply the ClassOp/DFun rule on the - head of the application, repeatedly, via 'rewriteClassOps'. + head of the application, repeatedly, via 'fireRewriteRules'. 2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and `$dShow` in `bindAuxiliaryDict`, so that we can exploit the unfolding - in 'rewriteClassOps' to do the ClassOp/DFun rewrite. + in 'fireRewriteRules' to do the ClassOp/DFun rewrite. NB: Without (2), (1) would be pointless, because 'lookupRule' wouldn't be able to look into the RHS of `$dC` to see the DFun. ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -12,8 +12,10 @@ module GHC.Core.Rules ( lookupRule, -- ** RuleBase, RuleEnv + RuleBase, RuleEnv(..), mkRuleEnv, emptyRuleEnv, + updExternalPackageRules, addLocalRules, updLocalRules, emptyRuleBase, mkRuleBase, extendRuleBaseList, - pprRuleBase, extendRuleEnv, + pprRuleBase, -- ** Checking rule applications ruleCheckProgram, @@ -22,6 +24,8 @@ module GHC.Core.Rules ( extendRuleInfo, addRuleInfo, addIdSpecialisations, + -- ** RuleBase and RuleEnv + -- * Misc. CoreRule helpers rulesOfBinds, getRules, pprRulesForUser, @@ -34,6 +38,8 @@ import GHC.Prelude import GHC.Unit.Module ( Module ) import GHC.Unit.Module.Env +import GHC.Unit.Module.ModGuts( ModGuts(..) ) +import GHC.Unit.Module.Deps( Dependencies(..) ) import GHC.Driver.Session( DynFlags ) import GHC.Driver.Ppr( showSDoc ) @@ -135,7 +141,7 @@ Note [Overall plumbing for rules] * At the moment (c) is carried in a reader-monad way by the GHC.Core.Opt.Monad. The HomePackageTable doesn't have a single RuleBase because technically we should only be able to "see" rules "below" this module; so we - generate a RuleBase for (c) by combing rules from all the modules + generate a RuleBase for (c) by combining rules from all the modules "below" us. That's why we can't just select the home-package RuleBase from HscEnv. @@ -339,12 +345,106 @@ addIdSpecialisations id rules rulesOfBinds :: [CoreBind] -> [CoreRule] rulesOfBinds binds = concatMap (concatMap idCoreRules . bindersOf) binds + +{- +************************************************************************ +* * + RuleBase +* * +************************************************************************ +-} + +-- | Gathers a collection of 'CoreRule's. Maps (the name of) an 'Id' to its rules +type RuleBase = NameEnv [CoreRule] + -- The rules are unordered; + -- we sort out any overlaps on lookup + +emptyRuleBase :: RuleBase +emptyRuleBase = emptyNameEnv + +mkRuleBase :: [CoreRule] -> RuleBase +mkRuleBase rules = extendRuleBaseList emptyRuleBase rules + +extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase +extendRuleBaseList rule_base new_guys + = foldl' extendRuleBase rule_base new_guys + +extendRuleBase :: RuleBase -> CoreRule -> RuleBase +extendRuleBase rule_base rule + = extendNameEnv_Acc (:) Utils.singleton rule_base (ruleIdName rule) rule + +pprRuleBase :: RuleBase -> SDoc +pprRuleBase rules = pprUFM rules $ \rss -> + vcat [ pprRules (tidyRules emptyTidyEnv rs) + | rs <- rss ] + +-- | A full rule environment which we can apply rules from. Like a 'RuleBase', +-- but it also includes the set of visible orphans we use to filter out orphan +-- rules which are not visible (even though we can see them...) +-- See Note [Orphans] in GHC.Core +data RuleEnv + = RuleEnv { re_local_rules :: !RuleBase -- Rules from this module + , re_home_rules :: !RuleBase -- Rule from the home package + -- (excl this module) + , re_eps_rules :: !RuleBase -- Rules from other packages + -- see Note [External package rules] + , re_visible_orphs :: !ModuleSet + } + +mkRuleEnv :: ModGuts -> RuleBase -> RuleBase -> RuleEnv +mkRuleEnv (ModGuts { mg_module = this_mod + , mg_deps = deps + , mg_rules = local_rules }) + eps_rules hpt_rules + = RuleEnv { re_local_rules = mkRuleBase local_rules + , re_home_rules = hpt_rules + , re_eps_rules = eps_rules + , re_visible_orphs = mkModuleSet vis_orphs } + where + vis_orphs = this_mod : dep_orphs deps + +updExternalPackageRules :: RuleEnv -> RuleBase -> RuleEnv +-- Completely over-ride the external rules in RuleEnv +updExternalPackageRules rule_env eps_rules + = rule_env { re_eps_rules = eps_rules } + +updLocalRules :: RuleEnv -> [CoreRule] -> RuleEnv +-- Completely over-ride the local rules in RuleEnv +updLocalRules rule_env local_rules + = rule_env { re_local_rules = mkRuleBase local_rules } + +addLocalRules :: RuleEnv -> [CoreRule] -> RuleEnv +-- Add new local rules +addLocalRules rule_env rules + = rule_env { re_local_rules = extendRuleBaseList (re_local_rules rule_env) rules } + +emptyRuleEnv :: RuleEnv +emptyRuleEnv = RuleEnv { re_local_rules = emptyNameEnv + , re_home_rules = emptyNameEnv + , re_eps_rules = emptyNameEnv + , re_visible_orphs = emptyModuleSet } + getRules :: RuleEnv -> Id -> [CoreRule] +-- Given a RuleEnv and an Id, find the visible rules for that Id -- See Note [Where rules are found] -getRules (RuleEnv { re_base = rule_base, re_visible_orphs = orphs }) fn - = idCoreRules fn ++ concatMap imp_rules rule_base +getRules (RuleEnv { re_local_rules = local_rules + , re_home_rules = home_rules + , re_eps_rules = eps_rules + , re_visible_orphs = orphs }) fn + + | Just {} <- isDataConId_maybe fn -- Short cut for data constructor workers + = [] -- and wrappers, which never have any rules + + | otherwise + = idCoreRules fn ++ + get local_rules ++ + find_visible home_rules ++ + find_visible eps_rules + where - imp_rules rb = filter (ruleIsVisible orphs) (lookupNameEnv rb (idName fn) `orElse` []) + fn_name = idName fn + find_visible rb = filter (ruleIsVisible orphs) (get rb) + get rb = lookupNameEnv rb fn_name `orElse` [] ruleIsVisible :: ModuleSet -> CoreRule -> Bool ruleIsVisible _ BuiltinRule{} = True @@ -370,37 +470,28 @@ but that isn't quite right: in the module defining the Id (when it's a LocalId), but the rules are kept in the global RuleBase + Note [External package rules] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In Note [Overall plumbing for rules], it is explained that the final +RuleBase which we must consider is combined from 4 different sources. -************************************************************************ -* * - RuleBase -* * -************************************************************************ --} - --- RuleBase itself is defined in GHC.Core, along with CoreRule - -emptyRuleBase :: RuleBase -emptyRuleBase = emptyNameEnv - -mkRuleBase :: [CoreRule] -> RuleBase -mkRuleBase rules = extendRuleBaseList emptyRuleBase rules +During simplifier runs, the fourth source of rules is constantly being updated +as new interfaces are loaded into the EPS. Therefore just before we check to see +if any rules match we get the EPS RuleBase and combine it with the existing RuleBase +and then perform exactly 1 lookup into the new map. -extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase -extendRuleBaseList rule_base new_guys - = foldl' extendRuleBase rule_base new_guys +It is more efficient to avoid combining the environments and store the uncombined +environments as we can instead perform 1 lookup into each environment and then combine +the results. -extendRuleBase :: RuleBase -> CoreRule -> RuleBase -extendRuleBase rule_base rule - = extendNameEnv_Acc (:) Utils.singleton rule_base (ruleIdName rule) rule +Essentially we use the identity: -extendRuleEnv :: RuleEnv -> RuleBase -> RuleEnv -extendRuleEnv (RuleEnv rules orphs) rb = (RuleEnv (rb:rules) orphs) +> lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) +> = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 -pprRuleBase :: RuleBase -> SDoc -pprRuleBase rules = pprUFM rules $ \rss -> - vcat [ pprRules (tidyRules emptyTidyEnv rs) - | rs <- rss ] +The latter being more efficient as we don't construct an intermediate +map. +-} {- ************************************************************************ @@ -1575,7 +1666,7 @@ ruleCheckFun env fn args | otherwise = unitBag (ruleAppCheck_help env fn args name_match_rules) where name_match_rules = filter match (rc_rules env fn) - match rule = (rc_pattern env) `isPrefixOf` unpackFS (ruleName rule) + match rule = rc_pattern env `isPrefixOf` unpackFS (ruleName rule) ruleAppCheck_help :: RuleCheckEnv -> Id -> [CoreExpr] -> [CoreRule] -> SDoc ruleAppCheck_help env fn args rules ===================================== compiler/GHC/Driver/Config/Core/Opt/Simplify.hs ===================================== @@ -6,7 +6,7 @@ module GHC.Driver.Config.Core.Opt.Simplify import GHC.Prelude -import GHC.Core ( RuleBase ) +import GHC.Core.Rules ( RuleBase ) import GHC.Core.Opt.Pipeline.Types ( CoreToDo(..) ) import GHC.Core.Opt.Simplify ( SimplifyExprOpts(..), SimplifyOpts(..) ) import GHC.Core.Opt.Simplify.Env ( FloatEnable(..), SimplMode(..) ) @@ -40,20 +40,19 @@ initSimplifyExprOpts dflags ic = SimplifyExprOpts } initSimplifyOpts :: DynFlags -> [Var] -> Int -> SimplMode -> RuleBase -> SimplifyOpts -initSimplifyOpts dflags extra_vars iterations mode rule_base = let +initSimplifyOpts dflags extra_vars iterations mode hpt_rule_base = let -- This is a particularly ugly construction, but we will get rid of it in !8341. opts = SimplifyOpts { so_dump_core_sizes = not $ gopt Opt_SuppressCoreSizes dflags - , so_iterations = iterations - , so_mode = mode + , so_iterations = iterations + , so_mode = mode , so_pass_result_cfg = if gopt Opt_DoCoreLinting dflags - then Just $ initLintPassResultConfig dflags extra_vars (CoreDoSimplify opts) - else Nothing - , so_rule_base = rule_base - , so_top_env_cfg = TopEnvConfig - { te_history_size = historySize dflags - , te_tick_factor = simplTickFactor dflags - } + then Just $ initLintPassResultConfig dflags extra_vars + (CoreDoSimplify opts) + else Nothing + , so_hpt_rules = hpt_rule_base + , so_top_env_cfg = TopEnvConfig { te_history_size = historySize dflags + , te_tick_factor = simplTickFactor dflags } } in opts ===================================== compiler/GHC/HsToCore/Errors/Ppr.hs ===================================== @@ -86,7 +86,7 @@ instance Diagnostic DsMessage where hang (text "Top-level" <+> text desc <+> text "aren't allowed:") 2 (ppr bind) DsUselessSpecialiseForClassMethodSelector poly_id -> mkSimpleDecorated $ - text "Ignoring useless SPECIALISE pragma for NOINLINE function:" <+> quotes (ppr poly_id) + text "Ignoring useless SPECIALISE pragma for class selector:" <+> quotes (ppr poly_id) DsUselessSpecialiseForNoInlineFunction poly_id -> mkSimpleDecorated $ text "Ignoring useless SPECIALISE pragma for NOINLINE function:" <+> quotes (ppr poly_id) ===================================== compiler/GHC/Unit/External.hs ===================================== @@ -21,11 +21,10 @@ import GHC.Prelude import GHC.Unit import GHC.Unit.Module.ModIface -import GHC.Core ( RuleBase ) import GHC.Core.FamInstEnv import GHC.Core.InstEnv ( InstEnv, emptyInstEnv ) import GHC.Core.Opt.ConstantFold -import GHC.Core.Rules (mkRuleBase) +import GHC.Core.Rules ( RuleBase, mkRuleBase) import GHC.Types.Annotations ( AnnEnv, emptyAnnEnv ) import GHC.Types.CompleteMatch ===================================== libraries/base/GHC/Ix.hs ===================================== @@ -140,12 +140,30 @@ Note [Out-of-bounds error messages] The default method for 'index' generates hoplelessIndexError, because Ix doesn't have Show as a superclass. For particular base types we can do better, so we override the default method for index. --} --- Abstract these errors from the relevant index functions so that --- the guts of the function will be small enough to inline. +Note [indexError] +~~~~~~~~~~~~~~~~~ +We abstract the guts of constructing an out-of-bounds error into `indexError`. +We give it a NOINLINE pragma, because we don't want to duplicate this +cold-path code. + +We give it a SPECIALISE pragma because we really want it to take +its arguments unboxed, to avoid reboxing code in the caller, and +perhaps even some reboxing code in the hot path of a caller. +See Note [Boxity for bottoming functions] in GHC.Core.Opt.DmdAnal. + +The SPECIALISE pragma means that at least the Int-indexed case +of indexError /will/ unbox its arguments. +The [2] phase is because if we don't give an activation we'll get +the one from the inline pragama (i.e. never) which is a bit silly. +See Note [Activation pragmas for SPECIALISE] in GHC.HsToCore.Binds. +-} + +-- indexError: see Note [indexError] {-# NOINLINE indexError #-} +{-# SPECIALISE [2] indexError :: (Int,Int) -> Int -> String -> b #-} + indexError :: Show a => (a,a) -> a -> String -> b indexError rng i tp = errorWithoutStackTrace (showString "Ix{" . showString tp . showString "}.index: Index " . ===================================== libraries/base/GHC/Real.hs ===================================== @@ -701,11 +701,14 @@ half of y - 1 can be computed as y `quot` 2, optimising subtraction away. Note [Inlining (^) ~~~~~~~~~~~~~~~~~~ -The INLINABLE pragma allows (^) to be specialised at its call sites. +The INLINABLE [1] pragma allows (^) to be specialised at its call sites. If it is called repeatedly at the same type, that can make a huge difference, because of those constants which can be repeatedly calculated. +We don't inline until phase 1, to give a chance for the RULES +"^2/Int" etc to fire first. + Currently the fromInteger calls are not floated because we get \d1 d2 x y -> blah after the gentle round of simplification. ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -15,5 +15,3 @@ g' :: Int -> Int g' = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } - - ===================================== testsuite/tests/simplCore/should_compile/T21851_2.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS_GHC -ddump-simpl -dsuppress-uniques -dno-typeable-binds #-} + +module T21851_2 where + +import T21851_2a + +g :: forall a. (Ord a, Num a) => a -> (a,String) +g n | n < 10 = (0, f n True) + | otherwise = g (n-2) +-- The specialised version of g leads to a specialised +-- call to (f @Int @Bool). Then we want to fire f's RULE +-- and specialise 'wombat' + +h = g (3::Int) + ===================================== testsuite/tests/simplCore/should_compile/T21851_2.stderr ===================================== @@ -0,0 +1,120 @@ +[1 of 2] Compiling T21851_2a ( T21851_2a.hs, T21851_2a.o ) +[2 of 2] Compiling T21851_2 ( T21851_2.hs, T21851_2.o ) + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 107, types: 96, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl :: Integer +[GblId, Unf=OtherCon []] +lvl = GHC.Num.Integer.IS 2# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl1 :: Integer +[GblId, Unf=OtherCon []] +lvl1 = GHC.Num.Integer.IS 0# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl2 :: Integer +[GblId, Unf=OtherCon []] +lvl2 = GHC.Num.Integer.IS 10# + +Rec { +-- RHS size: {terms: 25, types: 5, coercions: 0, joins: 0/0} +T21851_2.$s$wwombat [InlPrag=[~], Occ=LoopBreaker] + :: GHC.Prim.Int# -> Bool -> [Char] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +T21851_2.$s$wwombat + = \ (ww :: GHC.Prim.Int#) (y :: Bool) -> + case ww of ds { + __DEFAULT -> + case y of { + False -> + GHC.CString.unpackAppendCString# + GHC.Show.$fShowBool3 + (T21851_2.$s$wwombat (GHC.Prim.-# ds 1#) GHC.Types.False); + True -> + GHC.CString.unpackAppendCString# + GHC.Show.$fShowBool2 + (T21851_2.$s$wwombat (GHC.Prim.-# ds 1#) GHC.Types.True) + }; + 0# -> GHC.Types.[] @Char + } +end Rec } + +Rec { +-- RHS size: {terms: 16, types: 6, coercions: 0, joins: 0/0} +T21851_2.$w$sg [InlPrag=[2], Occ=LoopBreaker] + :: GHC.Prim.Int# -> (# GHC.Prim.Int#, String #) +[GblId, Arity=1, Str=, Unf=OtherCon []] +T21851_2.$w$sg + = \ (ww :: GHC.Prim.Int#) -> + case GHC.Prim.<# ww 10# of { + __DEFAULT -> T21851_2.$w$sg (GHC.Prim.-# ww 2#); + 1# -> (# 0#, T21851_2.$s$wwombat ww GHC.Types.True #) + } +end Rec } + +-- RHS size: {terms: 3, types: 3, coercions: 0, joins: 0/0} +lvl3 :: forall {a}. [Char] +[GblId] +lvl3 = \ (@a) -> T21851_2a.$wf GHC.Prim.(##) @a @Bool + +Rec { +-- RHS size: {terms: 27, types: 18, coercions: 0, joins: 0/0} +T21851_2.$wg [InlPrag=[2], Occ=LoopBreaker] + :: forall {a}. (Ord a, Num a) => a -> (# a, String #) +[GblId[StrictWorker([!])], + Arity=3, + Str=, + Unf=OtherCon []] +T21851_2.$wg + = \ (@a) ($dOrd :: Ord a) ($dNum :: Num a) (n :: a) -> + case < @a $dOrd n (fromInteger @a $dNum lvl2) of { + False -> + T21851_2.$wg + @a $dOrd $dNum (- @a $dNum n (fromInteger @a $dNum lvl)); + True -> (# fromInteger @a $dNum lvl1, lvl3 @a #) + } +end Rec } + +-- RHS size: {terms: 13, types: 16, coercions: 0, joins: 0/0} +g [InlPrag=[2]] :: forall a. (Ord a, Num a) => a -> (a, String) +[GblId, + Arity=3, + Str=, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) + Tmpl= \ (@a) + ($dOrd [Occ=Once1] :: Ord a) + ($dNum [Occ=Once1] :: Num a) + (n [Occ=Once1] :: a) -> + case T21851_2.$wg @a $dOrd $dNum n of + { (# ww [Occ=Once1], ww1 [Occ=Once1] #) -> + (ww, ww1) + }}] +g = \ (@a) ($dOrd :: Ord a) ($dNum :: Num a) (n :: a) -> + case T21851_2.$wg @a $dOrd $dNum n of { (# ww, ww1 #) -> + (ww, ww1) + } + +-- RHS size: {terms: 8, types: 9, coercions: 0, joins: 0/0} +h :: (Int, String) +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, + WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 50 10}] +h = case T21851_2.$w$sg 3# of { (# ww, ww1 #) -> + (GHC.Types.I# ww, ww1) + } + + +------ Local rules for imported ids -------- +"SPEC/T21851_2 $wwombat @Bool" [2] + forall ($dShow :: Show Bool). + T21851_2a.$wwombat @Bool $dShow + = T21851_2.$s$wwombat + + ===================================== testsuite/tests/simplCore/should_compile/T21851_2a.hs ===================================== @@ -0,0 +1,11 @@ +module T21851_2a where + +f :: (Num a, Show b) => a -> b -> String +{-# NOINLINE f #-} +f x y = "no" +{-# RULES "wombat" f = wombat #-} + +wombat :: Show b => Int -> b -> String +{-# INLINEABLE wombat #-} +wombat 0 y = "" +wombat n y = show y ++ wombat (n-1) y ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -442,3 +442,7 @@ test('T22357', normal, compile, ['-O']) # Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) test('T17366', normal, multimod_compile, ['T17366', '-O -v0 -ddump-rule-firings']) test('T17366_AR', [grep_errmsg(r'SPEC')], multimod_compile, ['T17366_AR', '-O -v0 -ddump-rule-firings']) + +# One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl +# Expecting to see $s$wwombat +test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90c5abd4581b404f715e72ad55303e18d0c31d68...399e921b05493d79f04e77806c1562806f118d4a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/90c5abd4581b404f715e72ad55303e18d0c31d68...399e921b05493d79f04e77806c1562806f118d4a You're receiving 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 Nov 11 02:16:26 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 10 Nov 2022 21:16:26 -0500 Subject: [Git][ghc/ghc][master] 2 commits: WorkWrap: Unboxing unboxed tuples is not always useful (#22388) Message-ID: <636db07ae3515_10da0554a241072238@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 8 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + testsuite/tests/stranal/should_compile/T22388.hs - + testsuite/tests/stranal/should_compile/T22388.stderr - testsuite/tests/stranal/should_compile/all.T - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1765,7 +1766,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1774,10 +1775,91 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Recall that unboxed tuples will be flattened to individual arguments during +unarisation. Here, `unboxed` will have 5 arguments at runtime because of the +nested unboxed tuple, which will be flattened to 4 args. So it's best to leave +`(a,b)` boxed (because we already are above our arg threshold), but unbox `c` +through `f` because that doesn't increase the number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. For example at the top-level, `(# x,y #)` is to be +treated just like two arguments `x` and `y`. +Of course, for that to work, our budget calculations must initialise +'max_wkr_args' to 5, based on the 'unariseArity' of each Core arg: That would be +1 for the pair and 4 for the unboxed pair. Then when we decide whether to unbox +the unboxed pair, we *directly* recurse into the fields, spending our budget +on retaining `c` and (after recursing once more) `d` through `f` as arguments, +depleting our budget completely in the first layer. Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1798,10 +1880,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets + +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1814,7 +1903,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1826,8 +1916,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1871,22 +1963,49 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg + -- The unboxed case does happen here, for example + -- app g x = g x :: (# Int, Int #) + -- here, `x` is used `L`azy and thus Boxed + + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- We currently don't return DoUnbox for unboxed sums. + -- But hopefully we will at some point. When that happens, + -- it would still be impossible to predict the effect + -- of dropping absent fields and unboxing others on the + -- unariseArity of the sum without losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) + where + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) -- "~": This match *must* be lazy! | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) - where - decremented_bg = MkB (bg_top-1) bg_inner add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , isGoodWorker, badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,23 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True - -isGoodWorker :: Bool -> Bool -isGoodWorker = id +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -826,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -843,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -855,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -875,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -887,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -895,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -910,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts - -> Var-> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> Var -> DataConPatContext Demand + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -939,13 +940,14 @@ unbox_one_arg opts arg_var -- See Note [Call-by-value for worker args] all_str_marks = (map (const NotMarkedStrict) ex_tvs') ++ con_str_marks - ; (_sub_args_quality, worker_args, wrap_fn, wrap_args) + ; (nested_useful, worker_args, wrap_fn, wrap_args) <- mkWWstr opts (ex_tvs' ++ arg_ids') all_str_marks ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co - - ; return (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } - -- Don't pass the arg, rebox instead + -- See Note [Unboxing through unboxed tuples] + ; return $ if isUnboxedTupleDataCon dc && not nested_useful + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1195,6 +1197,26 @@ fragile because `MkT` is strict in its Int# argument, so we get an absentError exception when we shouldn't. Very annoying! +Note [Unboxing through unboxed tuples] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We should not to a worker/wrapper split just for unboxing the components of +an unboxed tuple (in the result *or* argument, #22388). Consider + boring_res x y = (# y, x #) +It's entirely pointless to split for the constructed unboxed pair to + $wboring_res x y = (# y, x #) + boring_res = case $wboring_res x y of (# a, b #) -> (# a, b #) +`boring_res` will immediately simplify to an alias for `$wboring_res`! + +Similarly, the unboxed tuple might occur in argument position + boring_arg (# x, y, z #) = (# z, x, y #) +It's entirely pointless to "unbox" the triple + $wboring_arg x y z = (# z, x, y #) + boring_arg (# x, y, z #) = $wboring_arg x y z +because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. + +Conclusion: Only consider unboxing an unboxed tuple useful when we will +also unbox its components. That is governed by the `usefulSplit` mechanism. + ************************************************************************ * * Type scrutiny that is specific to demand analysis @@ -1376,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1398,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1411,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1441,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1467,11 +1489,10 @@ unbox_one_result opts res_bndr -- this_work_unbox_res alt = (case res_bndr |> co of C a b -> [a,b]) this_work_unbox_res = mkUnpackCase (Var res_bndr) co cprCaseBndrMult dc arg_ids - -- Don't try to WW an unboxed tuple return type when there's nothing inside - -- to unbox further. + -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== testsuite/tests/stranal/should_compile/T22388.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Unboxing through unboxed tuples] +module T22388 where + +-- Don't split, because neither the result not arg cancels away a box. +boring :: (# Int, Int, Int #) -> (# Int, Int, Int #) +boring (# x, y, z #) = (# y, z, x #) +{-# NOINLINE boring #-} + +-- Do split, because we get to drop z and pass x and y unboxed +interesting :: (# Int, Int, Int #) -> (# Int #) +interesting (# x, y, z #) = let !t = x + y in (# t #) +{-# NOINLINE interesting #-} ===================================== testsuite/tests/stranal/should_compile/T22388.stderr ===================================== @@ -0,0 +1,92 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 48, types: 81, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 8, types: 23, coercions: 0, joins: 0/0} +boring [InlPrag=NOINLINE] + :: (# Int, Int, Int #) -> (# Int, Int, Int #) +[GblId, Arity=1, Str=<1!P(L,L,L)>, Cpr=1, Unf=OtherCon []] +boring + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# x, y, z #) -> (# y, z, x #) } + +-- RHS size: {terms: 5, types: 2, coercions: 0, joins: 0/0} +T22388.$winteresting [InlPrag=NOINLINE] + :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=, Unf=OtherCon []] +T22388.$winteresting + = \ (ww :: GHC.Prim.Int#) (ww1 :: GHC.Prim.Int#) -> + GHC.Prim.+# ww ww1 + +-- RHS size: {terms: 18, types: 24, coercions: 0, joins: 0/0} +interesting [InlPrag=NOINLINE[final]] + :: (# Int, Int, Int #) -> (# Int #) +[GblId, + Arity=1, + Str=<1!P(1!P(L),1!P(L),A)>, + Cpr=1(1), + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (ds [Occ=Once1!] :: (# Int, Int, Int #)) -> + case ds of + { (# ww [Occ=Once1!], ww1 [Occ=Once1!], _ [Occ=Dead] #) -> + case ww of { GHC.Types.I# ww3 [Occ=Once1] -> + case ww1 of { GHC.Types.I# ww4 [Occ=Once1] -> + case T22388.$winteresting ww3 ww4 of ww5 [Occ=Once1] { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + }}] +interesting + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# ww, ww1, ww2 #) -> + case ww of { GHC.Types.I# ww3 -> + case ww1 of { GHC.Types.I# ww4 -> + case T22388.$winteresting ww3 ww4 of ww5 { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + } + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T22388.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule3 = GHC.Types.TrNameS T22388.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T22388.$trModule2 = "T22388"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule1 = GHC.Types.TrNameS T22388.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule + = GHC.Types.Module T22388.$trModule3 T22388.$trModule1 + + + ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -86,3 +86,5 @@ test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', ' test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) test('T22039', normal, compile, ['']) +# T22388: Should see $winteresting but not $wboring +test('T22388', [ grep_errmsg(r'^\S+\$w\S+') ], compile, ['-dsuppress-uniques -ddump-simpl']) ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,47 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} + +-- Point: Demand on `x` is lazy and thus Unboxed +app :: ((# Int, Int #) -> (# Int, Int #)) -> (# Int, Int #) -> (# Int, Int #) +app g x = g x ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.app: +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/399e921b05493d79f04e77806c1562806f118d4a...1230c2689db2e510b5a9b280c1a4eca832c23ccc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/399e921b05493d79f04e77806c1562806f118d4a...1230c2689db2e510b5a9b280c1a4eca832c23ccc You're receiving 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 Nov 11 02:46:55 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Thu, 10 Nov 2022 21:46:55 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 45 commits: WorkWrap: Unboxing unboxed tuples is not always useful (#22388) Message-ID: <636db79fb2fdb_10da05526ac10745e9@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 986da50b by Cheng Shao at 2022-11-10T21:46:47-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - 5977293a by Cheng Shao at 2022-11-10T21:46:47-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 28c54145 by Cheng Shao at 2022-11-10T21:46:47-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - c9b66591 by Cheng Shao at 2022-11-10T21:46:47-05:00 Fix Cmm symbol kind - - - - - 11334652 by Norman Ramsey at 2022-11-10T21:46:47-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 13723410 by Norman Ramsey at 2022-11-10T21:46:47-05:00 add new modules for reducibility and WebAssembly translation - - - - - e2b90391 by Cheng Shao at 2022-11-10T21:46:47-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 420dba20 by Cheng Shao at 2022-11-10T21:46:47-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 5987e0e1 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 1b27f82f by Cheng Shao at 2022-11-10T21:46:47-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - 7c803a9b by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 37faf4b0 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 299b3538 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 017c0675 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - be83d260 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - 1e1a9a94 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - 7517399d by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - e75578fa by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - bbd783a6 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - 785bb58c by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 53d8e303 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 94775ec3 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 383ab645 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - bd65aa20 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - dad65350 by Cheng Shao at 2022-11-10T21:46:47-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - 00b51fb4 by Cheng Shao at 2022-11-10T21:46:48-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - 0b656cf2 by Cheng Shao at 2022-11-10T21:46:48-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - 6ff6bd89 by Cheng Shao at 2022-11-10T21:46:48-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - aac4301a by Cheng Shao at 2022-11-10T21:46:48-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 386792be by Cheng Shao at 2022-11-10T21:46:48-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 215b2c84 by Cheng Shao at 2022-11-10T21:46:48-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 9ed49e35 by Cheng Shao at 2022-11-10T21:46:48-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - cda59b64 by Cheng Shao at 2022-11-10T21:46:48-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 83373ef0 by Cheng Shao at 2022-11-10T21:46:48-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 298e3d22 by Cheng Shao at 2022-11-10T21:46:48-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - da91d54f by Cheng Shao at 2022-11-10T21:46:48-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - 5892c6f2 by Cheng Shao at 2022-11-10T21:46:48-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - 876387b5 by Cheng Shao at 2022-11-10T21:46:48-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 0fa624fd by Cheng Shao at 2022-11-10T21:46:48-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - bc6f7bcc by Cheng Shao at 2022-11-10T21:46:48-05:00 ci: add wasm32-wasi release bindist job - - - - - 205c5ce4 by Cheng Shao at 2022-11-10T21:46:48-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 884b1a03 by Cheng Shao at 2022-11-10T21:46:48-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 573f92d9 by Zubin Duggal at 2022-11-10T21:46:48-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 25 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - + compiler/GHC/CmmToAsm/Wasm.hs - + compiler/GHC/CmmToAsm/Wasm/Asm.hs - + compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - + compiler/GHC/CmmToAsm/Wasm/Types.hs - + compiler/GHC/CmmToAsm/Wasm/Utils.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - + compiler/GHC/Data/Graph/Collapse.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5252c7f8ad22433c9b10d11907772c582e40f227...573f92d92b3ee7928c2e5fd46efc3e723be9bf64 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5252c7f8ad22433c9b10d11907772c582e40f227...573f92d92b3ee7928c2e5fd46efc3e723be9bf64 You're receiving 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 Nov 11 02:56:25 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Thu, 10 Nov 2022 21:56:25 -0500 Subject: [Git][ghc/ghc][wip/T22434] 6 commits: Fire RULES in the Specialiser Message-ID: <636db9d9a9e51_10da05526c010802d4@gitlab.mail> Krzysztof Gogolewski pushed to branch wip/T22434 at Glasgow Haskell Compiler / GHC Commits: f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 13b7c9ef by Simon Peyton Jones at 2022-11-11T03:41:37+01:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 29 changed files: - compiler/GHC/Core.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/Specialise.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Rules.hs - compiler/GHC/Driver/Config/Core/Opt/Simplify.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/Types/Id/Make.hs - compiler/GHC/Unit/External.hs - libraries/base/GHC/Ix.hs - libraries/base/GHC/Real.hs - testsuite/tests/simplCore/should_compile/T21851.stderr - + testsuite/tests/simplCore/should_compile/T21851_2.hs - + testsuite/tests/simplCore/should_compile/T21851_2.stderr - + testsuite/tests/simplCore/should_compile/T21851_2a.hs - testsuite/tests/simplCore/should_compile/all.T - + testsuite/tests/stranal/should_compile/T22388.hs - + testsuite/tests/stranal/should_compile/T22388.stderr - testsuite/tests/stranal/should_compile/all.T - + testsuite/tests/stranal/sigs/T21737.hs - + testsuite/tests/stranal/sigs/T21737.stderr - testsuite/tests/stranal/sigs/all.T Changes: ===================================== compiler/GHC/Core.hs ===================================== @@ -85,9 +85,8 @@ module GHC.Core ( IsOrphan(..), isOrphan, notOrphan, chooseOrphanAnchor, -- * Core rule data types - CoreRule(..), RuleBase, - RuleName, RuleFun, IdUnfoldingFun, InScopeEnv, - RuleEnv(..), RuleOpts, mkRuleEnv, emptyRuleEnv, + CoreRule(..), + RuleName, RuleFun, IdUnfoldingFun, InScopeEnv, RuleOpts, -- ** Operations on 'CoreRule's ruleArity, ruleName, ruleIdName, ruleActivation, @@ -105,7 +104,6 @@ import GHC.Core.Coercion import GHC.Core.Rules.Config ( RuleOpts ) import GHC.Types.Name import GHC.Types.Name.Set -import GHC.Types.Name.Env( NameEnv ) import GHC.Types.Literal import GHC.Types.Tickish import GHC.Core.DataCon @@ -1062,6 +1060,12 @@ has two major consequences M. But it's painful, because it means we need to keep track of all the orphan modules below us. + * The "visible orphan modules" are all the orphan module in the transitive + closure of the imports of this module. + + * During instance lookup, we filter orphan instances depending on + whether or not the instance is in a visible orphan module. + * A non-orphan is not finger-printed separately. Instead, for fingerprinting purposes it is treated as part of the entity it mentions on the LHS. For example @@ -1076,12 +1080,20 @@ has two major consequences Orphan-hood is computed * For class instances: - when we make a ClsInst - (because it is needed during instance lookup) + when we make a ClsInst in GHC.Core.InstEnv.mkLocalInstance + (because it is needed during instance lookup) + See Note [When exactly is an instance decl an orphan?] + in GHC.Core.InstEnv + + * For rules + when we generate a CoreRule (GHC.Core.Rules.mkRule) + + * For family instances: + when we generate an IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst) + +Orphan-hood is persisted into interface files, in ClsInst, FamInst, +and CoreRules. - * For rules and family instances: - when we generate an IfaceRule (GHC.Iface.Make.coreRuleToIfaceRule) - or IfaceFamInst (GHC.Iface.Make.instanceToIfaceInst) -} {- @@ -1096,49 +1108,6 @@ GHC.Core.FVs, GHC.Core.Subst, GHC.Core.Ppr, GHC.Core.Tidy also inspect the representation. -} --- | Gathers a collection of 'CoreRule's. Maps (the name of) an 'Id' to its rules -type RuleBase = NameEnv [CoreRule] - -- The rules are unordered; - -- we sort out any overlaps on lookup - --- | A full rule environment which we can apply rules from. Like a 'RuleBase', --- but it also includes the set of visible orphans we use to filter out orphan --- rules which are not visible (even though we can see them...) -data RuleEnv - = RuleEnv { re_base :: [RuleBase] -- See Note [Why re_base is a list] - , re_visible_orphs :: ModuleSet - } - -mkRuleEnv :: RuleBase -> [Module] -> RuleEnv -mkRuleEnv rules vis_orphs = RuleEnv [rules] (mkModuleSet vis_orphs) - -emptyRuleEnv :: RuleEnv -emptyRuleEnv = RuleEnv [] emptyModuleSet - -{- -Note [Why re_base is a list] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In Note [Overall plumbing for rules], it is explained that the final -RuleBase which we must consider is combined from 4 different sources. - -During simplifier runs, the fourth source of rules is constantly being updated -as new interfaces are loaded into the EPS. Therefore just before we check to see -if any rules match we get the EPS RuleBase and combine it with the existing RuleBase -and then perform exactly 1 lookup into the new map. - -It is more efficient to avoid combining the environments and store the uncombined -environments as we can instead perform 1 lookup into each environment and then combine -the results. - -Essentially we use the identity: - -> lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) -> = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 - -The latter being more efficient as we don't construct an intermediate -map. --} -- | A 'CoreRule' is: -- ===================================== compiler/GHC/Core/InstEnv.hs ===================================== @@ -323,7 +323,9 @@ mkImportedInstance cls_nm mb_tcs dfun_name dfun oflag orphan {- Note [When exactly is an instance decl an orphan?] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - (see GHC.Iface.Make.instanceToIfaceInst, which implements this) +(See GHC.Iface.Make.instanceToIfaceInst, which implements this.) +See Note [Orphans] in GHC.Core + Roughly speaking, an instance is an orphan if its head (after the =>) mentions nothing defined in this module. ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -45,6 +45,7 @@ import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set import GHC.Types.Unique.MemoFun +import GHC.Types.RepType {- @@ -1520,6 +1521,9 @@ $wtheresCrud = \ ww ww1 -> ... ``` This is currently a bug that we willingly accept and it's documented in #21128. + +See also Note [indexError] in base:GHC.Ix, which describes how we use +SPECIALISE to mitigate this problem for indexError. -} {- ********************************************************************* @@ -1762,7 +1766,7 @@ Note [Worker argument budget] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 'finaliseArgBoxities' we don't want to generate workers with zillions of argument when, say given a strict record with zillions of fields. So we -limit the maximum number of worker args to the maximum of +limit the maximum number of worker args ('max_wkr_args') to the maximum of - -fmax-worker-args=N - The number of args in the original function; if it already has has zillions of arguments we don't want to seek /fewer/ args in the worker. @@ -1771,10 +1775,91 @@ limit the maximum number of worker args to the maximum of We pursue a "layered" strategy for unboxing: we unbox the top level of the argument(s), subject to budget; if there are any arguments left we unbox the next layer, using that depleted budget. +Unboxing an argument *increases* the budget for the inner layer roughly +according to how many registers that argument takes (unboxed tuples take +multiple registers, see below), as determined by 'unariseArity'. +Budget is spent when we have to pass a non-absent field as a parameter. To achieve this, we use the classic almost-circular programming technique in which we we write one pass that takes a lazy list of the Budgets for every -layer. +layer. The effect is that of a breadth-first search (over argument type and +demand structure) to compute Budgets followed by a depth-first search to +construct the product demands, but laziness allows us to do it all in one +pass and without intermediate data structures. + +Suppose we have -fmax-worker-args=4 for the remainder of this Note. +Then consider this example function: + + boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int + boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f + +With a budget of 4 args to spend (number of args is only 2), we'd be served well +to unbox both pairs, but not the triple. Indeed, that is what the algorithm +computes, and the following pictogram shows how the budget layers are computed. +Each layer is started with `n ~>`, where `n` is the budget at the start of the +layer. We write -n~> when we spend budget (and n is the remaining budget) and ++n~> when we earn budget. We separate unboxed args with ][ and indicate +inner budget threads becoming negative in braces {{}}, so that we see which +unboxing decision we do *not* commit to. Without further ado: + + 4 ~> ][ (a,b) -3~> ][ (c, ...) -2~> + ][ | | ][ | | + ][ | +-------------+ ][ | +-----------------+ + ][ | | ][ | | + ][ v v ][ v v + 2 ~> ][ +3~> a -2~> ][ b -1~> ][ +2~> c -1~> ][ (d, e, f) -0~> + ][ | ][ | ][ | ][ {{ | | | }} + ][ | ][ | ][ | ][ {{ | | +----------------+ }} + ][ v ][ v ][ v ][ {{ v +------v v }} + 0 ~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ {{ +1~> d -0~> ][ e -(-1)~> ][ f -(-2)~> }} + +Unboxing increments the budget we have on the next layer (because we don't need +to retain the boxed arg), but in turn the inner layer must afford to retain all +non-absent fields, each decrementing the budget. Note how the budget becomes +negative when trying to unbox the triple and the unboxing decision is "rolled +back". This is done by the 'positiveTopBudget' guard. + +There's a bit of complication as a result of handling unboxed tuples correctly; +specifically, handling nested unboxed tuples. Consider (#21737) + + unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int + unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f + +Recall that unboxed tuples will be flattened to individual arguments during +unarisation. Here, `unboxed` will have 5 arguments at runtime because of the +nested unboxed tuple, which will be flattened to 4 args. So it's best to leave +`(a,b)` boxed (because we already are above our arg threshold), but unbox `c` +through `f` because that doesn't increase the number of args post unarisation. + +Note that the challenge is that syntactically, `(# d, e, f #)` occurs in a +deeper layer than `(a, b)`. Treating unboxed tuples as a regular data type, we'd +make the same unboxing decisions as for `boxed` above; although our starting +budget is 5 (Here, the number of args is greater than -fmax-worker-args), it's +not enough to unbox the triple (we'd finish with budget -1). So we'd unbox `a` +through `c`, but not `d` through `f`, which is silly, because then we'd end up +having 6 arguments at runtime, of which `d` through `f` weren't unboxed. + +Hence we pretend that the fields of unboxed tuples appear in the same budget +layer as the tuple itself. For example at the top-level, `(# x,y #)` is to be +treated just like two arguments `x` and `y`. +Of course, for that to work, our budget calculations must initialise +'max_wkr_args' to 5, based on the 'unariseArity' of each Core arg: That would be +1 for the pair and 4 for the unboxed pair. Then when we decide whether to unbox +the unboxed pair, we *directly* recurse into the fields, spending our budget +on retaining `c` and (after recursing once more) `d` through `f` as arguments, +depleting our budget completely in the first layer. Pictorially: + + 5 ~> ][ (a,b) -4~> ][ (# c, ... #) + ][ {{ | | }} ][ c -3~> ][ (# d, e, f #) + ][ {{ | +-------+ }} ][ | ][ d -2~> ][ e -1~> ][ f -0~> + ][ {{ | | }} ][ | ][ | ][ | ][ | + ][ {{ v v }} ][ v ][ v ][ v ][ v + 0 ~> ][ {{ +1~> a -0~> ][ b -(-1)~> }} ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> ][ +1~> I# -0~> + +As you can see, we have no budget left to justify unboxing `(a,b)` on the second +layer, which is good, because it would increase the number of args. Also note +that we can still unbox `c` through `f` in this layer, because doing so has a +net zero effect on budget. Note [The OPAQUE pragma and avoiding the reboxing of arguments] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1795,10 +1880,17 @@ W/W-transformation code that boxed arguments of 'f' must definitely be passed along in boxed form and as such dissuade the creation of reboxing workers. -} -data Budgets = MkB Arity Budgets -- An infinite list of arity budgets +-- | How many registers does this type take after unarisation? +unariseArity :: Type -> Arity +unariseArity ty = length (typePrimRep ty) + +data Budgets = MkB !Arity Budgets -- An infinite list of arity budgets -incTopBudget :: Budgets -> Budgets -incTopBudget (MkB n bg) = MkB (n+1) bg +earnTopBudget :: Budgets -> Budgets +earnTopBudget (MkB n bg) = MkB (n+1) bg + +spendTopBudget :: Arity -> Budgets -> Budgets +spendTopBudget m (MkB n bg) = MkB (n-m) bg positiveTopBudget :: Budgets -> Bool positiveTopBudget (MkB n _) = n >= 0 @@ -1811,7 +1903,8 @@ finaliseArgBoxities env fn arity rhs div -- Then there are no binders; we don't worker/wrapper; and we -- simply want to give f the same demand signature as g - | otherwise + | otherwise -- NB: arity is the threshold_arity, which might be less than + -- manifest arity for join points = -- pprTrace "finaliseArgBoxities" ( -- vcat [text "function:" <+> ppr fn -- , text "dmds before:" <+> ppr (map idDemandInfo (filter isId bndrs)) @@ -1823,8 +1916,10 @@ finaliseArgBoxities env fn arity rhs div where opts = ae_opts env (bndrs, _body) = collectBinders rhs - max_wkr_args = dmd_max_worker_args opts `max` arity - -- See Note [Worker argument budget] + unarise_arity = sum [ unariseArity (idType b) | b <- bndrs, isId b ] + max_wkr_args = dmd_max_worker_args opts `max` unarise_arity + -- This is the budget initialisation step of + -- Note [Worker argument budget] -- This is the key line, which uses almost-circular programming -- The remaining budget from one layer becomes the initial @@ -1868,22 +1963,49 @@ finaliseArgBoxities env fn arity rhs div = case wantToUnboxArg env ty str_mark dmd of DropAbsent -> (bg, dmd) - DontUnbox | is_bot_fn, isTyVarTy ty -> (decremented_bg, dmd) - | otherwise -> (decremented_bg, trimBoxity dmd) + DontUnbox | is_bot_fn, isTyVarTy ty -> (retain_budget, dmd) + | otherwise -> (retain_budget, trimBoxity dmd) -- If bot: Keep deep boxity even though WW won't unbox -- See Note [Boxity for bottoming functions] case (A) -- trimBoxity: see Note [No lazy, Unboxed demands in demand signature] - - DoUnbox triples -> (MkB (bg_top-1) final_bg_inner, final_dmd) where - (bg_inner', dmds') = go_args (incTopBudget bg_inner) triples - -- incTopBudget: give one back for the arg we are unboxing + retain_budget = spendTopBudget (unariseArity ty) bg + -- spendTopBudget: spend from our budget the cost of the + -- retaining the arg + -- The unboxed case does happen here, for example + -- app g x = g x :: (# Int, Int #) + -- here, `x` is used `L`azy and thus Boxed + + DoUnbox triples + | isUnboxedTupleType ty + , (bg', dmds') <- go_args bg triples + -> (bg', n :* (mkProd Unboxed $! dmds')) + -- See Note [Worker argument budget] + -- unboxed tuples are always unboxed, deeply + -- NB: Recurse with bg, *not* bg_inner! The unboxed fields + -- are at the same budget layer. + + | isUnboxedSumType ty + -> pprPanic "Unboxing through unboxed sum" (ppr fn <+> ppr ty) + -- We currently don't return DoUnbox for unboxed sums. + -- But hopefully we will at some point. When that happens, + -- it would still be impossible to predict the effect + -- of dropping absent fields and unboxing others on the + -- unariseArity of the sum without losing sanity. + -- We could overwrite bg_top with the one from + -- retain_budget while still unboxing inside the alts as in + -- the tuple case for a conservative solution, though. + + | otherwise + -> (spendTopBudget 1 (MkB bg_top final_bg_inner), final_dmd) + where + (bg_inner', dmds') = go_args (earnTopBudget bg_inner) triples + -- earnTopBudget: give back the cost of retaining the + -- arg we are insted unboxing. dmd' = n :* (mkProd Unboxed $! dmds') - (final_bg_inner, final_dmd) + ~(final_bg_inner, final_dmd) -- "~": This match *must* be lazy! | positiveTopBudget bg_inner' = (bg_inner', dmd') | otherwise = (bg_inner, trimBoxity dmd) - where - decremented_bg = MkB (bg_top-1) bg_inner add_demands :: [Demand] -> CoreExpr -> CoreExpr -- Attach the demands to the outer lambdas of this expression ===================================== compiler/GHC/Core/Opt/Monad.hs ===================================== @@ -19,10 +19,10 @@ module GHC.Core.Opt.Monad ( -- ** Reading from the monad getHscEnv, getModule, - getRuleBase, getExternalRuleBase, + initRuleEnv, getExternalRuleBase, getDynFlags, getPackageFamInstEnv, getInteractiveContext, - getVisibleOrphanMods, getUniqMask, + getUniqMask, getPrintUnqualified, getSrcSpanM, -- ** Writing to the monad @@ -45,7 +45,7 @@ import GHC.Prelude hiding ( read ) import GHC.Driver.Session import GHC.Driver.Env -import GHC.Core +import GHC.Core.Rules ( RuleBase, RuleEnv, mkRuleEnv ) import GHC.Core.Opt.Stats ( SimplCount, zeroSimplCount, plusSimplCount ) import GHC.Types.Annotations @@ -114,12 +114,11 @@ pprFloatOutSwitches sw data CoreReader = CoreReader { cr_hsc_env :: HscEnv, - cr_rule_base :: RuleBase, + cr_rule_base :: RuleBase, -- Home package table rules cr_module :: Module, cr_print_unqual :: PrintUnqualified, cr_loc :: SrcSpan, -- Use this for log/error messages so they -- are at least tagged with the right source file - cr_visible_orphan_mods :: !ModuleSet, cr_uniq_mask :: !Char -- Mask for creating unique values } @@ -181,19 +180,17 @@ runCoreM :: HscEnv -> RuleBase -> Char -- ^ Mask -> Module - -> ModuleSet -> PrintUnqualified -> SrcSpan -> CoreM a -> IO (a, SimplCount) -runCoreM hsc_env rule_base mask mod orph_imps print_unqual loc m +runCoreM hsc_env rule_base mask mod print_unqual loc m = liftM extract $ runIOEnv reader $ unCoreM m where reader = CoreReader { cr_hsc_env = hsc_env, cr_rule_base = rule_base, cr_module = mod, - cr_visible_orphan_mods = orph_imps, cr_print_unqual = print_unqual, cr_loc = loc, cr_uniq_mask = mask @@ -245,15 +242,18 @@ liftIOWithCount what = liftIO what >>= (\(count, x) -> addSimplCount count >> re getHscEnv :: CoreM HscEnv getHscEnv = read cr_hsc_env -getRuleBase :: CoreM RuleBase -getRuleBase = read cr_rule_base +getHomeRuleBase :: CoreM RuleBase +getHomeRuleBase = read cr_rule_base + +initRuleEnv :: ModGuts -> CoreM RuleEnv +initRuleEnv guts + = do { hpt_rules <- getHomeRuleBase + ; eps_rules <- getExternalRuleBase + ; return (mkRuleEnv guts eps_rules hpt_rules) } getExternalRuleBase :: CoreM RuleBase getExternalRuleBase = eps_rule_base <$> get_eps -getVisibleOrphanMods :: CoreM ModuleSet -getVisibleOrphanMods = read cr_visible_orphan_mods - getPrintUnqualified :: CoreM PrintUnqualified getPrintUnqualified = read cr_print_unqual ===================================== compiler/GHC/Core/Opt/Pipeline.hs ===================================== @@ -22,7 +22,7 @@ import GHC.Platform.Ways ( hasWay, Way(WayProf) ) import GHC.Core import GHC.Core.Opt.CSE ( cseProgram ) -import GHC.Core.Rules ( mkRuleBase, ruleCheckProgram, getRules ) +import GHC.Core.Rules ( RuleBase, mkRuleBase, ruleCheckProgram, getRules ) import GHC.Core.Ppr ( pprCoreBindings ) import GHC.Core.Utils ( dumpIdInfoOfProgram ) import GHC.Core.Lint ( lintAnnots ) @@ -53,9 +53,7 @@ import GHC.Utils.Logger as Logger import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Unit.Module.Env import GHC.Unit.Module.ModGuts -import GHC.Unit.Module.Deps import GHC.Types.Id.Info import GHC.Types.Basic @@ -78,14 +76,12 @@ import GHC.Unit.Module core2core :: HscEnv -> ModGuts -> IO ModGuts core2core hsc_env guts@(ModGuts { mg_module = mod , mg_loc = loc - , mg_deps = deps , mg_rdr_env = rdr_env }) = do { let builtin_passes = getCoreToDo dflags hpt_rule_base extra_vars - orph_mods = mkModuleSet (mod : dep_orphs deps) uniq_mask = 's' - ; + ; (guts2, stats) <- runCoreM hsc_env hpt_rule_base uniq_mask mod - orph_mods print_unqual loc $ + print_unqual loc $ do { hsc_env' <- getHscEnv ; all_passes <- withPlugins (hsc_plugins hsc_env') installCoreToDos @@ -121,7 +117,8 @@ core2core hsc_env guts@(ModGuts { mg_module = mod -} getCoreToDo :: DynFlags -> RuleBase -> [Var] -> [CoreToDo] -getCoreToDo dflags rule_base extra_vars +-- This function builds the pipeline of optimisations +getCoreToDo dflags hpt_rule_base extra_vars = flatten_todos core_todo where phases = simplPhases dflags @@ -176,7 +173,7 @@ getCoreToDo dflags rule_base extra_vars ---------------------------- run_simplifier mode iter - = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode rule_base + = CoreDoSimplify $ initSimplifyOpts dflags extra_vars iter mode hpt_rule_base simpl_phase phase name iter = CoreDoPasses $ [ maybe_strictness_before phase @@ -573,11 +570,9 @@ ruleCheckPass current_phase pat guts = do logger <- getLogger withTiming logger (text "RuleCheck"<+>brackets (ppr $ mg_module guts)) (const ()) $ do - rb <- getRuleBase - vis_orphs <- getVisibleOrphanMods - let rule_fn fn = getRules (RuleEnv [rb] vis_orphs) fn - ++ (mg_rules guts) - let ropts = initRuleOpts dflags + rule_env <- initRuleEnv guts + let rule_fn fn = getRules rule_env fn + ropts = initRuleOpts dflags liftIO $ logDumpMsg logger "Rule check" (ruleCheckProgram ropts current_phase pat rule_fn (mg_binds guts)) ===================================== compiler/GHC/Core/Opt/Simplify.hs ===================================== @@ -10,7 +10,7 @@ import GHC.Prelude import GHC.Driver.Flags import GHC.Core -import GHC.Core.Rules ( extendRuleBaseList, extendRuleEnv, addRuleInfo ) +import GHC.Core.Rules import GHC.Core.Ppr ( pprCoreBindings, pprCoreExpr ) import GHC.Core.Opt.OccurAnal ( occurAnalysePgm, occurAnalyseExpr ) import GHC.Core.Stats ( coreBindsSize, coreBindsStats, exprSize ) @@ -31,7 +31,6 @@ import GHC.Utils.Constants (debugIsOn) import GHC.Unit.Env ( UnitEnv, ueEPS ) import GHC.Unit.External import GHC.Unit.Module.ModGuts -import GHC.Unit.Module.Deps import GHC.Types.Id import GHC.Types.Id.Info @@ -81,7 +80,7 @@ simplifyExpr logger euc opts expr simpl_env = mkSimplEnv (se_mode opts) fam_envs top_env_cfg = se_top_env_cfg opts read_eps_rules = eps_rule_base <$> eucEPS euc - read_ruleenv = extendRuleEnv emptyRuleEnv <$> read_eps_rules + read_ruleenv = updExternalPackageRules emptyRuleEnv <$> read_eps_rules ; let sz = exprSize expr @@ -132,11 +131,11 @@ simplExprGently env expr = do -- The values of this datatype are /only/ driven by the demands of that function. data SimplifyOpts = SimplifyOpts { so_dump_core_sizes :: !Bool - , so_iterations :: !Int - , so_mode :: !SimplMode + , so_iterations :: !Int + , so_mode :: !SimplMode , so_pass_result_cfg :: !(Maybe LintPassResultConfig) - , so_rule_base :: !RuleBase - , so_top_env_cfg :: !TopEnvConfig + , so_hpt_rules :: !RuleBase + , so_top_env_cfg :: !TopEnvConfig } simplifyPgm :: Logger @@ -148,11 +147,10 @@ simplifyPgm :: Logger simplifyPgm logger unit_env opts guts@(ModGuts { mg_module = this_mod , mg_rdr_env = rdr_env - , mg_deps = deps - , mg_binds = binds, mg_rules = rules + , mg_binds = binds, mg_rules = local_rules , mg_fam_inst_env = fam_inst_env }) = do { (termination_msg, it_count, counts_out, guts') - <- do_iteration 1 [] binds rules + <- do_iteration 1 [] binds local_rules ; when (logHasDumpFlag logger Opt_D_verbose_core2core && logHasDumpFlag logger Opt_D_dump_simpl_stats) $ @@ -169,7 +167,6 @@ simplifyPgm logger unit_env opts dump_core_sizes = so_dump_core_sizes opts mode = so_mode opts max_iterations = so_iterations opts - hpt_rule_base = so_rule_base opts top_env_cfg = so_top_env_cfg opts print_unqual = mkPrintUnqualified unit_env rdr_env active_rule = activeRule mode @@ -178,13 +175,18 @@ simplifyPgm logger unit_env opts -- the old bindings are retained until the end of all simplifier iterations !guts_no_binds = guts { mg_binds = [], mg_rules = [] } + hpt_rule_env :: RuleEnv + hpt_rule_env = mkRuleEnv guts emptyRuleBase (so_hpt_rules opts) + -- emptyRuleBase: no EPS rules yet; we will update + -- them on each iteration to pick up the most up to date set + do_iteration :: Int -- Counts iterations -> [SimplCount] -- Counts from earlier iterations, reversed - -> CoreProgram -- Bindings in - -> [CoreRule] -- and orphan rules + -> CoreProgram -- Bindings + -> [CoreRule] -- Local rules for imported Ids -> IO (String, Int, SimplCount, ModGuts) - do_iteration iteration_no counts_so_far binds rules + do_iteration iteration_no counts_so_far binds local_rules -- iteration_no is the number of the iteration we are -- about to begin, with '1' for the first | iteration_no > max_iterations -- Stop if we've run out of iterations @@ -200,7 +202,7 @@ simplifyPgm logger unit_env opts -- number of iterations we actually completed return ( "Simplifier baled out", iteration_no - 1 , totalise counts_so_far - , guts_no_binds { mg_binds = binds, mg_rules = rules } ) + , guts_no_binds { mg_binds = binds, mg_rules = local_rules } ) -- Try and force thunks off the binds; significantly reduces -- space usage, especially with -O. JRS, 000620. @@ -209,8 +211,8 @@ simplifyPgm logger unit_env opts = do { -- Occurrence analysis let { tagged_binds = {-# SCC "OccAnal" #-} - occurAnalysePgm this_mod active_unf active_rule rules - binds + occurAnalysePgm this_mod active_unf active_rule + local_rules binds } ; Logger.putDumpFileMaybe logger Opt_D_dump_occur_anal "Occurrence analysis" FormatCore @@ -221,24 +223,29 @@ simplifyPgm logger unit_env opts -- poke on IdInfo thunks, which in turn brings in new rules -- behind the scenes. Otherwise there's a danger we'll simply -- miss the rules for Ids hidden inside imported inlinings - -- Hence just before attempting to match rules we read on the EPS - -- value and then combine it when the existing rule base. + -- Hence just before attempting to match a rule we read the EPS + -- value (via read_rule_env) and then combine it with the existing rule base. -- See `GHC.Core.Opt.Simplify.Monad.getSimplRules`. - eps <- ueEPS unit_env ; - let { -- Forcing this value to avoid unnessecary allocations. + eps <- ueEPS unit_env ; + let { -- base_rule_env contains + -- (a) home package rules, fixed across all iterations + -- (b) local rules (substituted) from `local_rules` arg to do_iteration + -- Forcing base_rule_env to avoid unnecessary allocations. -- Not doing so results in +25.6% allocations of LargeRecord. - ; !rule_base = extendRuleBaseList hpt_rule_base rules - ; vis_orphs = this_mod : dep_orphs deps - ; base_ruleenv = mkRuleEnv rule_base vis_orphs + ; !base_rule_env = updLocalRules hpt_rule_env local_rules + + ; read_eps_rules :: IO PackageRuleBase ; read_eps_rules = eps_rule_base <$> ueEPS unit_env - ; read_ruleenv = extendRuleEnv base_ruleenv <$> read_eps_rules + + ; read_rule_env :: IO RuleEnv + ; read_rule_env = updExternalPackageRules base_rule_env <$> read_eps_rules ; fam_envs = (eps_fam_inst_env eps, fam_inst_env) ; simpl_env = mkSimplEnv mode fam_envs } ; -- Simplify the program ((binds1, rules1), counts1) <- - initSmpl logger read_ruleenv top_env_cfg sz $ + initSmpl logger read_rule_env top_env_cfg sz $ do { (floats, env1) <- {-# SCC "SimplTopBinds" #-} simplTopBinds simpl_env tagged_binds @@ -246,7 +253,7 @@ simplifyPgm logger unit_env opts -- for imported Ids. Eg RULE map my_f = blah -- If we have a substitution my_f :-> other_f, we'd better -- apply it to the rule to, or it'll never match - ; rules1 <- simplImpRules env1 rules + ; rules1 <- simplImpRules env1 local_rules ; return (getTopFloatBinds floats, rules1) } ; ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1497,9 +1497,10 @@ rebuild env expr cont ApplyToTy { sc_arg_ty = ty, sc_cont = cont} -> rebuild env (App expr (Type ty)) cont - ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag, sc_cont = cont} + ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag + , sc_cont = cont, sc_hole_ty = fun_ty } -- See Note [Avoid redundant simplification] - -> do { (_, _, arg') <- simplArg env dup_flag se arg + -> do { (_, _, arg') <- simplArg env dup_flag fun_ty se arg ; rebuild env (App expr arg') cont } completeBindX :: SimplEnv @@ -1598,7 +1599,8 @@ 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_dup = dup, sc_cont = tail + , sc_hole_ty = fun_ty }) | Just (m_co1, m_co2) <- pushCoValArg co , fixed_rep m_co1 = {-#SCC "addCoerce-pushCoValArg" #-} @@ -1610,7 +1612,7 @@ simplCast env body co0 cont0 -- See Note [Avoiding exponential behaviour] MCo co1 -> - do { (dup', arg_se', arg') <- simplArg env dup arg_se arg + do { (dup', arg_se', arg') <- simplArg env dup fun_ty arg_se arg -- When we build the ApplyTo we can't mix the OutCoercion -- 'co' with the InExpr 'arg', so we simplify -- to make it all consistent. It's a bit messy. @@ -1636,14 +1638,16 @@ simplCast env body co0 cont0 -- See Note [Representation polymorphism invariants] in GHC.Core -- test: typecheck/should_run/EtaExpandLevPoly -simplArg :: SimplEnv -> DupFlag -> StaticEnv -> CoreExpr +simplArg :: SimplEnv -> DupFlag + -> OutType -- Type of the function applied to this arg + -> StaticEnv -> CoreExpr -- Expression with its static envt -> SimplM (DupFlag, StaticEnv, OutExpr) -simplArg env dup_flag arg_env arg +simplArg env dup_flag fun_ty arg_env arg | isSimplified dup_flag = return (dup_flag, arg_env, arg) | otherwise = do { let arg_env' = arg_env `setInScopeFromE` env - ; arg' <- simplExpr arg_env' arg + ; arg' <- simplExprC arg_env' arg (mkBoringStop (funArgTy fun_ty)) ; return (Simplified, zapSubstEnv arg_env', arg') } -- Return a StaticEnv that includes the in-scope set from 'env', -- because arg' may well mention those variables (#20639) @@ -2029,6 +2033,21 @@ zap the SubstEnv. This is VITAL. Consider We'll clone the inner \x, adding x->x' in the id_subst Then when we inline y, we must *not* replace x by x' in the inlined copy!! + +Note [Fast path for data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For applications of a data constructor worker, the full glory of +rebuildCall is a waste of effort; +* They never inline, obviously +* They have no rewrite rules +* They are not strict (see Note [Data-con worker strictness] + in GHC.Core.DataCon) +So it's fine to zoom straight to `rebuild` which just rebuilds the +call in a very straightforward way. + +Some programs have a /lot/ of data constructors in the source program +(compiler/perf/T9961 is an example), so this fast path can be very +valuable. -} simplVar :: SimplEnv -> InVar -> SimplM OutExpr @@ -2046,6 +2065,9 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont + | isDataConWorkId var -- See Note [Fast path for data constructors] + = rebuild env (Var var) cont + | otherwise = case substId env var of ContEx tvs cvs ids e -> simplExprF env' e cont -- Don't trimJoinCont; haven't already simplified e, @@ -2315,6 +2337,8 @@ field of the ArgInfo record is the state of a little state-machine: If we inline `f` before simplifying `BIG` well use preInlineUnconditionally, and we'll simplify BIG once, at x's occurrence, rather than twice. +* GHC.Core.Opt.Simplify.Utils. mkRewriteCall: if there are no rules, and no + unfolding, we can skip both TryRules and TryInlining, which saves work. Note [Avoid redundant simplification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3645,7 +3669,7 @@ mkDupableContWithDmds env dmds do { let (dmd:cont_dmds) = dmds -- Never fails ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 - ; (_, se', arg') <- simplArg env' dup se arg + ; (_, se', arg') <- simplArg env' dup hole_ty se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ; let all_floats = floats1 `addLetFloats` let_floats2 ; return ( all_floats ===================================== compiler/GHC/Core/Opt/Simplify/Monad.hs ===================================== @@ -27,8 +27,8 @@ import GHC.Types.Name ( mkSystemVarName ) import GHC.Types.Id ( Id, mkSysLocalOrCoVarM ) import GHC.Types.Id.Info ( IdDetails(..), vanillaIdInfo, setArityInfo ) import GHC.Core.Type ( Type, Mult ) -import GHC.Core ( RuleEnv(..) ) import GHC.Core.Opt.Stats +import GHC.Core.Rules import GHC.Core.Utils ( mkLamTypes ) import GHC.Types.Unique.Supply import GHC.Driver.Flags ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -53,7 +53,7 @@ import GHC.Core.Ppr import GHC.Core.TyCo.Ppr ( pprParendType ) import GHC.Core.FVs import GHC.Core.Utils -import GHC.Core.Rules( getRules ) +import GHC.Core.Rules( RuleEnv, getRules ) import GHC.Core.Opt.Arity import GHC.Core.Unfold import GHC.Core.Unfold.Make @@ -425,12 +425,22 @@ decArgCount :: RewriteCall -> RewriteCall decArgCount (TryRules n rules) = TryRules (n-1) rules decArgCount rew = rew -mkTryRules :: [CoreRule] -> RewriteCall +mkRewriteCall :: Id -> RuleEnv -> RewriteCall -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration -mkTryRules [] = TryInlining -mkTryRules rs = TryRules n_required rs +-- We try to skip any unnecessary stages: +-- No rules => skip TryRules +-- No unfolding => skip TryInlining +-- This skipping is "just" for efficiency. But rebuildCall is +-- quite a heavy hammer, so skipping stages is a good plan. +-- And it's extremely simple to do. +mkRewriteCall fun rule_env + | not (null rules) = TryRules n_required rules + | canUnfold unf = TryInlining + | otherwise = TryNothing where - n_required = maximum (map ruleArity rs) + n_required = maximum (map ruleArity rules) + rules = getRules rule_env fun + unf = idUnfolding fun {- ************************************************************************ @@ -604,21 +614,23 @@ mkArgInfo :: SimplEnv -> RuleEnv -> Id -> SimplCont -> ArgInfo mkArgInfo env rule_base fun cont | n_val_args < idArity fun -- Note [Unsaturated functions] = ArgInfo { ai_fun = fun, ai_args = [] - , ai_rewrite = fun_rules + , ai_rewrite = fun_rewrite , ai_encl = False , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise = ArgInfo { ai_fun = fun , ai_args = [] - , ai_rewrite = fun_rules - , ai_encl = notNull rules || contHasRules cont + , ai_rewrite = fun_rewrite + , ai_encl = fun_has_rules || contHasRules cont , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where - rules = getRules rule_base fun - fun_rules = mkTryRules rules - n_val_args = countValArgs cont + n_val_args = countValArgs cont + fun_rewrite = mkRewriteCall fun rule_base + fun_has_rules = case fun_rewrite of + TryRules {} -> True + _ -> False vanilla_discounts, arg_discounts :: [Int] vanilla_discounts = repeat 0 ===================================== compiler/GHC/Core/Opt/Specialise.hs ===================================== @@ -17,6 +17,7 @@ import GHC.Driver.Config.Core.Rules ( initRuleOpts ) import GHC.Core.Type hiding( substTy, substCo, extendTvSubst, zapSubst ) import GHC.Core.Multiplicity +import GHC.Core.SimpleOpt( defaultSimpleOpts, simpleOptExprWith ) import GHC.Core.Predicate import GHC.Core.Coercion( Coercion ) import GHC.Core.Opt.Monad @@ -636,9 +637,11 @@ Hence, the invariant is this: -- | Specialise calls to type-class overloaded functions occurring in a program. specProgram :: ModGuts -> CoreM ModGuts specProgram guts@(ModGuts { mg_module = this_mod - , mg_rules = local_rules - , mg_binds = binds }) - = do { dflags <- getDynFlags + , mg_rules = local_rules + , mg_binds = binds }) + = do { dflags <- getDynFlags + ; rule_env <- initRuleEnv guts + -- See Note [Fire rules in the specialiser] -- We need to start with a Subst that knows all the things -- that are in scope, so that the substitution engine doesn't @@ -650,6 +653,7 @@ specProgram guts@(ModGuts { mg_module = this_mod -- mkInScopeSetList $ -- bindersOfBinds binds , se_module = this_mod + , se_rules = rule_env , se_dflags = dflags } go [] = return ([], emptyUDs) @@ -660,7 +664,7 @@ specProgram guts@(ModGuts { mg_module = this_mod -- Specialise the bindings of this module ; (binds', uds) <- runSpecM (go binds) - ; (spec_rules, spec_binds) <- specImports top_env local_rules uds + ; (spec_rules, spec_binds) <- specImports top_env uds ; return (guts { mg_binds = spec_binds ++ binds' , mg_rules = spec_rules ++ local_rules }) } @@ -725,21 +729,15 @@ specialisation (see canSpecImport): -} specImports :: SpecEnv - -> [CoreRule] -> UsageDetails -> CoreM ([CoreRule], [CoreBind]) -specImports top_env local_rules - (MkUD { ud_binds = dict_binds, ud_calls = calls }) +specImports top_env (MkUD { ud_binds = dict_binds, ud_calls = calls }) | not $ gopt Opt_CrossModuleSpecialise (se_dflags top_env) -- See Note [Disabling cross-module specialisation] = return ([], wrapDictBinds dict_binds []) | otherwise - = do { hpt_rules <- getRuleBase - ; let rule_base = extendRuleBaseList hpt_rules local_rules - - ; (spec_rules, spec_binds) <- spec_imports top_env [] rule_base - dict_binds calls + = do { (_env, spec_rules, spec_binds) <- spec_imports top_env [] dict_binds calls -- Don't forget to wrap the specialized bindings with -- bindings for the needed dictionaries. @@ -757,89 +755,91 @@ specImports top_env local_rules spec_imports :: SpecEnv -- Passed in so that all top-level Ids are in scope -> [Id] -- Stack of imported functions being specialised -- See Note [specImport call stack] - -> RuleBase -- Rules from this module and the home package - -- (but not external packages, which can change) -> FloatedDictBinds -- Dict bindings, used /only/ for filterCalls -- See Note [Avoiding loops in specImports] -> CallDetails -- Calls for imported things - -> CoreM ( [CoreRule] -- New rules + -> CoreM ( SpecEnv -- Env contains the new rules + , [CoreRule] -- New rules , [CoreBind] ) -- Specialised bindings -spec_imports top_env callers rule_base dict_binds calls +spec_imports env callers dict_binds calls = do { let import_calls = dVarEnvElts calls -- ; debugTraceMsg (text "specImports {" <+> -- vcat [ text "calls:" <+> ppr import_calls -- , text "dict_binds:" <+> ppr dict_binds ]) - ; (rules, spec_binds) <- go rule_base import_calls + ; (env, rules, spec_binds) <- go env import_calls -- ; debugTraceMsg (text "End specImports }" <+> ppr import_calls) - ; return (rules, spec_binds) } + ; return (env, rules, spec_binds) } where - go :: RuleBase -> [CallInfoSet] -> CoreM ([CoreRule], [CoreBind]) - go _ [] = return ([], []) - go rb (cis : other_calls) + go :: SpecEnv -> [CallInfoSet] -> CoreM (SpecEnv, [CoreRule], [CoreBind]) + go env [] = return (env, [], []) + go env (cis : other_calls) = do { -- debugTraceMsg (text "specImport {" <+> ppr cis) - ; (rules1, spec_binds1) <- spec_import top_env callers rb dict_binds cis + ; (env, rules1, spec_binds1) <- spec_import env callers dict_binds cis ; -- debugTraceMsg (text "specImport }" <+> ppr cis) - ; (rules2, spec_binds2) <- go (extendRuleBaseList rb rules1) other_calls - ; return (rules1 ++ rules2, spec_binds1 ++ spec_binds2) } + ; (env, rules2, spec_binds2) <- go env other_calls + ; return (env, rules1 ++ rules2, spec_binds1 ++ spec_binds2) } spec_import :: SpecEnv -- Passed in so that all top-level Ids are in scope -> [Id] -- Stack of imported functions being specialised -- See Note [specImport call stack] - -> RuleBase -- Rules from this module -> FloatedDictBinds -- Dict bindings, used /only/ for filterCalls -- See Note [Avoiding loops in specImports] -> CallInfoSet -- Imported function and calls for it - -> CoreM ( [CoreRule] -- New rules + -> CoreM ( SpecEnv + , [CoreRule] -- New rules , [CoreBind] ) -- Specialised bindings -spec_import top_env callers rb dict_binds cis@(CIS fn _) +spec_import env callers dict_binds cis@(CIS fn _) | isIn "specImport" fn callers - = return ([], []) -- No warning. This actually happens all the time - -- when specialising a recursive function, because - -- the RHS of the specialised function contains a recursive - -- call to the original function + = return (env, [], []) -- No warning. This actually happens all the time + -- when specialising a recursive function, because + -- the RHS of the specialised function contains a recursive + -- call to the original function | null good_calls - = return ([], []) + = return (env, [], []) | Just rhs <- canSpecImport dflags fn = do { -- Get rules from the external package state -- We keep doing this in case we "page-fault in" -- more rules as we go along - ; external_rule_base <- getExternalRuleBase - ; vis_orphs <- getVisibleOrphanMods - ; let rules_for_fn = getRules (RuleEnv [rb, external_rule_base] vis_orphs) fn + ; eps_rules <- getExternalRuleBase + ; let rule_env = se_rules env `updExternalPackageRules` eps_rules - ; -- debugTraceMsg (text "specImport1" <+> vcat [ppr fn, ppr good_calls, ppr rhs]) +-- ; debugTraceMsg (text "specImport1" <+> vcat [ppr fn, ppr good_calls +-- , ppr (getRules rule_env fn), ppr rhs]) ; (rules1, spec_pairs, MkUD { ud_binds = dict_binds1, ud_calls = new_calls }) - <- runSpecM $ specCalls True top_env dict_binds - rules_for_fn good_calls fn rhs + <- runSpecM $ specCalls True env dict_binds + (getRules rule_env fn) good_calls fn rhs ; let spec_binds1 = [NonRec b r | (b,r) <- spec_pairs] -- After the rules kick in we may get recursion, but -- we rely on a global GlomBinds to sort that out later -- See Note [Glom the bindings if imported functions are specialised] + new_subst = se_subst env `Core.extendSubstInScopeList` map fst spec_pairs + new_env = env { se_rules = rule_env `addLocalRules` rules1 + , se_subst = new_subst } + -- Now specialise any cascaded calls - ; -- debugTraceMsg (text "specImport 2" <+> (ppr fn $$ ppr rules1 $$ ppr spec_binds1)) - ; (rules2, spec_binds2) <- spec_imports top_env - (fn:callers) - (extendRuleBaseList rb rules1) - (dict_binds `thenFDBs` dict_binds1) - new_calls +-- ; debugTraceMsg (text "specImport 2" <+> (ppr fn $$ ppr rules1 $$ ppr spec_binds1)) + ; (env, rules2, spec_binds2) + <- spec_imports new_env (fn:callers) + (dict_binds `thenFDBs` dict_binds1) + new_calls ; let final_binds = wrapDictBinds dict_binds1 $ spec_binds2 ++ spec_binds1 - ; return (rules2 ++ rules1, final_binds) } + ; return (env, rules2 ++ rules1, final_binds) } | otherwise = do { tryWarnMissingSpecs dflags callers fn good_calls - ; return ([], [])} + ; return (env, [], [])} where - dflags = se_dflags top_env + dflags = se_dflags env good_calls = filterCalls cis dict_binds -- SUPER IMPORTANT! Drop calls that (directly or indirectly) refer to fn -- See Note [Avoiding loops in specImports] @@ -1134,6 +1134,7 @@ data SpecEnv -- the RHS of specialised bindings (no type-let!) , se_module :: Module + , se_rules :: RuleEnv -- From the home package and this module , se_dflags :: DynFlags } @@ -1172,8 +1173,8 @@ specExpr env expr@(App {}) ; (args_out, uds_args) <- mapAndCombineSM (specExpr env) args_in ; let env_args = env `bringFloatedDictsIntoScope` ud_binds uds_args -- Some dicts may have floated out of args_in; - -- they should be in scope for rewriteClassOps (#21689) - (fun_in', args_out') = rewriteClassOps env_args fun_in args_out + -- they should be in scope for fireRewriteRules (#21689) + (fun_in', args_out') = fireRewriteRules env_args fun_in args_out ; (fun_out', uds_fun) <- specExpr env fun_in' ; let uds_call = mkCallUDs env fun_out' args_out' ; return (fun_out' `mkApps` args_out', uds_fun `thenUDs` uds_call `thenUDs` uds_args) } @@ -1208,17 +1209,19 @@ specExpr env (Let bind body) ; return (foldr Let body' binds', uds) } -- See Note [Specialisation modulo dictionary selectors] --- and Note [ClassOp/DFun selection] -rewriteClassOps :: SpecEnv -> InExpr -> [OutExpr] -> (InExpr, [OutExpr]) -rewriteClassOps env (Var f) args - | isClassOpId f -- If we see `op_sel $fCInt`, we rewrite to `$copInt` - , Just (rule, expr) <- -- pprTrace "rewriteClassOps" (ppr f $$ ppr args $$ ppr (se_subst env)) $ - specLookupRule env f args (idCoreRules f) - , let rest_args = drop (ruleArity rule) args -- See Note [Extra args in the target] --- , pprTrace "class op rewritten" (ppr f <+> ppr args $$ ppr expr <+> ppr rest_args) True - , (fun, args) <- collectArgs expr - = rewriteClassOps env fun (args++rest_args) -rewriteClassOps _ fun args = (fun, args) +-- Note [ClassOp/DFun selection] +-- Note [Fire rules in the specialiser] +fireRewriteRules :: SpecEnv -> InExpr -> [OutExpr] -> (InExpr, [OutExpr]) +fireRewriteRules env (Var f) args + | Just (rule, expr) <- specLookupRule env f args InitialPhase (getRules (se_rules env) f) + , let rest_args = drop (ruleArity rule) args -- See Note [Extra args in the target] + zapped_subst = Core.zapSubst (se_subst env) + expr' = simpleOptExprWith defaultSimpleOpts zapped_subst expr + -- simplOptExpr needed because lookupRule returns + -- (\x y. rhs) arg1 arg2 + , (fun, args) <- collectArgs expr' + = fireRewriteRules env fun (args++rest_args) +fireRewriteRules _ fun args = (fun, args) -------------- specLam :: SpecEnv -> [OutBndr] -> InExpr -> SpecM (OutExpr, UsageDetails) @@ -1324,7 +1327,67 @@ specCase env scrut case_bndr alts where (env_rhs, args') = substBndrs env_alt args -{- +{- Note [Fire rules in the specialiser] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Consider this (#21851) + + module A where + f :: Num b => b -> (b, b) + f x = (x + 1, snd (f x)) + {-# SPECIALIZE f :: Int -> (Int, Int) #-} + + module B (g') where + import A + + g :: Num a => a -> a + g x = fst (f x) + {-# NOINLINE[99] g #-} + + h :: Int -> Int + h = g + +Note that `f` has the CPR property, and so will worker/wrapper. + +The call to `g` in `h` will make us specialise `g @Int`. And the specialised +version of `g` will contain the call `f @Int`; but in the subsequent run of +the Simplifier, there will be a competition between: +* The user-supplied SPECIALISE rule for `f` +* The inlining of the wrapper for `f` +In fact, the latter wins -- see Note [Rewrite rules and inlining] in +GHC.Core.Opt.Simplify.Iteration. However, it a bit fragile. + +Moreover consider (test T21851_2): + + module A + f :: (Ord a, Show b) => a -> b -> blah + {-# RULE forall b. f @Int @b = wombat #-} + + wombat :: Show b => Int -> b -> blah + wombat = blah + + module B + import A + g :: forall a. Ord a => blah + g @a = ...g...f @a @Char.... + + h = ....g @Int.... + +Now, in module B, GHC will specialise `g @Int`, which will lead to a +call `f @Int @Char`. If we immediately (in the specialiser) rewrite +that to `womabat @Char`, we have a chance to specialise `wombat`. + +Conclusion: it's treat if the Specialiser fires RULEs itself. +It's not hard to achieve: see `fireRewriteRules`. The only tricky bit is +making sure that we have a reasonably up to date EPS rule base. Currently +we load it up just once, in `initRuleEnv`, called at the beginning of +`specProgram`. + +NB: you might wonder if running rules in the specialiser (this Note) +renders Note [Rewrite rules and inlining] in the Simplifier redundant. +That is, if we run rules in the specialiser, does it matter if we make +rules "win" over inlining in the Simplifier? Yes, it does! See the +discussion in #21851. + Note [Floating dictionaries out of cases] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -1415,13 +1478,12 @@ specBind top_lvl env (NonRec fn rhs) do_body final_binds :: [DictBind] -- See Note [From non-recursive to recursive] - final_binds - | not (isNilOL dump_dbs) - , not (null spec_defns) - = [recWithDumpedDicts pairs dump_dbs] - | otherwise - = [mkDB $ NonRec b r | (b,r) <- pairs] - ++ fromOL dump_dbs + final_binds | not (isNilOL dump_dbs) + , not (null spec_defns) + = [recWithDumpedDicts pairs dump_dbs] + | otherwise + = [mkDB $ NonRec b r | (b,r) <- pairs] + ++ fromOL dump_dbs ; if float_all then -- Rather than discard the calls mentioning the bound variables @@ -1553,8 +1615,10 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs foldlM spec_call ([], [], emptyUDs) calls_for_me | otherwise -- No calls or RHS doesn't fit our preconceptions - = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me) + = warnPprTrace (not (exprIsTrivial rhs) && notNull calls_for_me && not (isClassOpId fn)) "Missed specialisation opportunity for" (ppr fn $$ trace_doc) $ + -- isClassOpId: class-op Ids never inline; we specialise them + -- through fireRewriteRules. So don't complain about missed opportunities -- Note [Specialisation shape] -- pprTrace "specCalls: none" (ppr fn <+> ppr calls_for_me) $ return ([], [], emptyUDs) @@ -1581,9 +1645,13 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs already_covered :: SpecEnv -> [CoreRule] -> [CoreExpr] -> Bool already_covered env new_rules args -- Note [Specialisations already covered] - = isJust (specLookupRule env fn args (new_rules ++ existing_rules)) - -- NB: we look both in the new_rules (generated by this invocation - -- of specCalls), and in existing_rules (passed in to specCalls) + = isJust (specLookupRule env fn args (beginPhase inl_act) + (new_rules ++ existing_rules)) + -- Rules: we look both in the new_rules (generated by this invocation + -- of specCalls), and in existing_rules (passed in to specCalls) + -- inl_act: is the activation we are going to put in the new SPEC + -- rule; so we want to see if it is covered by another rule with + -- that same activation. ---------------------------------------------------------- -- Specialise to one particular call pattern @@ -1708,13 +1776,16 @@ specCalls spec_imp env dict_binds existing_rules calls_for_me fn rhs -- Convenience function for invoking lookupRule from Specialise -- The SpecEnv's InScopeSet should include all the Vars in the [CoreExpr] -specLookupRule :: SpecEnv -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr) -specLookupRule env fn args rules - = lookupRule ropts (in_scope, realIdUnfolding) (const True) fn args rules +specLookupRule :: SpecEnv -> Id -> [CoreExpr] + -> CompilerPhase -- Look up rules as if we were in this phase + -> [CoreRule] -> Maybe (CoreRule, CoreExpr) +specLookupRule env fn args phase rules + = lookupRule ropts (in_scope, realIdUnfolding) is_active fn args rules where - dflags = se_dflags env - in_scope = getSubstInScope (se_subst env) - ropts = initRuleOpts dflags + dflags = se_dflags env + in_scope = getSubstInScope (se_subst env) + ropts = initRuleOpts dflags + is_active = isActive phase {- Note [Specialising DFuns] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1913,10 +1984,10 @@ We want to specialise this! How? By doing the method-selection rewrite in the Specialiser. Hence 1. In the App case of 'specExpr', try to apply the ClassOp/DFun rule on the - head of the application, repeatedly, via 'rewriteClassOps'. + head of the application, repeatedly, via 'fireRewriteRules'. 2. Attach an unfolding to freshly-bound dictionary ids such as `$dC` and `$dShow` in `bindAuxiliaryDict`, so that we can exploit the unfolding - in 'rewriteClassOps' to do the ClassOp/DFun rewrite. + in 'fireRewriteRules' to do the ClassOp/DFun rewrite. NB: Without (2), (1) would be pointless, because 'lookupRule' wouldn't be able to look into the RHS of `$dC` to see the DFun. ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -15,7 +15,7 @@ module GHC.Core.Opt.WorkWrap.Utils , findTypeShape, IsRecDataConResult(..), isRecDataCon , mkAbsentFiller , isWorkerSmallEnough, dubiousDataConInstArgTys - , isGoodWorker, badWorker , goodWorker + , boringSplit , usefulSplit ) where @@ -571,23 +571,24 @@ data UnboxingDecision unboxing_info -- returned product was constructed, so unbox it. | DropAbsent -- ^ The argument/field was absent. Drop it. --- Do we want to create workers just for unlifting? -wwForUnlifting :: WwOpts -> Bool -wwForUnlifting !opts +-- | Do we want to create workers just for unlifting? +wwUseForUnlifting :: WwOpts -> WwUse +wwUseForUnlifting !opts -- Always unlift if possible - | wo_unlift_strict opts = goodWorker + | wo_unlift_strict opts = usefulSplit -- Don't unlift it would cause additional W/W splits. - | otherwise = badWorker + | otherwise = boringSplit -badWorker :: Bool -badWorker = False +-- | Is the worker/wrapper split profitable? +type WwUse = Bool -goodWorker :: Bool -goodWorker = True - -isGoodWorker :: Bool -> Bool -isGoodWorker = id +-- | WW split not profitable +boringSplit :: WwUse +boringSplit = False +-- | WW split profitable +usefulSplit :: WwUse +usefulSplit = True -- | Unwraps the 'Boxity' decision encoded in the given 'SubDemand' and returns -- a 'DataConPatContext' as well the nested demands on fields of the 'DataCon' @@ -826,7 +827,7 @@ Is this a win? Not always: So there is a flag, `-fworker-wrapper-cbv`, to control whether we do w/w on strict arguments (internally `Opt_WorkerWrapperUnlift`). The flag is off by default. The choice is made in -GHC.Core.Opt.WorkWrape.Utils.wwForUnlifting +GHC.Core.Opt.WorkWrape.Utils.wwUseForUnlifting See also `Note [WW for calling convention]` in GHC.Core.Opt.WorkWrap.Utils -} @@ -843,7 +844,7 @@ mkWWstr :: WwOpts -> [Var] -- Wrapper args; have their demand info on them -- *Includes type variables* -> [StrictnessMark] -- Strictness-mark info for arguments - -> UniqSM (Bool, -- Will this result in a useful worker + -> UniqSM (WwUse, -- Will this result in a useful worker [(Var,StrictnessMark)], -- Worker args/their call-by-value semantics. CoreExpr -> CoreExpr, -- Wrapper body, lacking the worker call -- and without its lambdas @@ -855,7 +856,7 @@ mkWWstr opts args str_marks = -- pprTrace "mkWWstr" (ppr args) $ go args str_marks where - go [] _ = return (badWorker, [], nop_fn, []) + go [] _ = return (boringSplit, [], nop_fn, []) go (arg : args) (str:strs) = do { (useful1, args1, wrap_fn1, wrap_arg) <- mkWWstr_one opts arg str ; (useful2, args2, wrap_fn2, wrap_args) <- go args strs @@ -875,7 +876,7 @@ mkWWstr opts args str_marks mkWWstr_one :: WwOpts -> Var -> StrictnessMark - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) mkWWstr_one opts arg str_mark = -- pprTrace "mkWWstr_one" (ppr arg <+> (if isId arg then ppr arg_ty $$ ppr arg_dmd else text "type arg")) $ case canUnboxArg fam_envs arg_ty arg_dmd of @@ -887,7 +888,7 @@ mkWWstr_one opts arg str_mark = -- We can't always handle absence for arbitrary -- unlifted types, so we need to choose just the cases we can -- (that's what mkAbsentFiller does) - -> return (goodWorker, [], nop_fn, absent_filler) + -> return (usefulSplit, [], nop_fn, absent_filler) | otherwise -> do_nothing DoUnbox dcpc -> -- pprTrace "mkWWstr_one:1" (ppr (dcpc_dc dcpc) <+> ppr (dcpc_tc_args dcpc) $$ ppr (dcpc_args dcpc)) $ @@ -895,12 +896,12 @@ mkWWstr_one opts arg str_mark = DontUnbox | isStrictDmd arg_dmd || isMarkedStrict str_mark - , wwForUnlifting opts -- See Note [CBV Function Ids] + , wwUseForUnlifting opts -- See Note [CBV Function Ids] , not (isFunTy arg_ty) , not (isUnliftedType arg_ty) -- Already unlifted! -- NB: function arguments have a fixed RuntimeRep, -- so it's OK to call isUnliftedType here - -> return (goodWorker, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) + -> return (usefulSplit, [(arg, MarkedStrict)], nop_fn, varToCoreExpr arg ) | otherwise -> do_nothing @@ -910,11 +911,11 @@ mkWWstr_one opts arg str_mark = arg_dmd = idDemandInfo arg arg_str | isTyVar arg = NotMarkedStrict -- Type args don't get strictness marks | otherwise = str_mark - do_nothing = return (badWorker, [(arg,arg_str)], nop_fn, varToCoreExpr arg) + do_nothing = return (boringSplit, [(arg,arg_str)], nop_fn, varToCoreExpr arg) unbox_one_arg :: WwOpts - -> Var-> DataConPatContext Demand - -> UniqSM (Bool, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) + -> Var -> DataConPatContext Demand + -> UniqSM (WwUse, [(Var,StrictnessMark)], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var DataConPatContext { dcpc_dc = dc, dcpc_tc_args = tc_args , dcpc_co = co, dcpc_args = ds } @@ -939,13 +940,14 @@ unbox_one_arg opts arg_var -- See Note [Call-by-value for worker args] all_str_marks = (map (const NotMarkedStrict) ex_tvs') ++ con_str_marks - ; (_sub_args_quality, worker_args, wrap_fn, wrap_args) + ; (nested_useful, worker_args, wrap_fn, wrap_args) <- mkWWstr opts (ex_tvs' ++ arg_ids') all_str_marks ; let wrap_arg = mkConApp dc (map Type tc_args ++ wrap_args) `mkCast` mkSymCo co - - ; return (goodWorker, worker_args, unbox_fn . wrap_fn, wrap_arg) } - -- Don't pass the arg, rebox instead + -- See Note [Unboxing through unboxed tuples] + ; return $ if isUnboxedTupleDataCon dc && not nested_useful + then (boringSplit, [(arg_var,NotMarkedStrict)], nop_fn, varToCoreExpr arg_var) + else (usefulSplit, worker_args, unbox_fn . wrap_fn, wrap_arg) } -- | Tries to find a suitable absent filler to bind the given absent identifier -- to. See Note [Absent fillers]. @@ -1195,6 +1197,26 @@ fragile because `MkT` is strict in its Int# argument, so we get an absentError exception when we shouldn't. Very annoying! +Note [Unboxing through unboxed tuples] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +We should not to a worker/wrapper split just for unboxing the components of +an unboxed tuple (in the result *or* argument, #22388). Consider + boring_res x y = (# y, x #) +It's entirely pointless to split for the constructed unboxed pair to + $wboring_res x y = (# y, x #) + boring_res = case $wboring_res x y of (# a, b #) -> (# a, b #) +`boring_res` will immediately simplify to an alias for `$wboring_res`! + +Similarly, the unboxed tuple might occur in argument position + boring_arg (# x, y, z #) = (# z, x, y #) +It's entirely pointless to "unbox" the triple + $wboring_arg x y z = (# z, x, y #) + boring_arg (# x, y, z #) = $wboring_arg x y z +because after unarisation, `boring_arg` is just an alias for `$wboring_arg`. + +Conclusion: Only consider unboxing an unboxed tuple useful when we will +also unbox its components. That is governed by the `usefulSplit` mechanism. + ************************************************************************ * * Type scrutiny that is specific to demand analysis @@ -1376,12 +1398,12 @@ mkWWcpr_entry :: WwOpts -> Type -- function body -> Cpr -- CPR analysis results - -> UniqSM (Bool, -- Is w/w'ing useful? + -> UniqSM (WwUse, -- Is w/w'ing useful? CoreExpr -> CoreExpr, -- New wrapper. 'nop_fn' if not useful CoreExpr -> CoreExpr) -- New worker. 'nop_fn' if not useful -- ^ Entrypoint to CPR W/W. See Note [Worker/wrapper for CPR] for an overview. mkWWcpr_entry opts body_ty body_cpr - | not (wo_cpr_anal opts) = return (badWorker, nop_fn, nop_fn) + | not (wo_cpr_anal opts) = return (boringSplit, nop_fn, nop_fn) | otherwise = do -- Part (1) res_bndr <- mk_res_bndr body_ty @@ -1398,8 +1420,8 @@ mkWWcpr_entry opts body_ty body_cpr let wrap_fn = unbox_transit_tup rebuilt_result -- 3 2 work_fn body = bind_res_bndr body (work_unpack_res transit_tup) -- 1 2 3 return $ if not useful - then (badWorker, nop_fn, nop_fn) - else (goodWorker, wrap_fn, work_fn) + then (boringSplit, nop_fn, nop_fn) + else (usefulSplit, wrap_fn, work_fn) -- | Part (1) of Note [Worker/wrapper for CPR]. mk_res_bndr :: Type -> UniqSM Id @@ -1411,18 +1433,18 @@ mk_res_bndr body_ty = do -- | What part (2) of Note [Worker/wrapper for CPR] collects. -- --- 1. A Bool capturing whether the transformation did anything useful. +-- 1. A 'WwUse' capturing whether the split does anything useful. -- 2. The list of transit variables (see the Note). -- 3. The result builder expression for the wrapper. The original case binder if not useful. -- 4. The result unpacking expression for the worker. 'nop_fn' if not useful. -type CprWwResultOne = (Bool, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) -type CprWwResultMany = (Bool, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) +type CprWwResultOne = (WwUse, OrdList Var, CoreExpr , CoreExpr -> CoreExpr) +type CprWwResultMany = (WwUse, OrdList Var, [CoreExpr], CoreExpr -> CoreExpr) mkWWcpr :: WwOpts -> [Id] -> [Cpr] -> UniqSM CprWwResultMany mkWWcpr _opts vars [] = -- special case: No CPRs means all top (for example from FlatConCpr), -- hence stop WW. - return (badWorker, toOL vars, map varToCoreExpr vars, nop_fn) + return (boringSplit, toOL vars, map varToCoreExpr vars, nop_fn) mkWWcpr opts vars cprs = do -- No existentials in 'vars'. 'canUnboxResult' should have checked that. massertPpr (not (any isTyVar vars)) (ppr vars $$ ppr cprs) @@ -1441,7 +1463,7 @@ mkWWcpr_one opts res_bndr cpr , DoUnbox dcpc <- canUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr = unbox_one_result opts res_bndr dcpc | otherwise - = return (badWorker, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) + = return (boringSplit, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) unbox_one_result :: WwOpts -> Id -> DataConPatContext Cpr -> UniqSM CprWwResultOne @@ -1467,11 +1489,10 @@ unbox_one_result opts res_bndr -- this_work_unbox_res alt = (case res_bndr |> co of C a b -> [a,b]) this_work_unbox_res = mkUnpackCase (Var res_bndr) co cprCaseBndrMult dc arg_ids - -- Don't try to WW an unboxed tuple return type when there's nothing inside - -- to unbox further. + -- See Note [Unboxing through unboxed tuples] return $ if isUnboxedTupleDataCon dc && not nested_useful - then ( badWorker, unitOL res_bndr, Var res_bndr, nop_fn ) - else ( goodWorker + then ( boringSplit, unitOL res_bndr, Var res_bndr, nop_fn ) + else ( usefulSplit , transit_vars , rebuilt_result , this_work_unbox_res . work_unbox_res ===================================== compiler/GHC/Core/Rules.hs ===================================== @@ -12,8 +12,10 @@ module GHC.Core.Rules ( lookupRule, -- ** RuleBase, RuleEnv + RuleBase, RuleEnv(..), mkRuleEnv, emptyRuleEnv, + updExternalPackageRules, addLocalRules, updLocalRules, emptyRuleBase, mkRuleBase, extendRuleBaseList, - pprRuleBase, extendRuleEnv, + pprRuleBase, -- ** Checking rule applications ruleCheckProgram, @@ -22,6 +24,8 @@ module GHC.Core.Rules ( extendRuleInfo, addRuleInfo, addIdSpecialisations, + -- ** RuleBase and RuleEnv + -- * Misc. CoreRule helpers rulesOfBinds, getRules, pprRulesForUser, @@ -34,6 +38,8 @@ import GHC.Prelude import GHC.Unit.Module ( Module ) import GHC.Unit.Module.Env +import GHC.Unit.Module.ModGuts( ModGuts(..) ) +import GHC.Unit.Module.Deps( Dependencies(..) ) import GHC.Driver.Session( DynFlags ) import GHC.Driver.Ppr( showSDoc ) @@ -135,7 +141,7 @@ Note [Overall plumbing for rules] * At the moment (c) is carried in a reader-monad way by the GHC.Core.Opt.Monad. The HomePackageTable doesn't have a single RuleBase because technically we should only be able to "see" rules "below" this module; so we - generate a RuleBase for (c) by combing rules from all the modules + generate a RuleBase for (c) by combining rules from all the modules "below" us. That's why we can't just select the home-package RuleBase from HscEnv. @@ -339,12 +345,106 @@ addIdSpecialisations id rules rulesOfBinds :: [CoreBind] -> [CoreRule] rulesOfBinds binds = concatMap (concatMap idCoreRules . bindersOf) binds + +{- +************************************************************************ +* * + RuleBase +* * +************************************************************************ +-} + +-- | Gathers a collection of 'CoreRule's. Maps (the name of) an 'Id' to its rules +type RuleBase = NameEnv [CoreRule] + -- The rules are unordered; + -- we sort out any overlaps on lookup + +emptyRuleBase :: RuleBase +emptyRuleBase = emptyNameEnv + +mkRuleBase :: [CoreRule] -> RuleBase +mkRuleBase rules = extendRuleBaseList emptyRuleBase rules + +extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase +extendRuleBaseList rule_base new_guys + = foldl' extendRuleBase rule_base new_guys + +extendRuleBase :: RuleBase -> CoreRule -> RuleBase +extendRuleBase rule_base rule + = extendNameEnv_Acc (:) Utils.singleton rule_base (ruleIdName rule) rule + +pprRuleBase :: RuleBase -> SDoc +pprRuleBase rules = pprUFM rules $ \rss -> + vcat [ pprRules (tidyRules emptyTidyEnv rs) + | rs <- rss ] + +-- | A full rule environment which we can apply rules from. Like a 'RuleBase', +-- but it also includes the set of visible orphans we use to filter out orphan +-- rules which are not visible (even though we can see them...) +-- See Note [Orphans] in GHC.Core +data RuleEnv + = RuleEnv { re_local_rules :: !RuleBase -- Rules from this module + , re_home_rules :: !RuleBase -- Rule from the home package + -- (excl this module) + , re_eps_rules :: !RuleBase -- Rules from other packages + -- see Note [External package rules] + , re_visible_orphs :: !ModuleSet + } + +mkRuleEnv :: ModGuts -> RuleBase -> RuleBase -> RuleEnv +mkRuleEnv (ModGuts { mg_module = this_mod + , mg_deps = deps + , mg_rules = local_rules }) + eps_rules hpt_rules + = RuleEnv { re_local_rules = mkRuleBase local_rules + , re_home_rules = hpt_rules + , re_eps_rules = eps_rules + , re_visible_orphs = mkModuleSet vis_orphs } + where + vis_orphs = this_mod : dep_orphs deps + +updExternalPackageRules :: RuleEnv -> RuleBase -> RuleEnv +-- Completely over-ride the external rules in RuleEnv +updExternalPackageRules rule_env eps_rules + = rule_env { re_eps_rules = eps_rules } + +updLocalRules :: RuleEnv -> [CoreRule] -> RuleEnv +-- Completely over-ride the local rules in RuleEnv +updLocalRules rule_env local_rules + = rule_env { re_local_rules = mkRuleBase local_rules } + +addLocalRules :: RuleEnv -> [CoreRule] -> RuleEnv +-- Add new local rules +addLocalRules rule_env rules + = rule_env { re_local_rules = extendRuleBaseList (re_local_rules rule_env) rules } + +emptyRuleEnv :: RuleEnv +emptyRuleEnv = RuleEnv { re_local_rules = emptyNameEnv + , re_home_rules = emptyNameEnv + , re_eps_rules = emptyNameEnv + , re_visible_orphs = emptyModuleSet } + getRules :: RuleEnv -> Id -> [CoreRule] +-- Given a RuleEnv and an Id, find the visible rules for that Id -- See Note [Where rules are found] -getRules (RuleEnv { re_base = rule_base, re_visible_orphs = orphs }) fn - = idCoreRules fn ++ concatMap imp_rules rule_base +getRules (RuleEnv { re_local_rules = local_rules + , re_home_rules = home_rules + , re_eps_rules = eps_rules + , re_visible_orphs = orphs }) fn + + | Just {} <- isDataConId_maybe fn -- Short cut for data constructor workers + = [] -- and wrappers, which never have any rules + + | otherwise + = idCoreRules fn ++ + get local_rules ++ + find_visible home_rules ++ + find_visible eps_rules + where - imp_rules rb = filter (ruleIsVisible orphs) (lookupNameEnv rb (idName fn) `orElse` []) + fn_name = idName fn + find_visible rb = filter (ruleIsVisible orphs) (get rb) + get rb = lookupNameEnv rb fn_name `orElse` [] ruleIsVisible :: ModuleSet -> CoreRule -> Bool ruleIsVisible _ BuiltinRule{} = True @@ -370,37 +470,28 @@ but that isn't quite right: in the module defining the Id (when it's a LocalId), but the rules are kept in the global RuleBase + Note [External package rules] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In Note [Overall plumbing for rules], it is explained that the final +RuleBase which we must consider is combined from 4 different sources. -************************************************************************ -* * - RuleBase -* * -************************************************************************ --} - --- RuleBase itself is defined in GHC.Core, along with CoreRule - -emptyRuleBase :: RuleBase -emptyRuleBase = emptyNameEnv - -mkRuleBase :: [CoreRule] -> RuleBase -mkRuleBase rules = extendRuleBaseList emptyRuleBase rules +During simplifier runs, the fourth source of rules is constantly being updated +as new interfaces are loaded into the EPS. Therefore just before we check to see +if any rules match we get the EPS RuleBase and combine it with the existing RuleBase +and then perform exactly 1 lookup into the new map. -extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase -extendRuleBaseList rule_base new_guys - = foldl' extendRuleBase rule_base new_guys +It is more efficient to avoid combining the environments and store the uncombined +environments as we can instead perform 1 lookup into each environment and then combine +the results. -extendRuleBase :: RuleBase -> CoreRule -> RuleBase -extendRuleBase rule_base rule - = extendNameEnv_Acc (:) Utils.singleton rule_base (ruleIdName rule) rule +Essentially we use the identity: -extendRuleEnv :: RuleEnv -> RuleBase -> RuleEnv -extendRuleEnv (RuleEnv rules orphs) rb = (RuleEnv (rb:rules) orphs) +> lookupNameEnv n (plusNameEnv_C (++) rb1 rb2) +> = lookupNameEnv n rb1 ++ lookupNameEnv n rb2 -pprRuleBase :: RuleBase -> SDoc -pprRuleBase rules = pprUFM rules $ \rss -> - vcat [ pprRules (tidyRules emptyTidyEnv rs) - | rs <- rss ] +The latter being more efficient as we don't construct an intermediate +map. +-} {- ************************************************************************ @@ -1575,7 +1666,7 @@ ruleCheckFun env fn args | otherwise = unitBag (ruleAppCheck_help env fn args name_match_rules) where name_match_rules = filter match (rc_rules env fn) - match rule = (rc_pattern env) `isPrefixOf` unpackFS (ruleName rule) + match rule = rc_pattern env `isPrefixOf` unpackFS (ruleName rule) ruleAppCheck_help :: RuleCheckEnv -> Id -> [CoreExpr] -> [CoreRule] -> SDoc ruleAppCheck_help env fn args rules ===================================== compiler/GHC/Driver/Config/Core/Opt/Simplify.hs ===================================== @@ -6,7 +6,7 @@ module GHC.Driver.Config.Core.Opt.Simplify import GHC.Prelude -import GHC.Core ( RuleBase ) +import GHC.Core.Rules ( RuleBase ) import GHC.Core.Opt.Pipeline.Types ( CoreToDo(..) ) import GHC.Core.Opt.Simplify ( SimplifyExprOpts(..), SimplifyOpts(..) ) import GHC.Core.Opt.Simplify.Env ( FloatEnable(..), SimplMode(..) ) @@ -40,20 +40,19 @@ initSimplifyExprOpts dflags ic = SimplifyExprOpts } initSimplifyOpts :: DynFlags -> [Var] -> Int -> SimplMode -> RuleBase -> SimplifyOpts -initSimplifyOpts dflags extra_vars iterations mode rule_base = let +initSimplifyOpts dflags extra_vars iterations mode hpt_rule_base = let -- This is a particularly ugly construction, but we will get rid of it in !8341. opts = SimplifyOpts { so_dump_core_sizes = not $ gopt Opt_SuppressCoreSizes dflags - , so_iterations = iterations - , so_mode = mode + , so_iterations = iterations + , so_mode = mode , so_pass_result_cfg = if gopt Opt_DoCoreLinting dflags - then Just $ initLintPassResultConfig dflags extra_vars (CoreDoSimplify opts) - else Nothing - , so_rule_base = rule_base - , so_top_env_cfg = TopEnvConfig - { te_history_size = historySize dflags - , te_tick_factor = simplTickFactor dflags - } + then Just $ initLintPassResultConfig dflags extra_vars + (CoreDoSimplify opts) + else Nothing + , so_hpt_rules = hpt_rule_base + , so_top_env_cfg = TopEnvConfig { te_history_size = historySize dflags + , te_tick_factor = simplTickFactor dflags } } in opts ===================================== compiler/GHC/HsToCore/Errors/Ppr.hs ===================================== @@ -86,7 +86,7 @@ instance Diagnostic DsMessage where hang (text "Top-level" <+> text desc <+> text "aren't allowed:") 2 (ppr bind) DsUselessSpecialiseForClassMethodSelector poly_id -> mkSimpleDecorated $ - text "Ignoring useless SPECIALISE pragma for NOINLINE function:" <+> quotes (ppr poly_id) + text "Ignoring useless SPECIALISE pragma for class selector:" <+> quotes (ppr poly_id) DsUselessSpecialiseForNoInlineFunction poly_id -> mkSimpleDecorated $ text "Ignoring useless SPECIALISE pragma for NOINLINE function:" <+> quotes (ppr poly_id) ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -585,6 +585,7 @@ mkDataConWorkId wkr_name data_con `setInlinePragInfo` wkr_inline_prag `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated, -- even if arity = 0 + -- No strictness: see Note [Data-con worker strictness] in GHC.Core.DataCon wkr_inline_prag = defaultInlinePragma { inl_rule = ConLike } wkr_arity = dataConRepArity data_con ===================================== compiler/GHC/Unit/External.hs ===================================== @@ -21,11 +21,10 @@ import GHC.Prelude import GHC.Unit import GHC.Unit.Module.ModIface -import GHC.Core ( RuleBase ) import GHC.Core.FamInstEnv import GHC.Core.InstEnv ( InstEnv, emptyInstEnv ) import GHC.Core.Opt.ConstantFold -import GHC.Core.Rules (mkRuleBase) +import GHC.Core.Rules ( RuleBase, mkRuleBase) import GHC.Types.Annotations ( AnnEnv, emptyAnnEnv ) import GHC.Types.CompleteMatch ===================================== libraries/base/GHC/Ix.hs ===================================== @@ -140,12 +140,30 @@ Note [Out-of-bounds error messages] The default method for 'index' generates hoplelessIndexError, because Ix doesn't have Show as a superclass. For particular base types we can do better, so we override the default method for index. --} --- Abstract these errors from the relevant index functions so that --- the guts of the function will be small enough to inline. +Note [indexError] +~~~~~~~~~~~~~~~~~ +We abstract the guts of constructing an out-of-bounds error into `indexError`. +We give it a NOINLINE pragma, because we don't want to duplicate this +cold-path code. + +We give it a SPECIALISE pragma because we really want it to take +its arguments unboxed, to avoid reboxing code in the caller, and +perhaps even some reboxing code in the hot path of a caller. +See Note [Boxity for bottoming functions] in GHC.Core.Opt.DmdAnal. + +The SPECIALISE pragma means that at least the Int-indexed case +of indexError /will/ unbox its arguments. +The [2] phase is because if we don't give an activation we'll get +the one from the inline pragama (i.e. never) which is a bit silly. +See Note [Activation pragmas for SPECIALISE] in GHC.HsToCore.Binds. +-} + +-- indexError: see Note [indexError] {-# NOINLINE indexError #-} +{-# SPECIALISE [2] indexError :: (Int,Int) -> Int -> String -> b #-} + indexError :: Show a => (a,a) -> a -> String -> b indexError rng i tp = errorWithoutStackTrace (showString "Ix{" . showString tp . showString "}.index: Index " . ===================================== libraries/base/GHC/Real.hs ===================================== @@ -701,11 +701,14 @@ half of y - 1 can be computed as y `quot` 2, optimising subtraction away. Note [Inlining (^) ~~~~~~~~~~~~~~~~~~ -The INLINABLE pragma allows (^) to be specialised at its call sites. +The INLINABLE [1] pragma allows (^) to be specialised at its call sites. If it is called repeatedly at the same type, that can make a huge difference, because of those constants which can be repeatedly calculated. +We don't inline until phase 1, to give a chance for the RULES +"^2/Int" etc to fire first. + Currently the fromInteger calls are not floated because we get \d1 d2 x y -> blah after the gentle round of simplification. ===================================== testsuite/tests/simplCore/should_compile/T21851.stderr ===================================== @@ -15,5 +15,3 @@ g' :: Int -> Int g' = \ (x :: Int) -> case T21851a.$w$sf x of { (# ww, ww1 #) -> ww } - - ===================================== testsuite/tests/simplCore/should_compile/T21851_2.hs ===================================== @@ -0,0 +1,15 @@ +{-# OPTIONS_GHC -ddump-simpl -dsuppress-uniques -dno-typeable-binds #-} + +module T21851_2 where + +import T21851_2a + +g :: forall a. (Ord a, Num a) => a -> (a,String) +g n | n < 10 = (0, f n True) + | otherwise = g (n-2) +-- The specialised version of g leads to a specialised +-- call to (f @Int @Bool). Then we want to fire f's RULE +-- and specialise 'wombat' + +h = g (3::Int) + ===================================== testsuite/tests/simplCore/should_compile/T21851_2.stderr ===================================== @@ -0,0 +1,120 @@ +[1 of 2] Compiling T21851_2a ( T21851_2a.hs, T21851_2a.o ) +[2 of 2] Compiling T21851_2 ( T21851_2.hs, T21851_2.o ) + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 107, types: 96, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl :: Integer +[GblId, Unf=OtherCon []] +lvl = GHC.Num.Integer.IS 2# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl1 :: Integer +[GblId, Unf=OtherCon []] +lvl1 = GHC.Num.Integer.IS 0# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +lvl2 :: Integer +[GblId, Unf=OtherCon []] +lvl2 = GHC.Num.Integer.IS 10# + +Rec { +-- RHS size: {terms: 25, types: 5, coercions: 0, joins: 0/0} +T21851_2.$s$wwombat [InlPrag=[~], Occ=LoopBreaker] + :: GHC.Prim.Int# -> Bool -> [Char] +[GblId, Arity=2, Str=<1L>, Unf=OtherCon []] +T21851_2.$s$wwombat + = \ (ww :: GHC.Prim.Int#) (y :: Bool) -> + case ww of ds { + __DEFAULT -> + case y of { + False -> + GHC.CString.unpackAppendCString# + GHC.Show.$fShowBool3 + (T21851_2.$s$wwombat (GHC.Prim.-# ds 1#) GHC.Types.False); + True -> + GHC.CString.unpackAppendCString# + GHC.Show.$fShowBool2 + (T21851_2.$s$wwombat (GHC.Prim.-# ds 1#) GHC.Types.True) + }; + 0# -> GHC.Types.[] @Char + } +end Rec } + +Rec { +-- RHS size: {terms: 16, types: 6, coercions: 0, joins: 0/0} +T21851_2.$w$sg [InlPrag=[2], Occ=LoopBreaker] + :: GHC.Prim.Int# -> (# GHC.Prim.Int#, String #) +[GblId, Arity=1, Str=, Unf=OtherCon []] +T21851_2.$w$sg + = \ (ww :: GHC.Prim.Int#) -> + case GHC.Prim.<# ww 10# of { + __DEFAULT -> T21851_2.$w$sg (GHC.Prim.-# ww 2#); + 1# -> (# 0#, T21851_2.$s$wwombat ww GHC.Types.True #) + } +end Rec } + +-- RHS size: {terms: 3, types: 3, coercions: 0, joins: 0/0} +lvl3 :: forall {a}. [Char] +[GblId] +lvl3 = \ (@a) -> T21851_2a.$wf GHC.Prim.(##) @a @Bool + +Rec { +-- RHS size: {terms: 27, types: 18, coercions: 0, joins: 0/0} +T21851_2.$wg [InlPrag=[2], Occ=LoopBreaker] + :: forall {a}. (Ord a, Num a) => a -> (# a, String #) +[GblId[StrictWorker([!])], + Arity=3, + Str=, + Unf=OtherCon []] +T21851_2.$wg + = \ (@a) ($dOrd :: Ord a) ($dNum :: Num a) (n :: a) -> + case < @a $dOrd n (fromInteger @a $dNum lvl2) of { + False -> + T21851_2.$wg + @a $dOrd $dNum (- @a $dNum n (fromInteger @a $dNum lvl)); + True -> (# fromInteger @a $dNum lvl1, lvl3 @a #) + } +end Rec } + +-- RHS size: {terms: 13, types: 16, coercions: 0, joins: 0/0} +g [InlPrag=[2]] :: forall a. (Ord a, Num a) => a -> (a, String) +[GblId, + Arity=3, + Str=, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=3,unsat_ok=True,boring_ok=False) + Tmpl= \ (@a) + ($dOrd [Occ=Once1] :: Ord a) + ($dNum [Occ=Once1] :: Num a) + (n [Occ=Once1] :: a) -> + case T21851_2.$wg @a $dOrd $dNum n of + { (# ww [Occ=Once1], ww1 [Occ=Once1] #) -> + (ww, ww1) + }}] +g = \ (@a) ($dOrd :: Ord a) ($dNum :: Num a) (n :: a) -> + case T21851_2.$wg @a $dOrd $dNum n of { (# ww, ww1 #) -> + (ww, ww1) + } + +-- RHS size: {terms: 8, types: 9, coercions: 0, joins: 0/0} +h :: (Int, String) +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=False, ConLike=False, + WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 50 10}] +h = case T21851_2.$w$sg 3# of { (# ww, ww1 #) -> + (GHC.Types.I# ww, ww1) + } + + +------ Local rules for imported ids -------- +"SPEC/T21851_2 $wwombat @Bool" [2] + forall ($dShow :: Show Bool). + T21851_2a.$wwombat @Bool $dShow + = T21851_2.$s$wwombat + + ===================================== testsuite/tests/simplCore/should_compile/T21851_2a.hs ===================================== @@ -0,0 +1,11 @@ +module T21851_2a where + +f :: (Num a, Show b) => a -> b -> String +{-# NOINLINE f #-} +f x y = "no" +{-# RULES "wombat" f = wombat #-} + +wombat :: Show b => Int -> b -> String +{-# INLINEABLE wombat #-} +wombat 0 y = "" +wombat n y = show y ++ wombat (n-1) y ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -442,3 +442,7 @@ test('T22357', normal, compile, ['-O']) # Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) test('T17366', normal, multimod_compile, ['T17366', '-O -v0 -ddump-rule-firings']) test('T17366_AR', [grep_errmsg(r'SPEC')], multimod_compile, ['T17366_AR', '-O -v0 -ddump-rule-firings']) + +# One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl +# Expecting to see $s$wwombat +test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) ===================================== testsuite/tests/stranal/should_compile/T22388.hs ===================================== @@ -0,0 +1,14 @@ +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Unboxing through unboxed tuples] +module T22388 where + +-- Don't split, because neither the result not arg cancels away a box. +boring :: (# Int, Int, Int #) -> (# Int, Int, Int #) +boring (# x, y, z #) = (# y, z, x #) +{-# NOINLINE boring #-} + +-- Do split, because we get to drop z and pass x and y unboxed +interesting :: (# Int, Int, Int #) -> (# Int #) +interesting (# x, y, z #) = let !t = x + y in (# t #) +{-# NOINLINE interesting #-} ===================================== testsuite/tests/stranal/should_compile/T22388.stderr ===================================== @@ -0,0 +1,92 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 48, types: 81, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 8, types: 23, coercions: 0, joins: 0/0} +boring [InlPrag=NOINLINE] + :: (# Int, Int, Int #) -> (# Int, Int, Int #) +[GblId, Arity=1, Str=<1!P(L,L,L)>, Cpr=1, Unf=OtherCon []] +boring + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# x, y, z #) -> (# y, z, x #) } + +-- RHS size: {terms: 5, types: 2, coercions: 0, joins: 0/0} +T22388.$winteresting [InlPrag=NOINLINE] + :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId, Arity=2, Str=, Unf=OtherCon []] +T22388.$winteresting + = \ (ww :: GHC.Prim.Int#) (ww1 :: GHC.Prim.Int#) -> + GHC.Prim.+# ww ww1 + +-- RHS size: {terms: 18, types: 24, coercions: 0, joins: 0/0} +interesting [InlPrag=NOINLINE[final]] + :: (# Int, Int, Int #) -> (# Int #) +[GblId, + Arity=1, + Str=<1!P(1!P(L),1!P(L),A)>, + Cpr=1(1), + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) + Tmpl= \ (ds [Occ=Once1!] :: (# Int, Int, Int #)) -> + case ds of + { (# ww [Occ=Once1!], ww1 [Occ=Once1!], _ [Occ=Dead] #) -> + case ww of { GHC.Types.I# ww3 [Occ=Once1] -> + case ww1 of { GHC.Types.I# ww4 [Occ=Once1] -> + case T22388.$winteresting ww3 ww4 of ww5 [Occ=Once1] { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + }}] +interesting + = \ (ds :: (# Int, Int, Int #)) -> + case ds of { (# ww, ww1, ww2 #) -> + case ww of { GHC.Types.I# ww3 -> + case ww1 of { GHC.Types.I# ww4 -> + case T22388.$winteresting ww3 ww4 of ww5 { __DEFAULT -> + (# GHC.Types.I# ww5 #) + } + } + } + } + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule4 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}] +T22388.$trModule4 = "main"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule3 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule3 = GHC.Types.TrNameS T22388.$trModule4 + +-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule2 :: GHC.Prim.Addr# +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 0}] +T22388.$trModule2 = "T22388"# + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule1 :: GHC.Types.TrName +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule1 = GHC.Types.TrNameS T22388.$trModule2 + +-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0} +T22388.$trModule :: GHC.Types.Module +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22388.$trModule + = GHC.Types.Module T22388.$trModule3 T22388.$trModule1 + + + ===================================== testsuite/tests/stranal/should_compile/all.T ===================================== @@ -86,3 +86,5 @@ test('T21128', [ grep_errmsg(r'let { y = I\#') ], multimod_compile, ['T21128', ' test('T21265', normal, compile, ['']) test('EtaExpansion', normal, compile, ['']) test('T22039', normal, compile, ['']) +# T22388: Should see $winteresting but not $wboring +test('T22388', [ grep_errmsg(r'^\S+\$w\S+') ], compile, ['-dsuppress-uniques -ddump-simpl']) ===================================== testsuite/tests/stranal/sigs/T21737.hs ===================================== @@ -0,0 +1,47 @@ +{-# OPTIONS_GHC -fmax-worker-args=4 #-} + +{-# LANGUAGE MagicHash, UnboxedTuples #-} + +-- See Note [Worker argument budget] +module T21737 where + +data T = MkT (# Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- We should unbox through the unboxed pair but not T +{-# NOINLINE f #-} +f :: Int -> (# Int, Int #) -> T -> Int +f x (# y, z #) (MkT (# x1, x2, x3, x4 #)) = x + y + z + x1 + x2 + x3 + x4 + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the triple *even if* that gets us to 6 args, +-- because the triple will take 3 registers anyway (not 1) +-- and we get to unbox a b c. +yes :: (# Int, Int, Int #) -> Int -> Int -> Int -> Int +yes (# a, b, c #) d e f = a + b + c + d + e + f +{-# NOINLINE yes #-} + +data U = MkU (# Int, Int, Int, Int, Int, Int #) + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Don't unbox U, because then we'll pass an unboxed 6-tuple, all in registers. +no :: U -> Int +no (MkU (# a, b, c, d, e, f #)) = a + b + c + d + e + f +{-# NOINLINE no #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Hence do not unbox the nested triple. +boxed :: (Int, Int) -> (Int, (Int, Int, Int)) -> Int +boxed (a,b) (c, (d,e,f)) = a + b + c + d + e + f +{-# NOINLINE boxed #-} + +-- NB: -fmax-worker-args=4 at the top of this file! +-- Do split the inner unboxed triple *even if* that gets us to 5 args, because +-- the function will take 5 args anyway. But don't split the pair! +unboxed :: (Int, Int) -> (# Int, (# Int, Int, Int #) #) -> Int +unboxed (a,b) (# c, (# d, e, f #) #) = a + b + c + d + e + f +{-# NOINLINE unboxed #-} + +-- Point: Demand on `x` is lazy and thus Unboxed +app :: ((# Int, Int #) -> (# Int, Int #)) -> (# Int, Int #) -> (# Int, Int #) +app g x = g x ===================================== testsuite/tests/stranal/sigs/T21737.stderr ===================================== @@ -0,0 +1,30 @@ + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + + +==================== Cpr signatures ==================== +T21737.app: +T21737.boxed: 1 +T21737.f: 1 +T21737.no: 1 +T21737.unboxed: 1 +T21737.yes: 1 + + + +==================== Strictness signatures ==================== +T21737.app: <1C(1,L)> +T21737.boxed: <1!P(1!P(L),1!P(L))><1!P(1!P(L),1P(1L,1L,1L))> +T21737.f: <1!P(L)><1!P(1!P(L),1!P(L))><1P(1P(1L,1L,1L,1L))> +T21737.no: <1P(1P(1L,1L,1L,1L,1L,1L))> +T21737.unboxed: <1P(1L,1L)><1!P(1!P(L),1!P(1!P(L),1!P(L),1!P(L)))> +T21737.yes: <1!P(1!P(L),1!P(L),1!P(L))><1!P(L)><1!P(L)><1!P(L)> + + ===================================== testsuite/tests/stranal/sigs/all.T ===================================== @@ -38,3 +38,4 @@ test('T21754', normal, compile, ['']) test('T21888', normal, compile, ['']) test('T21888a', normal, compile, ['']) test('T22241', normal, compile, ['']) +test('T21737', normal, compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/299d21bbe03d4e054be7702b495f792f99898dfd...13b7c9ef64d7505116373a297a9074500d61764f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/299d21bbe03d4e054be7702b495f792f99898dfd...13b7c9ef64d7505116373a297a9074500d61764f You're receiving 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 Nov 11 05:11:00 2022 From: gitlab at gitlab.haskell.org (Alex D (@nineonine)) Date: Fri, 11 Nov 2022 00:11:00 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22043 Message-ID: <636dd9649281_10da054796c9810841e0@gitlab.mail> Alex D pushed new branch wip/T22043 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22043 You're receiving 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 Nov 11 05:27:12 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 00:27:12 -0500 Subject: [Git][ghc/ghc][master] 42 commits: autoconf: check getpid getuid raise Message-ID: <636ddd30db3ff_10da05322620001093330@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 25 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - + compiler/GHC/CmmToAsm/Wasm.hs - + compiler/GHC/CmmToAsm/Wasm/Asm.hs - + compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - + compiler/GHC/CmmToAsm/Wasm/Types.hs - + compiler/GHC/CmmToAsm/Wasm/Utils.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - + compiler/GHC/Data/Graph/Collapse.hs - + compiler/GHC/Data/Graph/Inductive/Graph.hs - + compiler/GHC/Data/Graph/Inductive/LICENSE The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1230c2689db2e510b5a9b280c1a4eca832c23ccc...8e6ae8827a75ae2d44e1c08098f3a68fd39c2a24 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1230c2689db2e510b5a9b280c1a4eca832c23ccc...8e6ae8827a75ae2d44e1c08098f3a68fd39c2a24 You're receiving 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 Nov 11 05:27:49 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 00:27:49 -0500 Subject: [Git][ghc/ghc][master] Clarify that LLVM upper bound is non-inclusive during configure (#22411) Message-ID: <636ddd5539d36_10da054a1b79810969cf@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 1 changed file: - m4/find_llvm_prog.m4 Changes: ===================================== m4/find_llvm_prog.m4 ===================================== @@ -18,15 +18,15 @@ AC_DEFUN([FIND_LLVM_PROG],[ AS_IF([test x"$PROG_VERSION" = x], [AC_MSG_RESULT(no) $1="" - AC_MSG_NOTICE([We only support llvm $3 to $4 (no version found).])], + AC_MSG_NOTICE([We only support llvm $3 upto $4 (non-inclusive) (no version found).])], [AC_MSG_CHECKING([$$1 version ($PROG_VERSION) is between $3 and $4]) AX_COMPARE_VERSION([$PROG_VERSION], [lt], [$3], [AC_MSG_RESULT(no) $1="" - AC_MSG_NOTICE([We only support llvm $3 to $4 (found $PROG_VERSION).])], + AC_MSG_NOTICE([We only support llvm $3 upto $4 (non-inclusive) (found $PROG_VERSION).])], [AX_COMPARE_VERSION([$PROG_VERSION], [ge], [$4], [AC_MSG_RESULT(no) $1="" - AC_MSG_NOTICE([We only support llvm $3 to $4 (found $PROG_VERSION).])], + AC_MSG_NOTICE([We only support llvm $3 upto $4 (non-inclusive) (found $PROG_VERSION).])], [AC_MSG_RESULT(yes)])])])]) ]) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/707d5651e17c8cbc95c67f89a3dca7a4d4b03e49 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/707d5651e17c8cbc95c67f89a3dca7a4d4b03e49 You're receiving 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 Nov 11 08:54:04 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 11 Nov 2022 03:54:04 -0500 Subject: [Git][ghc/ghc][wip/T22434] 44 commits: autoconf: check getpid getuid raise Message-ID: <636e0dac3c18b_102acb50fdc114c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22434 at Glasgow Haskell Compiler / GHC Commits: 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - df9c6c43 by Simon Peyton Jones at 2022-11-11T08:55:53+00:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 25 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - + compiler/GHC/CmmToAsm/Wasm.hs - + compiler/GHC/CmmToAsm/Wasm/Asm.hs - + compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - + compiler/GHC/CmmToAsm/Wasm/Types.hs - + compiler/GHC/CmmToAsm/Wasm/Utils.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - + compiler/GHC/Data/Graph/Collapse.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/13b7c9ef64d7505116373a297a9074500d61764f...df9c6c436963a435b0f7d79b9d1e515bcff13044 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/13b7c9ef64d7505116373a297a9074500d61764f...df9c6c436963a435b0f7d79b9d1e515bcff13044 You're receiving 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 Nov 11 09:51:31 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 11 Nov 2022 04:51:31 -0500 Subject: [Git][ghc/ghc][wip/T22439] 49 commits: Fire RULES in the Specialiser Message-ID: <636e1b2372ec4_1137665193c7686c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22439 at Glasgow Haskell Compiler / GHC Commits: f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 159cc2d9 by Simon Peyton Jones at 2022-11-11T09:53:19+00:00 Improve the Lint checking for empty cases - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - + compiler/GHC/CmmToAsm/Wasm.hs - + compiler/GHC/CmmToAsm/Wasm/Asm.hs - + compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - + compiler/GHC/CmmToAsm/Wasm/Types.hs - + compiler/GHC/CmmToAsm/Wasm/Utils.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/SetLevels.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c5092ac4c9f2620b8cd38737040358781c99d54...159cc2d9b171aec17293c5f167c783a04d972a41 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5c5092ac4c9f2620b8cd38737040358781c99d54...159cc2d9b171aec17293c5f167c783a04d972a41 You're receiving 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 Nov 11 11:17:03 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 11 Nov 2022 06:17:03 -0500 Subject: [Git][ghc/ghc][wip/T22416] 49 commits: Fire RULES in the Specialiser Message-ID: <636e2f2fbe45e_113766539a8962a3@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22416 at Glasgow Haskell Compiler / GHC Commits: f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 85989124 by Simon Peyton Jones at 2022-11-11T11:18:43+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - + compiler/GHC/CmmToAsm/Wasm.hs - + compiler/GHC/CmmToAsm/Wasm/Asm.hs - + compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - + compiler/GHC/CmmToAsm/Wasm/Types.hs - + compiler/GHC/CmmToAsm/Wasm/Utils.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core.hs - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/InstEnv.hs - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/Monad.hs - compiler/GHC/Core/Opt/Pipeline.hs - compiler/GHC/Core/Opt/Simplify.hs - compiler/GHC/Core/Opt/Simplify/Monad.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cfe9b5c6dd0a70af7c6901c2f2d1915e920f6b67...859891248205829cd71abab5de054e9242761adf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/cfe9b5c6dd0a70af7c6901c2f2d1915e920f6b67...859891248205829cd71abab5de054e9242761adf You're receiving 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 Nov 11 13:27:48 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 11 Nov 2022 08:27:48 -0500 Subject: [Git][ghc/ghc][wip/T22439] Improve the Lint checking for empty cases Message-ID: <636e4dd42e7f1_24229e526e8921b8@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22439 at Glasgow Haskell Compiler / GHC Commits: 1289ccbc by Simon Peyton Jones at 2022-11-11T13:29:36+00:00 Improve the Lint checking for empty cases - - - - - 4 changed files: - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/Arity.hs - compiler/GHC/Core/Opt/SetLevels.hs - compiler/GHC/Core/Utils.hs Changes: ===================================== compiler/GHC/Core/Lint.hs ===================================== @@ -56,7 +56,7 @@ import GHC.Core.TyCon as TyCon import GHC.Core.Coercion.Axiom import GHC.Core.Unify import GHC.Core.Coercion.Opt ( checkAxInstCo ) -import GHC.Core.Opt.Arity ( typeArity, exprIsDeadEnd ) +import GHC.Core.Opt.Arity ( typeArity, tryHardExprIsDeadEnd ) import GHC.Core.Opt.Monad @@ -84,7 +84,6 @@ import GHC.Data.List.SetOps import GHC.Utils.Monad import GHC.Utils.Outputable as Outputable import GHC.Utils.Panic -import GHC.Utils.Constants (debugIsOn) import GHC.Utils.Misc import GHC.Utils.Error import qualified GHC.Utils.Error as Err @@ -1227,49 +1226,6 @@ Utterly bogus. `f` expects an `Int` and we are giving it an `Age`. No no no. Casts destroy the tail-call property. Henc markAllJoinsBad in the (Cast expr co) case of lintCoreExpr. -Note [No alternatives lint check] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Case expressions with no alternatives are odd beasts, and it would seem -like they would worth be looking at in the linter (cf #10180). We -used to check two things: - -* exprIsHNF is false: it would *seem* to be terribly wrong if - the scrutinee was already in head normal form. - -* exprIsDeadEnd is true: we should be able to see why GHC believes the - scrutinee is diverging for sure. - -It was already known that the second test was not entirely reliable. -Unfortunately (#13990), the first test turned out not to be reliable -either. Getting the checks right turns out to be somewhat complicated. - -For example, suppose we have (comment 8) - - data T a where - TInt :: T Int - - absurdTBool :: T Bool -> a - absurdTBool v = case v of - - data Foo = Foo !(T Bool) - - absurdFoo :: Foo -> a - absurdFoo (Foo x) = absurdTBool x - -GHC initially accepts the empty case because of the GADT conditions. But then -we inline absurdTBool, getting - - absurdFoo (Foo x) = case x of - -x is in normal form (because the Foo constructor is strict) but the -case is empty. To avoid this problem, GHC would have to recognize -that matching on Foo x is already absurd, which is not so easy. - -More generally, we don't really know all the ways that GHC can -lose track of why an expression is bottom, so we shouldn't make too -much fuss when that happens. - - Note [Beta redexes] ~~~~~~~~~~~~~~~~~~~ Consider: @@ -1434,55 +1390,45 @@ lintTyKind tyvar arg_ty -} lintCaseExpr :: CoreExpr -> Id -> Type -> [CoreAlt] -> LintM (LintedType, UsageEnv) -lintCaseExpr scrut var alt_ty alts = - do { let e = Case scrut var alt_ty alts -- Just for error messages +lintCaseExpr scrut case_bndr alt_ty alts = + do { let e = Case scrut case_bndr alt_ty alts -- Just for error messages -- Check the scrutinee ; (scrut_ty, scrut_ue) <- markAllJoinsBad $ lintCoreExpr scrut -- See Note [Join points are less general than the paper] -- in GHC.Core - ; let scrut_mult = varMult var + ; let scrut_mult = varMult case_bndr ; alt_ty <- addLoc (CaseTy scrut) $ lintValueType alt_ty - ; var_ty <- addLoc (IdTy var) $ - lintValueType (idType var) - -- We used to try to check whether a case expression with no - -- alternatives was legitimate, but this didn't work. - -- See Note [No alternatives lint check] for details. + -- Don't use lintIdBndr on case_bndr, because unboxed tuple is legitimate + ; case_bndr_ty <- addLoc (IdTy case_bndr) $ + lintValueType (idType case_bndr) -- Check that the scrutinee is not a floating-point type -- if there are any literal alternatives -- See GHC.Core Note [Case expression invariants] item (5) -- See Note [Rules for floating-point comparisons] in GHC.Core.Opt.ConstantFold - ; let isLitPat (Alt (LitAlt _) _ _) = True - isLitPat _ = False - ; checkL (not $ isFloatingPrimTy scrut_ty && any isLitPat alts) + ; let is_lit_alt (Alt (LitAlt _) _ _) = True + is_lit_alt _ = False + ; checkL (not $ isFloatingPrimTy scrut_ty && any is_lit_alt alts) (text "Lint warning: Scrutinising floating-point expression with literal pattern in case analysis (see #9238)." $$ text "scrut" <+> ppr scrut) - ; case tyConAppTyCon_maybe (idType var) of - Just tycon - | debugIsOn - , isAlgTyCon tycon - , not (isAbstractTyCon tycon) - , null (tyConDataCons tycon) - , not (exprIsDeadEnd scrut) - -> pprTrace "Lint warning: case binder's type has no constructors" (ppr var <+> ppr (idType var)) - -- This can legitimately happen for type families - $ return () - _otherwise -> return () - - -- Don't use lintIdBndr on var, because unboxed tuple is legitimate + -- Check whether a case expression with no alternatives is legitimate. + -- See Note [No alternatives lint check] for details. + ; checkL (not (null alts) || tryHardExprIsDeadEnd scrut) $ + hang (text "Illegal empty case") + 2 (ppr case_bndr <+> ppr case_bndr_ty $$ ppr e) ; subst <- getSubst - ; ensureEqTys var_ty scrut_ty (mkScrutMsg var var_ty scrut_ty subst) + ; ensureEqTys case_bndr_ty scrut_ty (mkScrutMsg case_bndr case_bndr_ty scrut_ty subst) -- See GHC.Core Note [Case expression invariants] item (7) - ; lintBinder CaseBind var $ \_ -> + ; lintBinder CaseBind case_bndr $ \_ -> do { -- Check the alternatives - ; alt_ues <- mapM (lintCoreAlt var scrut_ty scrut_mult alt_ty) alts + ; alt_ues <- mapM (lintCoreAlt case_bndr scrut_ty scrut_mult alt_ty) alts ; let case_ue = (scaleUE scrut_mult scrut_ue) `addUE` supUEs alt_ues ; checkCaseAlts e scrut_ty alts ; return (alt_ty, case_ue) } } @@ -1584,6 +1530,42 @@ lintCoreAlt case_bndr scrut_ty _scrut_mult alt_ty alt@(Alt (DataAlt con) args rh = zeroUE <$ addErrL (mkBadAltMsg scrut_ty alt) {- +Note [No alternatives lint check] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Case expressions with no alternatives are odd beasts, and it would seem +like they would worth be looking at in the linter (cf #10180). We check +that the scrutinee is definitely diverging, using exprIsDeadEnd. + +Note that exprIsDeadEnv checks for /two/ things: +* Type: the type is empty; see Note [Empty types] in GHC.Core.Utils +* Value: the value visibly bottoming; e.g. (error "urk") +See Note [Bottoming expressions] in GHC.Core.Opt.Arity + +--- Historical note --- + +We used to check that exprIsHNF is False for a no-alternative case; +but that's not quite right (#13990). Consider: + + data T a = T1 !(F a) | T2 Int + data DataConCantHappen -- No constructors + type instance F Bool = DataConCantHappen + + f (x::T Bool) = case x of + T1 v -> case (v |> co) of {} + T2 x -> blah + + where co :: F Bool ~ Void + +Now T1 is in fact inaccessible: it is a strict constructor and there +are no inhabitants of (F Bool) = DataConCantHappen. GHC itself uses +this a lot in HsSyn to make inactive constructors inaccessible. + +However in this example `v` is marked "evaluated" because it is a +strict field; so the scrutinee responds True to exprIsHNF. It's +all fine; but don't complain about exprIsHNF. + +--- End of historical note --- + Note [Validating multiplicities in a case] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppose 'MkT :: a %m -> T m a'. ===================================== compiler/GHC/Core/Opt/Arity.hs ===================================== @@ -27,7 +27,9 @@ module GHC.Core.Opt.Arity , arityTypeArity, idArityType -- ** Bottoming things - , exprIsDeadEnd, exprBotStrictness_maybe, arityTypeBotSigs_maybe + , exprIsDeadEnd, tryHardExprIsDeadEnd + , arityTypeBotSigs_maybe + , exprBotStrictness_maybe, idBotStrictness_maybe -- ** typeArity and the state hack , typeArity, typeOneShots, typeOneShot @@ -146,13 +148,21 @@ exprBotStrictness_maybe e = arityTypeBotSigs_maybe (cheapArityType e) arityTypeBotSigs_maybe :: ArityType -> Maybe (Arity, DmdSig, CprSig) -- Arity of a divergent function arityTypeBotSigs_maybe (AT lams div) - | isDeadEndDiv div = Just ( arity - , mkVanillaDmdSig arity botDiv + | isDeadEndDiv div = Just (arity + , mkVanillaDmdSig arity div , mkCprSig arity botCpr) | otherwise = Nothing where arity = length lams +idBotStrictness_maybe :: Id -> Maybe (Arity, DmdSig, CprSig) +idBotStrictness_maybe id + | isDeadEndDiv div = Just (length dmds, dmd_sig, idCprSig id) + | otherwise = Nothing + where + (dmds, div) = splitDmdSig dmd_sig + dmd_sig = idDmdSig id + {- Note [exprArity for applications] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1652,15 +1662,22 @@ exprArity e = go e go _ = 0 --------------- -exprIsDeadEnd :: CoreExpr -> Bool +exprIsDeadEnd, tryHardExprIsDeadEnd :: CoreExpr -> Bool +tryHardExprIsDeadEnd e = expr_is_dead_end True e +exprIsDeadEnd e = expr_is_dead_end False e + +expr_is_dead_end :: Bool -> CoreExpr -> Bool -- See Note [Bottoming expressions] -- This function is, in effect, just a specialised (and hence cheap) -- version of cheapArityType: -- exprIsDeadEnd e = case cheapArityType e of -- AT lams div -> null lams && isDeadEndDiv div +-- The try_hard flag governs how hard it tries to find the right +-- answer. It's always OK to say False +-- -- See also exprBotStrictness_maybe, which uses cheapArityType -exprIsDeadEnd e - = go 0 e +expr_is_dead_end try_hard e + = go 0 e || isEmptyTy (exprType e) where go :: Arity -> CoreExpr -> Bool -- (go n e) = True <=> expr applied to n value args is bottom @@ -1675,11 +1692,13 @@ exprIsDeadEnd e go n (Lam v e) | isTyVar v = go n e | otherwise = False - go _ (Case _ _ _ alts) = null alts - -- See Note [Empty case alternatives] in GHC.Core + go n (Case scrut _ _ alts) + | not try_hard = null alts + | otherwise = go 0 scrut || and [ go n rhs | Alt _ _ rhs <- alts ] + -- If try_hard then look at scrutinee and all alternatives + -- See Note [Empty case alternatives] in GHC.Core go n (Var v) | isDeadEndAppSig (idDmdSig v) n = True - | isEmptyTy (idType v) = True | otherwise = False {- Note [Bottoming expressions] @@ -1692,24 +1711,26 @@ checks for both of these situations: (error Int "Hello") is visibly bottom. The strictness analyser also finds out if a function diverges or raises an exception, and puts that info - in its strictness signature. + in its strictness signature. The `go` function spots this. -* Empty types. If a type is empty, its only inhabitant is bottom. - For example: - data T - f :: T -> Bool - f = \(x:t). case x of Bool {} +* Empty types. The `isEmptyTy` function spots this. If a type is empty, its + only inhabitant is bottom. For example: + data Empty -- No constructors + f :: Empty -> Bool + f = \(x:Empty). case x of Bool {} Since T has no data constructors, the case alternatives are of course empty. However note that 'x' is not bound to a visibly-bottom value; it's the *type* that tells us it's going to diverge. -A GADT may also be empty even though it has constructors: - data T a where - T1 :: a -> T Bool - T2 :: T Int - ...(case (x::T Char) of {})... -Here (T Char) is uninhabited. A more realistic case is (Int ~ Bool), -which is likewise uninhabited. +Wrinkles: + +(W1) isEmptyTy: a GADT may also be empty even though it has constructors: + data G a where + G1 :: a -> G Bool + g2 :: G Int + ...(case (x::G Char) of {})... + Here (G Char) is uninhabited. A more realistic case is (Int ~ Bool), + which is likewise uninhabited. See Note [Empty types] in GHC.Core.Utils Note [No free join points in arityType] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ===================================== compiler/GHC/Core/Opt/SetLevels.hs ===================================== @@ -73,7 +73,7 @@ import GHC.Core.Utils ( exprType, exprIsHNF , collectMakeStaticArgs , mkLamTypes, extendInScopeSetBndrs ) -import GHC.Core.Opt.Arity ( exprBotStrictness_maybe, isOneShotBndr ) +import GHC.Core.Opt.Arity ( exprBotStrictness_maybe, idBotStrictness_maybe, isOneShotBndr ) import GHC.Core.FVs -- all of it import GHC.Core.Subst import GHC.Core.Make ( sortQuantVars ) @@ -1094,7 +1094,7 @@ lvlBind :: LevelEnv -> LvlM (LevelledBind, LevelEnv) lvlBind env (AnnNonRec bndr rhs) - | isTyVar bndr -- Don't do anything for TyVar binders + | is_tyvar -- Don't do anything for TyVar binders -- (simplifier gets rid of them pronto) || isCoVar bndr -- Difficult to fix up CoVar occurrences (see extendPolyLvlEnv) -- so we will ignore this case for now @@ -1105,7 +1105,9 @@ lvlBind env (AnnNonRec bndr rhs) -- bit brutal, but unlifted bindings aren't expensive either = -- No float - do { rhs' <- lvlRhs env NonRecursive is_bot_lam mb_join_arity rhs + do { rhs' <- if is_tyvar + then lvlExpr env rhs + else lvlRhs env NonRecursive is_bot_lam mb_join_arity rhs ; let bind_lvl = incMinorLvl (le_ctxt_lvl env) (env', [bndr']) = substAndLvlBndrs NonRecursive env bind_lvl [bndr] ; return (NonRec bndr' rhs', env') } @@ -1128,6 +1130,8 @@ lvlBind env (AnnNonRec bndr rhs) ; return (NonRec (TB bndr2 (FloatMe dest_lvl)) rhs', env') } where + is_tyvar = isTyVar bndr + deann_rhs = deAnnotate rhs bndr_ty = idType bndr ty_fvs = tyCoVarsOfType bndr_ty rhs_fvs = freeVarsOf rhs @@ -1135,11 +1139,13 @@ lvlBind env (AnnNonRec bndr rhs) abs_vars = abstractVars dest_lvl env bind_fvs dest_lvl = destLevel env bind_fvs ty_fvs (isFunction rhs) is_bot_lam is_join - deann_rhs = deAnnotate rhs - mb_bot_str = exprBotStrictness_maybe deann_rhs + mb_bot_str = idBotStrictness_maybe bndr is_bot_lam = isJust mb_bot_str - -- is_bot_lam: looks like (\xy. bot), maybe zero lams - -- NB: not isBottomThunk! See Note [Bottoming floats] point (3) + -- The Simplifier pins on strictness info, based on a call to arityType + -- Using that is faster and more accurate than calling exprBotStrictness_maybe + -- is_bot_lam: looks like (\xy. bot), maybe zero lams + -- NB: not isBottomThunk! See Note [Bottoming floats] point (3) + -- NB: these two defns only work for Ids, not TyVars n_extra = count isId abs_vars mb_join_arity = isJoinId_maybe bndr ===================================== compiler/GHC/Core/Utils.hs ===================================== @@ -2281,34 +2281,37 @@ locBind loc b1 b2 diffs = map addLoc diffs | otherwise = ppr b1 <> char '/' <> ppr b2 -{- ********************************************************************* +{- +************************************************************************ * * -\subsection{Determining non-updatable right-hand-sides} + Type utilities * * ************************************************************************ -Top-level constructor applications can usually be allocated -statically, but they can't if the constructor, or any of the -arguments, come from another DLL (because we can't refer to static -labels in other DLLs). +Note [Empty types] +~~~~~~~~~~~~~~~~~~ +For a type `ty`, if (isEmptyTy ty) is True, then bottom is the only +inhabitant of `ty`. So if (e :: ty), we know that `e` must diverge. -If this happens we simply make the RHS into an updatable thunk, -and 'execute' it rather than allocating it statically. --} +How can a type be empty? -{- -************************************************************************ -* * -\subsection{Type utilities} -* * -************************************************************************ +* It is a data type with no constructors. e.g. + data T a + Then (T Int) and (T b) are empty types + +* It is a GADT, but the type parameters excludes all the constructors. e.g. + data G a where + G1 :: G Int + G2 :: G Bool + Then (G Char) is empty, because no value can have that type. But G itself + isn't an empty type -- it certainly has data constructors. + +See Note [Bottoming expressions] in GHC.Core.Opt.Arity +See Note [No alternatives lint check] in GHC.Core.Lint -} --- | True if the type has no non-bottom elements, e.g. when it is an empty --- datatype, or a GADT with non-satisfiable type parameters, e.g. Int :~: Bool. --- See Note [Bottoming expressions] --- --- See Note [No alternatives lint check] for another use of this function. +-- | True if the type has no non-bottom elements +-- See Note [Empty types] isEmptyTy :: Type -> Bool isEmptyTy ty -- Data types where, given the particular type parameters, no data View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1289ccbc7356a5df69944af7c2ed405c71aba34b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1289ccbc7356a5df69944af7c2ed405c71aba34b You're receiving 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 Nov 11 15:23:13 2022 From: gitlab at gitlab.haskell.org (Richard Eisenberg (@rae)) Date: Fri, 11 Nov 2022 10:23:13 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/p547 Message-ID: <636e68e129199_24229e527d810003e@gitlab.mail> Richard Eisenberg pushed new branch wip/p547 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/p547 You're receiving 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 Nov 11 15:37:03 2022 From: gitlab at gitlab.haskell.org (Richard Eisenberg (@rae)) Date: Fri, 11 Nov 2022 10:37:03 -0500 Subject: [Git][ghc/ghc][wip/p547] 5 commits: Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) Message-ID: <636e6c1f90892_24229e526ac1075dc@gitlab.mail> Richard Eisenberg pushed to branch wip/p547 at Glasgow Haskell Compiler / GHC Commits: 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - e2f9360b by Simon Peyton Jones at 2022-11-10T10:03:42+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 30ee3c05 by Simon Peyton Jones at 2022-11-10T14:14:47+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - d71039a7 by Richard Eisenberg at 2022-11-11T10:36:53-05:00 Remove kind constraints - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5080d0fca046041ccfb82e0fa3767043459b1db4...d71039a72f68f7ac9c5826e931d5e4443223cb58 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5080d0fca046041ccfb82e0fa3767043459b1db4...d71039a72f68f7ac9c5826e931d5e4443223cb58 You're receiving 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 Nov 11 16:06:43 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 11:06:43 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 46 commits: autoconf: check getpid getuid raise Message-ID: <636e731327850_24229e5277411917@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 7e072f21 by Ben Gamari at 2022-11-11T11:06:36-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 4649f329 by Matthew Pickering at 2022-11-11T11:06:37-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - 94aa0db1 by Simon Peyton Jones at 2022-11-11T11:06:38-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 25 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - + compiler/GHC/CmmToAsm/Wasm.hs - + compiler/GHC/CmmToAsm/Wasm/Asm.hs - + compiler/GHC/CmmToAsm/Wasm/FromCmm.hs - + compiler/GHC/CmmToAsm/Wasm/Types.hs - + compiler/GHC/CmmToAsm/Wasm/Utils.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - + compiler/GHC/Data/Graph/Collapse.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/573f92d92b3ee7928c2e5fd46efc3e723be9bf64...94aa0db1f2a930bfadb50e09f6930cc708d5c523 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/573f92d92b3ee7928c2e5fd46efc3e723be9bf64...94aa0db1f2a930bfadb50e09f6930cc708d5c523 You're receiving 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 Nov 11 16:25:23 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 11 Nov 2022 11:25:23 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22452 Message-ID: <636e777337e04_24229e526ac1309c@gitlab.mail> Ben Gamari pushed new branch wip/T22452 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22452 You're receiving 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 Nov 11 16:27:44 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 11 Nov 2022 11:27:44 -0500 Subject: [Git][ghc/ghc][wip/T22452] eventlog: Ensure that IPE output contains actual info table pointers Message-ID: <636e780013a4f_24229e527c4131181@gitlab.mail> Ben Gamari pushed to branch wip/T22452 at Glasgow Haskell Compiler / GHC Commits: d90d7165 by Ben Gamari at 2022-11-11T11:26:01-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). - - - - - 2 changed files: - rts/eventlog/EventLog.c - rts/include/rts/IPE.h Changes: ===================================== rts/eventlog/EventLog.c ===================================== @@ -1429,7 +1429,7 @@ void postIPE(const InfoProvEnt *ipe) ensureRoomForVariableEvent(&eventBuf, len); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); - postWord64(&eventBuf, (StgWord) ipe->info); + postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postString(&eventBuf, ipe->prov.table_name); postString(&eventBuf, ipe->prov.closure_desc); postString(&eventBuf, ipe->prov.ty_desc); ===================================== rts/include/rts/IPE.h ===================================== @@ -24,6 +24,8 @@ typedef struct InfoProv_ { } InfoProv; typedef struct InfoProvEnt_ { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; InfoProv prov; } InfoProvEnt; @@ -50,6 +52,8 @@ typedef uint32_t StringIdx; // The size of this must be a multiple of the word size // to ensure correct packing. typedef struct { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; StringIdx table_name; StringIdx closure_desc; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d90d716517ad523e3d5785b205bfeeed6c64e9a9 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d90d716517ad523e3d5785b205bfeeed6c64e9a9 You're receiving 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 Nov 11 16:27:55 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Fri, 11 Nov 2022 11:27:55 -0500 Subject: [Git][ghc/ghc][wip/T22452] eventlog: Ensure that IPE output contains actual info table pointers Message-ID: <636e780b6a637_24229e527601313b9@gitlab.mail> Ben Gamari pushed to branch wip/T22452 at Glasgow Haskell Compiler / GHC Commits: 9b0a5524 by Ben Gamari at 2022-11-11T11:27:44-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - 2 changed files: - rts/eventlog/EventLog.c - rts/include/rts/IPE.h Changes: ===================================== rts/eventlog/EventLog.c ===================================== @@ -1429,7 +1429,7 @@ void postIPE(const InfoProvEnt *ipe) ensureRoomForVariableEvent(&eventBuf, len); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); - postWord64(&eventBuf, (StgWord) ipe->info); + postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postString(&eventBuf, ipe->prov.table_name); postString(&eventBuf, ipe->prov.closure_desc); postString(&eventBuf, ipe->prov.ty_desc); ===================================== rts/include/rts/IPE.h ===================================== @@ -24,6 +24,8 @@ typedef struct InfoProv_ { } InfoProv; typedef struct InfoProvEnt_ { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; InfoProv prov; } InfoProvEnt; @@ -50,6 +52,8 @@ typedef uint32_t StringIdx; // The size of this must be a multiple of the word size // to ensure correct packing. typedef struct { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; StringIdx table_name; StringIdx closure_desc; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b0a5524c12d604b0880357adfafc82e8e936f57 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9b0a5524c12d604b0880357adfafc82e8e936f57 You're receiving 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 Nov 11 17:32:05 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 11 Nov 2022 12:32:05 -0500 Subject: [Git][ghc/ghc][wip/T21623] 50 commits: Fire RULES in the Specialiser Message-ID: <636e871523bff_24229e5276013839c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 2c98005e by Simon Peyton Jones at 2022-11-11T17:33:54+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 48ffe698 by Simon Peyton Jones at 2022-11-11T17:33:54+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 26 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs - compiler/GHC/CmmToAsm/Reg/Linear.hs - compiler/GHC/CmmToAsm/Reg/Linear/FreeRegs.hs - compiler/GHC/CmmToAsm/Reg/Target.hs - + compiler/GHC/CmmToAsm/Wasm.hs - + compiler/GHC/CmmToAsm/Wasm/Asm.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30ee3c05985e5c9e64f66dbdde88db5cfc8a3af6...48ffe6989d59b4f1d0ad0636b39ca05b3c0fcbbe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/30ee3c05985e5c9e64f66dbdde88db5cfc8a3af6...48ffe6989d59b4f1d0ad0636b39ca05b3c0fcbbe You're receiving 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 Nov 11 18:17:02 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 13:17:02 -0500 Subject: [Git][ghc/ghc][master] rts: Check for program_invocation_short_name via autoconf Message-ID: <636e919ebf307_24229e5277415928@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 2 changed files: - configure.ac - rts/Task.c Changes: ===================================== configure.ac ===================================== @@ -918,6 +918,11 @@ AC_CHECK_DECLS([ctime_r], , , #define _POSIX_C_SOURCE 199506L #include ]) +dnl On Linux we should have program_invocation_short_name +AC_CHECK_DECLS([program_invocation_short_name], , , +[#define _GNU_SOURCE 1 +#include ]) + dnl ** check for mingwex library AC_CHECK_LIB( [mingwex], ===================================== rts/Task.c ===================================== @@ -477,7 +477,7 @@ startWorkerTask (Capability *cap) // Set the name of the worker thread to the original process name followed by // ":w", but only if we're on Linux where the program_invocation_short_name // global is available. -#if defined(linux_HOST_OS) +#if defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME) size_t procname_len = strlen(program_invocation_short_name); char worker_name[16]; // The kernel only allocates 16 bytes for thread names, so we truncate if the View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/430eccefaef1bc78a00a5327e6e485299be674a5 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/430eccefaef1bc78a00a5327e6e485299be674a5 You're receiving 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 Nov 11 18:17:46 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 13:17:46 -0500 Subject: [Git][ghc/ghc][master] driver: Fix -fdefer-diagnostics flag Message-ID: <636e91cad4afc_24229e527c41649bb@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - 9 changed files: - compiler/GHC/Driver/Make.hs - + testsuite/tests/driver/t22391/Makefile - + testsuite/tests/driver/t22391/all.T - + testsuite/tests/driver/t22391/src/Lib.hs - + testsuite/tests/driver/t22391/src/Lib/A.hs - + testsuite/tests/driver/t22391/src/Lib/B.hs - + testsuite/tests/driver/t22391/t22391.stderr - + testsuite/tests/driver/t22391/t22391j.stderr - testsuite/tests/ghci/prog018/prog018.stdout Changes: ===================================== compiler/GHC/Driver/Make.hs ===================================== @@ -741,8 +741,8 @@ load' mhmi_cache how_much mHscMessage mod_graph = do Just n -> return n setSession $ hscUpdateHUG (unitEnv_map pruneHomeUnitEnv) hsc_env - hsc_env <- getSession - (upsweep_ok, hsc_env1) <- withDeferredDiagnostics $ + (upsweep_ok, hsc_env1) <- withDeferredDiagnostics $ do + hsc_env <- getSession liftIO $ upsweep n_jobs hsc_env mhmi_cache mHscMessage (toCache pruned_cache) build_plan setSession hsc_env1 case upsweep_ok of ===================================== testsuite/tests/driver/t22391/Makefile ===================================== @@ -0,0 +1,19 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +warnings-ghc-deferred: clean + "$GHC" --make -Wall -fdefer-diagnostics src/Lib.hs src/Lib/A.hs src/Lib/B.hs" + ghc --version + +warnings-ghc-regular: clean + bash -c "ghc --make -Wall src/Lib.hs src/Lib/A.hs src/Lib/B.hs" + ghc --version + +.PHONY: warnings-ghc + +clean: + rm -rf src/**/*.{hi,o} + rm -rf **/*.{hi,o} + +.PHONY: clean ===================================== testsuite/tests/driver/t22391/all.T ===================================== @@ -0,0 +1,5 @@ +test('t22391', [extra_files(['src'])], + multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics']) + +test('t22391j', [req_smp, extra_files(['src'])], + multimod_compile, ['Lib', '-v1 -Wall -fhide-source-paths -isrc -fdefer-diagnostics -j2']) ===================================== testsuite/tests/driver/t22391/src/Lib.hs ===================================== @@ -0,0 +1,11 @@ +module Lib + ( someFunc + ) where + +import Lib.A +import Lib.B + +blah = 3 + +someFunc :: IO () +someFunc = putStrLn "someFunc" ===================================== testsuite/tests/driver/t22391/src/Lib/A.hs ===================================== @@ -0,0 +1,3 @@ +module Lib.A where + +blast = 1 ===================================== testsuite/tests/driver/t22391/src/Lib/B.hs ===================================== @@ -0,0 +1,3 @@ +module Lib.B where + +warnmeup = 4 ===================================== testsuite/tests/driver/t22391/t22391.stderr ===================================== @@ -0,0 +1,43 @@ +[1 of 3] Compiling Lib.A +[2 of 3] Compiling Lib.B +[3 of 3] Compiling Lib + +src/Lib/A.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blast :: Integer + +src/Lib/A.hs:3:9: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘1’ + • In the expression: 1 + In an equation for ‘blast’: blast = 1 + +src/Lib/B.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: warnmeup :: Integer + +src/Lib/B.hs:3:12: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘4’ + • In the expression: 4 + In an equation for ‘warnmeup’: warnmeup = 4 + +src/Lib.hs:5:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.A’ is redundant + except perhaps to import instances from ‘Lib.A’ + To import instances alone, use: import Lib.A() + +src/Lib.hs:6:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.B’ is redundant + except perhaps to import instances from ‘Lib.B’ + To import instances alone, use: import Lib.B() + +src/Lib.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blah :: Integer + +src/Lib.hs:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: ‘blah’ + +src/Lib.hs:8:8: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘3’ + • In the expression: 3 + In an equation for ‘blah’: blah = 3 ===================================== testsuite/tests/driver/t22391/t22391j.stderr ===================================== @@ -0,0 +1,43 @@ +[1 of 3] Compiling Lib.A +[2 of 3] Compiling Lib.B +[3 of 3] Compiling Lib + +src/Lib/A.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blast :: Integer + +src/Lib/A.hs:3:9: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘1’ + • In the expression: 1 + In an equation for ‘blast’: blast = 1 + +src/Lib/B.hs:3:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: warnmeup :: Integer + +src/Lib/B.hs:3:12: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘4’ + • In the expression: 4 + In an equation for ‘warnmeup’: warnmeup = 4 + +src/Lib.hs:5:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.A’ is redundant + except perhaps to import instances from ‘Lib.A’ + To import instances alone, use: import Lib.A() + +src/Lib.hs:6:1: warning: [-Wunused-imports (in -Wextra)] + The import of ‘Lib.B’ is redundant + except perhaps to import instances from ‘Lib.B’ + To import instances alone, use: import Lib.B() + +src/Lib.hs:8:1: warning: [GHC-38417] [-Wmissing-signatures (in -Wall)] + Top-level binding with no type signature: blah :: Integer + +src/Lib.hs:8:1: warning: [-Wunused-top-binds (in -Wextra, -Wunused-binds)] + Defined but not used: ‘blah’ + +src/Lib.hs:8:8: warning: [GHC-18042] [-Wtype-defaults (in -Wall)] + • Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraint + Num a0 arising from the literal ‘3’ + • In the expression: 3 + In an equation for ‘blah’: blah = 3 ===================================== testsuite/tests/ghci/prog018/prog018.stdout ===================================== @@ -1,4 +1,6 @@ [1 of 3] Compiling A ( A.hs, interpreted ) +[2 of 3] Compiling B ( B.hs, interpreted ) +[3 of 3] Compiling C ( C.hs, interpreted ) A.hs:5:1: warning: [GHC-62161] [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive @@ -7,19 +9,14 @@ A.hs:5:1: warning: [GHC-62161] [-Wincomplete-patterns (in -Wextra)] A.hs:8:15: warning: [-Wunused-matches (in -Wextra)] Defined but not used: ‘x’ -[2 of 3] Compiling B ( B.hs, interpreted ) B.hs:7:1: warning: [-Wunused-imports (in -Wextra)] The import of ‘Data.Tuple’ is redundant except perhaps to import instances from ‘Data.Tuple’ To import instances alone, use: import Data.Tuple() -[3 of 3] Compiling C ( C.hs, interpreted ) C.hs:6:7: error: [GHC-88464] Variable not in scope: variableNotInScope :: () Failed, two modules loaded. [3 of 3] Compiling C ( C.hs, interpreted ) - -C.hs:6:7: error: [GHC-88464] - Variable not in scope: variableNotInScope :: () Failed, two modules loaded. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6dab0046b575e102bf3245fd63d5ac6bc6f4204d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6dab0046b575e102bf3245fd63d5ac6bc6f4204d You're receiving 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 Nov 11 18:18:27 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 13:18:27 -0500 Subject: [Git][ghc/ghc][master] Add a fast path for data constructor workers Message-ID: <636e91f360370_24229e526c016853@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3 changed files: - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Types/Id/Make.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Iteration.hs ===================================== @@ -1497,9 +1497,10 @@ rebuild env expr cont ApplyToTy { sc_arg_ty = ty, sc_cont = cont} -> rebuild env (App expr (Type ty)) cont - ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag, sc_cont = cont} + ApplyToVal { sc_arg = arg, sc_env = se, sc_dup = dup_flag + , sc_cont = cont, sc_hole_ty = fun_ty } -- See Note [Avoid redundant simplification] - -> do { (_, _, arg') <- simplArg env dup_flag se arg + -> do { (_, _, arg') <- simplArg env dup_flag fun_ty se arg ; rebuild env (App expr arg') cont } completeBindX :: SimplEnv @@ -1598,7 +1599,8 @@ 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_dup = dup, sc_cont = tail + , sc_hole_ty = fun_ty }) | Just (m_co1, m_co2) <- pushCoValArg co , fixed_rep m_co1 = {-#SCC "addCoerce-pushCoValArg" #-} @@ -1610,7 +1612,7 @@ simplCast env body co0 cont0 -- See Note [Avoiding exponential behaviour] MCo co1 -> - do { (dup', arg_se', arg') <- simplArg env dup arg_se arg + do { (dup', arg_se', arg') <- simplArg env dup fun_ty arg_se arg -- When we build the ApplyTo we can't mix the OutCoercion -- 'co' with the InExpr 'arg', so we simplify -- to make it all consistent. It's a bit messy. @@ -1636,14 +1638,16 @@ simplCast env body co0 cont0 -- See Note [Representation polymorphism invariants] in GHC.Core -- test: typecheck/should_run/EtaExpandLevPoly -simplArg :: SimplEnv -> DupFlag -> StaticEnv -> CoreExpr +simplArg :: SimplEnv -> DupFlag + -> OutType -- Type of the function applied to this arg + -> StaticEnv -> CoreExpr -- Expression with its static envt -> SimplM (DupFlag, StaticEnv, OutExpr) -simplArg env dup_flag arg_env arg +simplArg env dup_flag fun_ty arg_env arg | isSimplified dup_flag = return (dup_flag, arg_env, arg) | otherwise = do { let arg_env' = arg_env `setInScopeFromE` env - ; arg' <- simplExpr arg_env' arg + ; arg' <- simplExprC arg_env' arg (mkBoringStop (funArgTy fun_ty)) ; return (Simplified, zapSubstEnv arg_env', arg') } -- Return a StaticEnv that includes the in-scope set from 'env', -- because arg' may well mention those variables (#20639) @@ -2029,6 +2033,21 @@ zap the SubstEnv. This is VITAL. Consider We'll clone the inner \x, adding x->x' in the id_subst Then when we inline y, we must *not* replace x by x' in the inlined copy!! + +Note [Fast path for data constructors] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For applications of a data constructor worker, the full glory of +rebuildCall is a waste of effort; +* They never inline, obviously +* They have no rewrite rules +* They are not strict (see Note [Data-con worker strictness] + in GHC.Core.DataCon) +So it's fine to zoom straight to `rebuild` which just rebuilds the +call in a very straightforward way. + +Some programs have a /lot/ of data constructors in the source program +(compiler/perf/T9961 is an example), so this fast path can be very +valuable. -} simplVar :: SimplEnv -> InVar -> SimplM OutExpr @@ -2046,6 +2065,9 @@ simplVar env var simplIdF :: SimplEnv -> InId -> SimplCont -> SimplM (SimplFloats, OutExpr) simplIdF env var cont + | isDataConWorkId var -- See Note [Fast path for data constructors] + = rebuild env (Var var) cont + | otherwise = case substId env var of ContEx tvs cvs ids e -> simplExprF env' e cont -- Don't trimJoinCont; haven't already simplified e, @@ -2315,6 +2337,8 @@ field of the ArgInfo record is the state of a little state-machine: If we inline `f` before simplifying `BIG` well use preInlineUnconditionally, and we'll simplify BIG once, at x's occurrence, rather than twice. +* GHC.Core.Opt.Simplify.Utils. mkRewriteCall: if there are no rules, and no + unfolding, we can skip both TryRules and TryInlining, which saves work. Note [Avoid redundant simplification] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3645,7 +3669,7 @@ mkDupableContWithDmds env dmds do { let (dmd:cont_dmds) = dmds -- Never fails ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont ; let env' = env `setInScopeFromF` floats1 - ; (_, se', arg') <- simplArg env' dup se arg + ; (_, se', arg') <- simplArg env' dup hole_ty se arg ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg' ; let all_floats = floats1 `addLetFloats` let_floats2 ; return ( all_floats ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -425,12 +425,22 @@ decArgCount :: RewriteCall -> RewriteCall decArgCount (TryRules n rules) = TryRules (n-1) rules decArgCount rew = rew -mkTryRules :: [CoreRule] -> RewriteCall +mkRewriteCall :: Id -> RuleEnv -> RewriteCall -- See Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration -mkTryRules [] = TryInlining -mkTryRules rs = TryRules n_required rs +-- We try to skip any unnecessary stages: +-- No rules => skip TryRules +-- No unfolding => skip TryInlining +-- This skipping is "just" for efficiency. But rebuildCall is +-- quite a heavy hammer, so skipping stages is a good plan. +-- And it's extremely simple to do. +mkRewriteCall fun rule_env + | not (null rules) = TryRules n_required rules + | canUnfold unf = TryInlining + | otherwise = TryNothing where - n_required = maximum (map ruleArity rs) + n_required = maximum (map ruleArity rules) + rules = getRules rule_env fun + unf = idUnfolding fun {- ************************************************************************ @@ -604,21 +614,23 @@ mkArgInfo :: SimplEnv -> RuleEnv -> Id -> SimplCont -> ArgInfo mkArgInfo env rule_base fun cont | n_val_args < idArity fun -- Note [Unsaturated functions] = ArgInfo { ai_fun = fun, ai_args = [] - , ai_rewrite = fun_rules + , ai_rewrite = fun_rewrite , ai_encl = False , ai_dmds = vanilla_dmds , ai_discs = vanilla_discounts } | otherwise = ArgInfo { ai_fun = fun , ai_args = [] - , ai_rewrite = fun_rules - , ai_encl = notNull rules || contHasRules cont + , ai_rewrite = fun_rewrite + , ai_encl = fun_has_rules || contHasRules cont , ai_dmds = add_type_strictness (idType fun) arg_dmds , ai_discs = arg_discounts } where - rules = getRules rule_base fun - fun_rules = mkTryRules rules - n_val_args = countValArgs cont + n_val_args = countValArgs cont + fun_rewrite = mkRewriteCall fun rule_base + fun_has_rules = case fun_rewrite of + TryRules {} -> True + _ -> False vanilla_discounts, arg_discounts :: [Int] vanilla_discounts = repeat 0 ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -585,6 +585,7 @@ mkDataConWorkId wkr_name data_con `setInlinePragInfo` wkr_inline_prag `setUnfoldingInfo` evaldUnfolding -- Record that it's evaluated, -- even if arity = 0 + -- No strictness: see Note [Data-con worker strictness] in GHC.Core.DataCon wkr_inline_prag = defaultInlinePragma { inl_rule = ConLike } wkr_arity = dataConRepArity data_con View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0c691b6110b11a43d5ea2685d17bc001d2298da -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d0c691b6110b11a43d5ea2685d17bc001d2298da You're receiving 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 Nov 11 18:51:02 2022 From: gitlab at gitlab.haskell.org (Alex D (@nineonine)) Date: Fri, 11 Nov 2022 13:51:02 -0500 Subject: [Git][ghc/ghc][wip/T22043] CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Message-ID: <636e9996b09c_24229e526ac169566@gitlab.mail> Alex D pushed to branch wip/T22043 at Glasgow Haskell Compiler / GHC Commits: 21450670 by nineonine at 2022-11-11T10:50:42-08:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 10 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/HsToCore/Foreign/C.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/ffi.rst - libraries/base/Foreign/C/Types.hs - libraries/unix - + testsuite/tests/ffi/should_compile/T22034.h - + testsuite/tests/ffi/should_compile/T22034.hs - + testsuite/tests/ffi/should_compile/T22034_c.c - testsuite/tests/ffi/should_compile/all.T Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -346,7 +346,7 @@ basicKnownKeyNames zipName, foldrName, buildName, augmentName, appendName, -- FFI primitive types that are not wired-in. - stablePtrTyConName, ptrTyConName, funPtrTyConName, + stablePtrTyConName, ptrTyConName, funPtrTyConName, constPtrConName, int8TyConName, int16TyConName, int32TyConName, int64TyConName, word8TyConName, word16TyConName, word32TyConName, word64TyConName, @@ -553,7 +553,7 @@ gHC_PRIM, gHC_PRIM_PANIC, aRROW, gHC_DESUGAR, rANDOM, gHC_EXTS, gHC_IS_LIST, cONTROL_EXCEPTION_BASE, gHC_TYPEERROR, gHC_TYPELITS, gHC_TYPELITS_INTERNAL, gHC_TYPENATS, gHC_TYPENATS_INTERNAL, - dATA_COERCE, dEBUG_TRACE, uNSAFE_COERCE :: Module + dATA_COERCE, dEBUG_TRACE, uNSAFE_COERCE, fOREIGN_C_TYPES :: Module gHC_PRIM = mkPrimModule (fsLit "GHC.Prim") -- Primitive types and values gHC_PRIM_PANIC = mkPrimModule (fsLit "GHC.Prim.Panic") @@ -623,6 +623,7 @@ gHC_TYPENATS_INTERNAL = mkBaseModule (fsLit "GHC.TypeNats.Internal") dATA_COERCE = mkBaseModule (fsLit "Data.Coerce") dEBUG_TRACE = mkBaseModule (fsLit "Debug.Trace") uNSAFE_COERCE = mkBaseModule (fsLit "Unsafe.Coerce") +fOREIGN_C_TYPES = mkBaseModule (fsLit "Foreign.C.Types") gHC_SRCLOC :: Module gHC_SRCLOC = mkBaseModule (fsLit "GHC.SrcLoc") @@ -1656,6 +1657,10 @@ fingerprintDataConName :: Name fingerprintDataConName = dcQual gHC_FINGERPRINT_TYPE (fsLit "Fingerprint") fingerprintDataConKey +constPtrConName :: Name +constPtrConName = + tcQual fOREIGN_C_TYPES (fsLit "ConstPtr") constPtrTyConKey + {- ************************************************************************ * * @@ -1852,7 +1857,7 @@ statePrimTyConKey, stableNamePrimTyConKey, stableNameTyConKey, funPtrTyConKey, tVarPrimTyConKey, eqPrimTyConKey, eqReprPrimTyConKey, eqPhantPrimTyConKey, compactPrimTyConKey, stackSnapshotPrimTyConKey, - promptTagPrimTyConKey :: Unique + promptTagPrimTyConKey, constPtrTyConKey :: Unique statePrimTyConKey = mkPreludeTyConUnique 50 stableNamePrimTyConKey = mkPreludeTyConUnique 51 stableNameTyConKey = mkPreludeTyConUnique 52 @@ -2059,6 +2064,7 @@ typeConsSymbolTyFamNameKey = mkPreludeTyConUnique 413 typeUnconsSymbolTyFamNameKey = mkPreludeTyConUnique 414 typeCharToNatTyFamNameKey = mkPreludeTyConUnique 415 typeNatToCharTyFamNameKey = mkPreludeTyConUnique 416 +constPtrTyConKey = mkPreludeTyConUnique 417 {- ************************************************************************ ===================================== compiler/GHC/HsToCore/Foreign/C.hs ===================================== @@ -246,10 +246,18 @@ dsFCall :: Id -> Coercion -> ForeignCall -> Maybe Header -> DsM ([(Id, Expr TyVar)], CHeader, CStub) dsFCall fn_id co fcall mDeclHeader = do let - ty = coercionLKind co + (ty,ty1) = (coercionLKind co, coercionRKind co) (tv_bndrs, rho) = tcSplitForAllTyVarBinders ty (arg_tys, io_res_ty) = tcSplitFunTys rho + let constQual -- provide 'const' qualifier (#22034) + | (_, res_ty1) <- tcSplitFunTys ty1 + , newty <- maybe res_ty1 snd (tcSplitIOType_maybe res_ty1) + , Just (ptr, _) <- splitTyConApp_maybe newty + , tyConName ptr `elem` [constPtrConName] + = text "const" + | otherwise = empty + args <- newSysLocalsDs arg_tys -- no FFI representation polymorphism (val_args, arg_wrappers) <- mapAndUnzipM unboxArg (map Var args) @@ -277,7 +285,7 @@ dsFCall fn_id co fcall mDeclHeader = do includes = vcat [ text "#include \"" <> ftext h <> text "\"" | Header _ h <- nub headers ] - fun_proto = cResType <+> pprCconv <+> ppr wrapperName <> parens argTypes + fun_proto = constQual <+> cResType <+> pprCconv <+> ppr wrapperName <> parens argTypes cRet | isVoidRes = cCall | otherwise = text "return" <+> cCall ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -157,6 +157,9 @@ Runtime system ``ghc`` library ~~~~~~~~~~~~~~~ +- Add `Foreign.C.Types.ConstPtr` was added to encode ``const``-qualified pointer return + types in foreign declarations when using ``CApiFFI`` extension. + ``ghc-heap`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -437,6 +437,18 @@ specified. The syntax looks like: :: data {-# CTYPE "unistd.h" "useconds_t" #-} T = ... newtype {-# CTYPE "useconds_t" #-} T = ... +In case foreign declarations contain ``const``-qualified pointer return +type, `ConstPtr` from :base-ref:`Foreign.C.Types` may be used to +encode this, e.g. :: + + foreign import capi "header.h f" f :: CInt -> ConstPtr CInt + +which corresponds to + +.. code-block:: c + + const *int f(int); + ``hs_thread_done()`` ~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/base/Foreign/C/Types.hs ===================================== @@ -84,8 +84,11 @@ module Foreign.C.Types -- Instances of: Eq and Storable , CFile, CFpos, CJmpBuf + + , ConstPtr(..) ) where +import Foreign.Ptr ( Ptr ) import Foreign.Storable import Data.Bits ( Bits(..), FiniteBits(..) ) import Data.Int ( Int8, Int16, Int32, Int64 ) @@ -214,6 +217,9 @@ INTEGRAL_TYPE(CUIntPtr,"uintptr_t",HTYPE_UINTPTR_T) INTEGRAL_TYPE(CIntMax,"intmax_t",HTYPE_INTMAX_T) INTEGRAL_TYPE(CUIntMax,"uintmax_t",HTYPE_UINTMAX_T) +-- | Used to produce 'const' qualifier in C code generator +newtype ConstPtr a = ConstPtr { unConstPtr :: Ptr a } deriving newtype (Show, Eq, Storable) + -- C99 types which are still missing include: -- wint_t, wctrans_t, wctype_t @@ -259,4 +265,3 @@ representing a C type @t@: corresponding bitwise operation in C on @t at . -} - ===================================== libraries/unix ===================================== @@ -1 +1 @@ -Subproject commit 3be0223cee7395410915a127eba3acae5ff0b2f2 +Subproject commit 2a6079a2b76adf29d3e3ff213dffe66cabcb76c3 ===================================== testsuite/tests/ffi/should_compile/T22034.h ===================================== @@ -0,0 +1,2 @@ +const int *foo(); +const double *bar; ===================================== testsuite/tests/ffi/should_compile/T22034.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE CApiFFI #-} +module T22034 where + +import Foreign.C.Types + +foreign import capi "T22034.h foo" + c_foo :: IO (ConstPtr CInt) + +foreign import capi "T22034.h value bar" + c_bar :: ConstPtr CDouble ===================================== testsuite/tests/ffi/should_compile/T22034_c.c ===================================== @@ -0,0 +1,9 @@ +#include + +const int * foo() { + int *x = malloc(sizeof(int)); + *x = 42; + return x; +} + +const int *bar = 0; ===================================== testsuite/tests/ffi/should_compile/all.T ===================================== @@ -43,3 +43,4 @@ test( ], ) test('T15531', normal, compile, ['-Wall']) +test('T22034', [omit_ways(['ghci'])], compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21450670340d1ec265461fd2bc4de8931658ec8a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/21450670340d1ec265461fd2bc4de8931658ec8a You're receiving 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 Nov 11 20:32:07 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 11 Nov 2022 15:32:07 -0500 Subject: [Git][ghc/ghc][wip/T21623] 5 commits: rts: Check for program_invocation_short_name via autoconf Message-ID: <636eb147e717_24229e526c017622e@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 8207d561 by Simon Peyton Jones at 2022-11-11T20:31:55+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 81f37af9 by Simon Peyton Jones at 2022-11-11T20:31:55+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/48ffe6989d59b4f1d0ad0636b39ca05b3c0fcbbe...81f37af984167302a3fa59378cf896a137ebd0c7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/48ffe6989d59b4f1d0ad0636b39ca05b3c0fcbbe...81f37af984167302a3fa59378cf896a137ebd0c7 You're receiving 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 Nov 11 21:21:32 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 16:21:32 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: rts: Check for program_invocation_short_name via autoconf Message-ID: <636ebcdc7e12c_24229e527c42008c0@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - a84d242f by Matthew Craven at 2022-11-11T16:21:26-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Driver/Make.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Types/CostCentre.hs - compiler/GHC/Types/ForeignStubs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/94aa0db1f2a930bfadb50e09f6930cc708d5c523...a84d242f8d398c93d515172cb75b1bc4fc661321 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/94aa0db1f2a930bfadb50e09f6930cc708d5c523...a84d242f8d398c93d515172cb75b1bc4fc661321 You're receiving 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 Nov 11 22:22:33 2022 From: gitlab at gitlab.haskell.org (Alex D (@nineonine)) Date: Fri, 11 Nov 2022 17:22:33 -0500 Subject: [Git][ghc/ghc][wip/T22043] CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Message-ID: <636ecb298547b_24229e5669402139b3@gitlab.mail> Alex D pushed to branch wip/T22043 at Glasgow Haskell Compiler / GHC Commits: 4f70a8a0 by nineonine at 2022-11-11T14:22:24-08:00 CApiFFI: add ConstPtr for encoding const-qualified pointer return types (#22043) Previously, when using `capi` calling convention in foreign declarations, code generator failed to handle const-cualified pointer return types. This resulted in CC toolchain throwing `-Wincompatible-pointer-types-discards-qualifiers` warning. `Foreign.C.Types.ConstPtr` newtype was introduced to handle these cases - special treatment was put in place to generate appropritetly qualified C wrapper that no longer triggers the above mentioned warning. Fixes #22043 - - - - - 9 changed files: - compiler/GHC/Builtin/Names.hs - compiler/GHC/HsToCore/Foreign/C.hs - docs/users_guide/9.6.1-notes.rst - docs/users_guide/exts/ffi.rst - libraries/base/Foreign/C/Types.hs - + testsuite/tests/ffi/should_compile/T22034.h - + testsuite/tests/ffi/should_compile/T22034.hs - + testsuite/tests/ffi/should_compile/T22034_c.c - testsuite/tests/ffi/should_compile/all.T Changes: ===================================== compiler/GHC/Builtin/Names.hs ===================================== @@ -346,7 +346,7 @@ basicKnownKeyNames zipName, foldrName, buildName, augmentName, appendName, -- FFI primitive types that are not wired-in. - stablePtrTyConName, ptrTyConName, funPtrTyConName, + stablePtrTyConName, ptrTyConName, funPtrTyConName, constPtrConName, int8TyConName, int16TyConName, int32TyConName, int64TyConName, word8TyConName, word16TyConName, word32TyConName, word64TyConName, @@ -553,7 +553,7 @@ gHC_PRIM, gHC_PRIM_PANIC, aRROW, gHC_DESUGAR, rANDOM, gHC_EXTS, gHC_IS_LIST, cONTROL_EXCEPTION_BASE, gHC_TYPEERROR, gHC_TYPELITS, gHC_TYPELITS_INTERNAL, gHC_TYPENATS, gHC_TYPENATS_INTERNAL, - dATA_COERCE, dEBUG_TRACE, uNSAFE_COERCE :: Module + dATA_COERCE, dEBUG_TRACE, uNSAFE_COERCE, fOREIGN_C_TYPES :: Module gHC_PRIM = mkPrimModule (fsLit "GHC.Prim") -- Primitive types and values gHC_PRIM_PANIC = mkPrimModule (fsLit "GHC.Prim.Panic") @@ -623,6 +623,7 @@ gHC_TYPENATS_INTERNAL = mkBaseModule (fsLit "GHC.TypeNats.Internal") dATA_COERCE = mkBaseModule (fsLit "Data.Coerce") dEBUG_TRACE = mkBaseModule (fsLit "Debug.Trace") uNSAFE_COERCE = mkBaseModule (fsLit "Unsafe.Coerce") +fOREIGN_C_TYPES = mkBaseModule (fsLit "Foreign.C.Types") gHC_SRCLOC :: Module gHC_SRCLOC = mkBaseModule (fsLit "GHC.SrcLoc") @@ -1656,6 +1657,10 @@ fingerprintDataConName :: Name fingerprintDataConName = dcQual gHC_FINGERPRINT_TYPE (fsLit "Fingerprint") fingerprintDataConKey +constPtrConName :: Name +constPtrConName = + tcQual fOREIGN_C_TYPES (fsLit "ConstPtr") constPtrTyConKey + {- ************************************************************************ * * @@ -1852,7 +1857,7 @@ statePrimTyConKey, stableNamePrimTyConKey, stableNameTyConKey, funPtrTyConKey, tVarPrimTyConKey, eqPrimTyConKey, eqReprPrimTyConKey, eqPhantPrimTyConKey, compactPrimTyConKey, stackSnapshotPrimTyConKey, - promptTagPrimTyConKey :: Unique + promptTagPrimTyConKey, constPtrTyConKey :: Unique statePrimTyConKey = mkPreludeTyConUnique 50 stableNamePrimTyConKey = mkPreludeTyConUnique 51 stableNameTyConKey = mkPreludeTyConUnique 52 @@ -2059,6 +2064,7 @@ typeConsSymbolTyFamNameKey = mkPreludeTyConUnique 413 typeUnconsSymbolTyFamNameKey = mkPreludeTyConUnique 414 typeCharToNatTyFamNameKey = mkPreludeTyConUnique 415 typeNatToCharTyFamNameKey = mkPreludeTyConUnique 416 +constPtrTyConKey = mkPreludeTyConUnique 417 {- ************************************************************************ ===================================== compiler/GHC/HsToCore/Foreign/C.hs ===================================== @@ -246,10 +246,18 @@ dsFCall :: Id -> Coercion -> ForeignCall -> Maybe Header -> DsM ([(Id, Expr TyVar)], CHeader, CStub) dsFCall fn_id co fcall mDeclHeader = do let - ty = coercionLKind co + (ty,ty1) = (coercionLKind co, coercionRKind co) (tv_bndrs, rho) = tcSplitForAllTyVarBinders ty (arg_tys, io_res_ty) = tcSplitFunTys rho + let constQual -- provide 'const' qualifier (#22034) + | (_, res_ty1) <- tcSplitFunTys ty1 + , newty <- maybe res_ty1 snd (tcSplitIOType_maybe res_ty1) + , Just (ptr, _) <- splitTyConApp_maybe newty + , tyConName ptr `elem` [constPtrConName] + = text "const" + | otherwise = empty + args <- newSysLocalsDs arg_tys -- no FFI representation polymorphism (val_args, arg_wrappers) <- mapAndUnzipM unboxArg (map Var args) @@ -277,7 +285,7 @@ dsFCall fn_id co fcall mDeclHeader = do includes = vcat [ text "#include \"" <> ftext h <> text "\"" | Header _ h <- nub headers ] - fun_proto = cResType <+> pprCconv <+> ppr wrapperName <> parens argTypes + fun_proto = constQual <+> cResType <+> pprCconv <+> ppr wrapperName <> parens argTypes cRet | isVoidRes = cCall | otherwise = text "return" <+> cCall ===================================== docs/users_guide/9.6.1-notes.rst ===================================== @@ -157,6 +157,9 @@ Runtime system ``ghc`` library ~~~~~~~~~~~~~~~ +- Add `Foreign.C.Types.ConstPtr` was added to encode ``const``-qualified pointer return + types in foreign declarations when using ``CApiFFI`` extension. + ``ghc-heap`` library ~~~~~~~~~~~~~~~~~~~~ ===================================== docs/users_guide/exts/ffi.rst ===================================== @@ -437,6 +437,18 @@ specified. The syntax looks like: :: data {-# CTYPE "unistd.h" "useconds_t" #-} T = ... newtype {-# CTYPE "useconds_t" #-} T = ... +In case foreign declarations contain ``const``-qualified pointer return +type, `ConstPtr` from :base-ref:`Foreign.C.Types` may be used to +encode this, e.g. :: + + foreign import capi "header.h f" f :: CInt -> ConstPtr CInt + +which corresponds to + +.. code-block:: c + + const *int f(int); + ``hs_thread_done()`` ~~~~~~~~~~~~~~~~~~~~ ===================================== libraries/base/Foreign/C/Types.hs ===================================== @@ -84,8 +84,11 @@ module Foreign.C.Types -- Instances of: Eq and Storable , CFile, CFpos, CJmpBuf + + , ConstPtr(..) ) where +import Foreign.Ptr ( Ptr ) import Foreign.Storable import Data.Bits ( Bits(..), FiniteBits(..) ) import Data.Int ( Int8, Int16, Int32, Int64 ) @@ -214,6 +217,9 @@ INTEGRAL_TYPE(CUIntPtr,"uintptr_t",HTYPE_UINTPTR_T) INTEGRAL_TYPE(CIntMax,"intmax_t",HTYPE_INTMAX_T) INTEGRAL_TYPE(CUIntMax,"uintmax_t",HTYPE_UINTMAX_T) +-- | Used to produce 'const' qualifier in C code generator +newtype ConstPtr a = ConstPtr { unConstPtr :: Ptr a } deriving newtype (Show, Eq, Storable) + -- C99 types which are still missing include: -- wint_t, wctrans_t, wctype_t @@ -259,4 +265,3 @@ representing a C type @t@: corresponding bitwise operation in C on @t at . -} - ===================================== testsuite/tests/ffi/should_compile/T22034.h ===================================== @@ -0,0 +1,2 @@ +const int *foo(); +const double *bar; ===================================== testsuite/tests/ffi/should_compile/T22034.hs ===================================== @@ -0,0 +1,10 @@ +{-# LANGUAGE CApiFFI #-} +module T22034 where + +import Foreign.C.Types + +foreign import capi "T22034.h foo" + c_foo :: IO (ConstPtr CInt) + +foreign import capi "T22034.h value bar" + c_bar :: ConstPtr CDouble ===================================== testsuite/tests/ffi/should_compile/T22034_c.c ===================================== @@ -0,0 +1,9 @@ +#include + +const int * foo() { + int *x = malloc(sizeof(int)); + *x = 42; + return x; +} + +const int *bar = 0; ===================================== testsuite/tests/ffi/should_compile/all.T ===================================== @@ -43,3 +43,4 @@ test( ], ) test('T15531', normal, compile, ['-Wall']) +test('T22034', [omit_ways(['ghci'])], compile, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f70a8a0b5db49ff249271faefec14bf1421f365 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4f70a8a0b5db49ff249271faefec14bf1421f365 You're receiving 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 Nov 11 23:31:57 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 18:31:57 -0500 Subject: [Git][ghc/ghc][master] Use a more efficient printer for code generation (#21853) Message-ID: <636edb6d2f75b_24229e5669402335c3@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 30 changed files: - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/Ppr.hs - compiler/GHC/CmmToAsm/X86.hs - compiler/GHC/CmmToAsm/X86/CodeGen.hs - compiler/GHC/CmmToAsm/X86/Instr.hs - compiler/GHC/CmmToAsm/X86/Ppr.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Linker/Types.hs - compiler/GHC/Types/CostCentre.hs - compiler/GHC/Types/ForeignStubs.hs - compiler/GHC/Types/Name.hs - compiler/GHC/Types/Name/Occurrence.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c37d30b07fc85fe09452f4ce250aec42cb1d2e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3c37d30b07fc85fe09452f4ce250aec42cb1d2e4 You're receiving 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 Nov 11 23:32:35 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 18:32:35 -0500 Subject: [Git][ghc/ghc][master] Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Message-ID: <636edb93de211_24229e52774239165@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 4 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - + testsuite/tests/simplCore/should_compile/T22375.hs - + testsuite/tests/simplCore/should_compile/T22375.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -2315,16 +2315,25 @@ Example with the "Merge Nested Cases" optimization (from #12877): 3## -> ... DEFAULT -> ... -There are some wrinkles +There are some wrinkles. -* Do not apply caseRules if there is just a single DEFAULT alternative +Wrinkle 1: + Do not apply caseRules if there is just a single DEFAULT alternative, + unless the case-binder is dead. Example: case e +# 3# of b { DEFAULT -> rhs } If we applied the transformation here we would (stupidly) get - case a of b' { DEFAULT -> let b = e +# 3# in rhs } + case e of b' { DEFAULT -> let b = b' +# 3# in rhs } and now the process may repeat, because that let will really - be a case. + be a case. But if the original case binder b is dead, we instead get + case e of b' { DEFAULT -> rhs } + and there is no such problem. -* The type of the scrutinee might change. E.g. + See Note [Example of case-merging and caseRules] for a compelling + example of why this dead-binder business can be really important. + + +Wrinkle 2: + The type of the scrutinee might change. E.g. case tagToEnum (x :: Int#) of (b::Bool) False -> e1 True -> e2 @@ -2333,7 +2342,8 @@ There are some wrinkles DEFAULT -> e1 1# -> e2 -* The case binder may be used in the right hand sides, so we need +Wrinkle 3: + The case binder may be used in the right hand sides, so we need to make a local binding for it, if it is alive. e.g. case e +# 10# of b DEFAULT -> blah...b... @@ -2347,8 +2357,87 @@ There are some wrinkles whereas in the DEFAULT case we must reconstruct the original value. But NB: we use b'; we do not duplicate 'e'. -* In dataToTag we might need to make up some fake binders; +Wrinkle 4: + In dataToTag we might need to make up some fake binders; see Note [caseRules for dataToTag] in GHC.Core.Opt.ConstantFold + + + +Note [Example of case-merging and caseRules] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The case-transformation rules are quite powerful. Here's a +subtle example from #22375. We start with + + data T = A | B | ... + deriving Eq + + f :: T -> String + f x = if | x==A -> "one" + | x==B -> "two" + | ... + +In Core after a bit of simplification we get: + + f x = case dataToTag# x of a# { _DEFAULT -> + case a# of + _DEFAULT -> case dataToTag# x of b# { _DEFAULT -> + case b# of + _DEFAULT -> ... + 1# -> "two" + } + 0# -> "one" + } + +Now consider what mkCase does to these case expressions. +The case-merge transformation Note [Merge Nested Cases] +does this (affecting both pairs of cases): + + f x = case dataToTag# x of a# { + _DEFAULT -> case dataToTag# x of b# { + _DEFAULT -> ... + 1# -> "two" + } + 0# -> "one" + } + +Now Note [caseRules for dataToTag] does its work, again +on both dataToTag# cases: + + f x = case x of x1 { + _DEFAULT -> case dataToTag# x1 of a# { _DEFAULT -> + case x of x2 { + _DEFAULT -> case dataToTag# x2 of b# { _DEFAULT -> ... } + B -> "two" + }} + A -> "one" + } + + +The new dataToTag# calls come from the "reconstruct scrutinee" part of +caseRules (note that a# and b# were not dead in the original program +before all this merging). However, since a# and b# /are/ in fact dead +in the resulting program, we are left with redundant dataToTag# calls. +But they are easily eliminated by doing caseRules again, in +the next Simplifier iteration, this time noticing that a# and b# are +dead. Hence the "dead-binder" sub-case of Wrinkle 1 of Note +[Scrutinee Constant Folding] above. Once we do this we get + + f x = case x of x1 { + _DEFAULT -> case x1 of x2 { _DEFAULT -> + case x1 of x2 { + _DEFAULT -> case x2 of x3 { _DEFAULT -> ... } + B -> "two" + }} + A -> "one" + } + +and now we can do case-merge again, getting the desired + + f x = case x of + A -> "one" + B -> "two" + ... + -} mkCase, mkCase1, mkCase2, mkCase3 @@ -2450,8 +2539,8 @@ mkCase1 mode scrut bndr alts_ty alts = mkCase2 mode scrut bndr alts_ty alts mkCase2 mode scrut bndr alts_ty alts | -- See Note [Scrutinee Constant Folding] - case alts of -- Not if there is just a DEFAULT alternative - [Alt DEFAULT _ _] -> False + case alts of + [Alt DEFAULT _ _] -> isDeadBinder bndr -- see wrinkle 1 _ -> True , sm_case_folding mode , Just (scrut', tx_con, mk_orig) <- caseRules (smPlatform mode) scrut @@ -2473,13 +2562,9 @@ mkCase2 mode scrut bndr alts_ty alts -- binder if the latter isn't dead. Hence we wrap rhs of alternatives with -- "let bndr = ... in": -- - -- case v + 10 of y =====> case v of y - -- 20 -> e1 10 -> let y = 20 in e1 - -- DEFAULT -> e2 DEFAULT -> let y = v + 10 in e2 - -- - -- Other transformations give: =====> case v of y' - -- 10 -> let y = 20 in e1 - -- DEFAULT -> let y = y' + 10 in e2 + -- case v + 10 of y =====> case v of y' + -- 20 -> e1 10 -> let y = 20 in e1 + -- DEFAULT -> e2 DEFAULT -> let y = y' + 10 in e2 -- -- This wrapping is done in tx_alt; we use mk_orig, returned by caseRules, -- to construct an expression equivalent to the original one, for use ===================================== testsuite/tests/simplCore/should_compile/T22375.hs ===================================== @@ -0,0 +1,12 @@ +module T22375 where + +data X = A | B | C | D | E + deriving Eq + +f :: X -> Int -> Int +f x v + | x == A = 1 + v + | x == B = 2 + v + | x == C = 3 + v + | x == D = 4 + v + | otherwise = 5 + v ===================================== testsuite/tests/simplCore/should_compile/T22375.stderr ===================================== @@ -0,0 +1,70 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 71, types: 31, coercions: 0, joins: 0/0} + +-- RHS size: {terms: 14, types: 7, coercions: 0, joins: 0/0} +T22375.$fEqX_$c== :: X -> X -> Bool +[GblId, + Arity=2, + Str=, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=True)}] +T22375.$fEqX_$c== + = \ (a :: X) (b :: X) -> + case GHC.Prim.dataToTag# @X a of a# { __DEFAULT -> + case GHC.Prim.dataToTag# @X b of b# { __DEFAULT -> + GHC.Prim.tagToEnum# @Bool (GHC.Prim.==# a# b#) + } + } + +-- RHS size: {terms: 18, types: 7, coercions: 0, joins: 0/0} +T22375.$fEqX_$c/= [InlPrag=INLINE (sat-args=2)] :: X -> X -> Bool +[GblId, + Arity=2, + Str=, + Unf=Unf{Src=StableUser, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False)}] +T22375.$fEqX_$c/= + = \ (eta :: X) (eta1 :: X) -> + case GHC.Prim.dataToTag# @X eta of a# { __DEFAULT -> + case GHC.Prim.dataToTag# @X eta1 of b# { __DEFAULT -> + case GHC.Prim.==# a# b# of { + __DEFAULT -> GHC.Types.True; + 1# -> GHC.Types.False + } + } + } + +-- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0} +T22375.$fEqX [InlPrag=CONLIKE] :: Eq X +[GblId[DFunId], + Unf=DFun: \ -> + GHC.Classes.C:Eq TYPE: X T22375.$fEqX_$c== T22375.$fEqX_$c/=] +T22375.$fEqX + = GHC.Classes.C:Eq @X T22375.$fEqX_$c== T22375.$fEqX_$c/= + +-- RHS size: {terms: 32, types: 5, coercions: 0, joins: 0/0} +f [InlPrag=[2]] :: X -> Int -> Int +[GblId, + Arity=2, + Str=<1L><1!P(L)>, + Cpr=1, + Unf=Unf{Src=StableSystem, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False)}] +f = \ (x :: X) (v :: Int) -> + case v of { GHC.Types.I# ww -> + case x of { + A -> GHC.Types.I# (GHC.Prim.+# 1# ww); + B -> GHC.Types.I# (GHC.Prim.+# 2# ww); + C -> GHC.Types.I# (GHC.Prim.+# 3# ww); + D -> GHC.Types.I# (GHC.Prim.+# 4# ww); + E -> GHC.Types.I# (GHC.Prim.+# 5# ww) + } + } + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -442,6 +442,7 @@ test('T22357', normal, compile, ['-O']) # Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) test('T17366', normal, multimod_compile, ['T17366', '-O -v0 -ddump-rule-firings']) test('T17366_AR', [grep_errmsg(r'SPEC')], multimod_compile, ['T17366_AR', '-O -v0 -ddump-rule-firings']) +test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6b92b47fa2386ccb2f8264110ff7a827958fb7bf -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6b92b47fa2386ccb2f8264110ff7a827958fb7bf You're receiving 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 Nov 11 23:40:21 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Fri, 11 Nov 2022 18:40:21 -0500 Subject: [Git][ghc/ghc][wip/T21623] 5 commits: Use a more efficient printer for code generation (#21853) Message-ID: <636edd656a035_24229e527d823934@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623 at Glasgow Haskell Compiler / GHC Commits: 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - 19 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81f37af984167302a3fa59378cf896a137ebd0c7...360f5fec2eb430ac15145193d95120a5a6ca6812 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/81f37af984167302a3fa59378cf896a137ebd0c7...360f5fec2eb430ac15145193d95120a5a6ca6812 You're receiving 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 Nov 12 02:34:09 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Fri, 11 Nov 2022 21:34:09 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Message-ID: <636f0621d6025_24229e527c4262020@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - 26255224 by Krzysztof Gogolewski at 2022-11-11T21:34:05-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a84d242f8d398c93d515172cb75b1bc4fc661321...262552246c8eb40dd9713637aa1e5ac48e70338f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a84d242f8d398c93d515172cb75b1bc4fc661321...262552246c8eb40dd9713637aa1e5ac48e70338f You're receiving 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 Nov 12 05:44:28 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 12 Nov 2022 00:44:28 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] Fix merge conflict in T18355.stderr Message-ID: <636f32bc6df07_24229e56694027754d@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 9acda36a by Krzysztof Gogolewski at 2022-11-12T00:44:22-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 1 changed file: - testsuite/tests/simplCore/should_compile/T18355.stderr Changes: ===================================== testsuite/tests/simplCore/should_compile/T18355.stderr ===================================== @@ -7,16 +7,8 @@ Result size of Tidy Core f :: forall {a}. Num a => a -> Bool -> a -> a [GblId, Arity=4, -<<<<<<< HEAD - Str=<1P(MC1(C1(L)),MC1(C1(L)),A,A,A,A,A)><1L>, + Str=<1P(MC(1,C(1,L)),MC(1,C(1,L)),A,A,A,A,A)><1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, -||||||| parent of 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, -======= - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, ->>>>>>> 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 0 70 0] 100 0}] f = \ (@a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9acda36a5f37a7d5867663bbbabd98301cb2a324 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9acda36a5f37a7d5867663bbbabd98301cb2a324 You're receiving 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 Nov 12 09:24:42 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 12 Nov 2022 04:24:42 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] Fix merge conflict in T18355.stderr Message-ID: <636f665a4727_24229e526c030005b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 18b8c177 by Krzysztof Gogolewski at 2022-11-12T04:24:36-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 1 changed file: - testsuite/tests/simplCore/should_compile/T18355.stderr Changes: ===================================== testsuite/tests/simplCore/should_compile/T18355.stderr ===================================== @@ -7,16 +7,8 @@ Result size of Tidy Core f :: forall {a}. Num a => a -> Bool -> a -> a [GblId, Arity=4, -<<<<<<< HEAD - Str=<1P(MC1(C1(L)),MC1(C1(L)),A,A,A,A,A)><1L>, + Str=<1P(MC(1,C(1,L)),MC(1,C(1,L)),A,A,A,A,A)><1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, -||||||| parent of 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, -======= - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, ->>>>>>> 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 0 70 0] 100 0}] f = \ (@a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/18b8c1777766bd44d29874ac46a27c96137f2dea -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/18b8c1777766bd44d29874ac46a27c96137f2dea You're receiving 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 Nov 12 10:45:21 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Sat, 12 Nov 2022 05:45:21 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] 67 commits: Bump unix submodule to 2.8.0.0 Message-ID: <636f79411fafb_24229e56694030615c@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - e74296c2 by Sylvain Henry at 2022-11-12T11:38:50+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump submodules Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 30 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - + .gitlab/hello.hs - .gitlab/jobs.yaml - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/DebugBlock.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs - compiler/GHC/CmmToAsm/Dwarf/Types.hs - compiler/GHC/CmmToAsm/Instr.hs - compiler/GHC/CmmToAsm/Monad.hs - compiler/GHC/CmmToAsm/PIC.hs - compiler/GHC/CmmToAsm/PPC.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Instr.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/46429b72663df3f7d267b5d350380a80bcc4ec5c...e74296c25b29d08c7f952173dc0a80786ebbe345 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/46429b72663df3f7d267b5d350380a80bcc4ec5c...e74296c25b29d08c7f952173dc0a80786ebbe345 You're receiving 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 Nov 12 10:47:31 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Sat, 12 Nov 2022 05:47:31 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Add Javascript backend Message-ID: <636f79c3424d0_24229e526e830728d@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: fb50e565 by Sylvain Henry at 2022-11-12T11:51:13+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump submodules Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 25 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backend/Internal.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/StgToCmm.hs - + compiler/GHC/Driver/Config/StgToJS.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Phases.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Pipeline/Phases.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - + compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - + compiler/GHC/JS/Make.hs - + compiler/GHC/JS/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb50e565d6ab5a2dbab7bb6a84a7b5a223bc174f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fb50e565d6ab5a2dbab7bb6a84a7b5a223bc174f You're receiving 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 Nov 12 13:05:07 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 12 Nov 2022 08:05:07 -0500 Subject: [Git][ghc/ghc][master] 3 commits: Fix fragile RULE setup in GHC.Float Message-ID: <636f9a03cfb99_24229e566940331219@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - 12 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot - compiler/GHC/Core/Coercion/Opt.hs - compiler/GHC/Core/ConLike.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b92b47fa2386ccb2f8264110ff7a827958fb7bf...360f5fec2eb430ac15145193d95120a5a6ca6812 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6b92b47fa2386ccb2f8264110ff7a827958fb7bf...360f5fec2eb430ac15145193d95120a5a6ca6812 You're receiving 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 Nov 12 13:05:47 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Sat, 12 Nov 2022 08:05:47 -0500 Subject: [Git][ghc/ghc][master] Fix merge conflict in T18355.stderr Message-ID: <636f9a2bacaf5_24229e7134ba433627@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 1 changed file: - testsuite/tests/simplCore/should_compile/T18355.stderr Changes: ===================================== testsuite/tests/simplCore/should_compile/T18355.stderr ===================================== @@ -7,16 +7,8 @@ Result size of Tidy Core f :: forall {a}. Num a => a -> Bool -> a -> a [GblId, Arity=4, -<<<<<<< HEAD - Str=<1P(MC1(C1(L)),MC1(C1(L)),A,A,A,A,A)><1L>, + Str=<1P(MC(1,C(1,L)),MC(1,C(1,L)),A,A,A,A,A)><1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, -||||||| parent of 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, -======= - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, ->>>>>>> 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 0 70 0] 100 0}] f = \ (@a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e160cf4776f21a39adebfa8f5d4dcbe9ec6b0ffe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e160cf4776f21a39adebfa8f5d4dcbe9ec6b0ffe You're receiving 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 Nov 12 13:24:13 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Sat, 12 Nov 2022 08:24:13 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Add Javascript backend Message-ID: <636f9e7dc70c_24229e52710336511@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: c08b438b by Sylvain Henry at 2022-11-12T14:26:59+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump submodules Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 25 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backend/Internal.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/StgToCmm.hs - + compiler/GHC/Driver/Config/StgToJS.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Phases.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Pipeline/Phases.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - + compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - + compiler/GHC/JS/Make.hs - + compiler/GHC/JS/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c08b438b9d91f64652bad149047d47b58fd8e4cd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c08b438b9d91f64652bad149047d47b58fd8e4cd You're receiving 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 Nov 12 18:55:17 2022 From: gitlab at gitlab.haskell.org (Richard Eisenberg (@rae)) Date: Sat, 12 Nov 2022 13:55:17 -0500 Subject: [Git][ghc/ghc][wip/p547] 57 commits: Fire RULES in the Specialiser Message-ID: <636fec15d7a5c_24229e527103628a8@gitlab.mail> Richard Eisenberg pushed to branch wip/p547 at Glasgow Haskell Compiler / GHC Commits: f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - 3120a792 by Richard Eisenberg at 2022-11-12T13:45:26-05:00 Drop support for kind constraints. This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. - - - - - 26 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/DebugBlock.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d71039a72f68f7ac9c5826e931d5e4443223cb58...3120a7928168618f3f91ba72e19fb0dbd5a89f9b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d71039a72f68f7ac9c5826e931d5e4443223cb58...3120a7928168618f3f91ba72e19fb0dbd5a89f9b You're receiving 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 Nov 12 22:40:22 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 12 Nov 2022 17:40:22 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T21623-faster Message-ID: <637020d674160_24229e566940385575@gitlab.mail> Simon Peyton Jones pushed new branch wip/T21623-faster at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T21623-faster You're receiving 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 Nov 12 22:43:37 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 12 Nov 2022 17:43:37 -0500 Subject: [Git][ghc/ghc][wip/T21623-faster] 7 commits: Use a more efficient printer for code generation (#21853) Message-ID: <637021997df59_24229e52774387751@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623-faster at Glasgow Haskell Compiler / GHC Commits: 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 039831e4 by Simon Peyton Jones at 2022-11-12T22:43:12+00:00 Better implementation of typeKind - - - - - 19 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bdc219bb76423dd4997c4b59eb5017940a3a2056...039831e4691d304c092df90a9fc87d95c05157b8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bdc219bb76423dd4997c4b59eb5017940a3a2056...039831e4691d304c092df90a9fc87d95c05157b8 You're receiving 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 Nov 12 22:50:25 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 12 Nov 2022 17:50:25 -0500 Subject: [Git][ghc/ghc][wip/T22416] 10 commits: rts: Check for program_invocation_short_name via autoconf Message-ID: <63702331e55b8_24229e5276038983c@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22416 at Glasgow Haskell Compiler / GHC Commits: 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - adf2e02e by Simon Peyton Jones at 2022-11-12T22:50:17+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 19 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/Dwarf.hs - compiler/GHC/CmmToAsm/Dwarf/Constants.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/859891248205829cd71abab5de054e9242761adf...adf2e02e405c8cfa46b42f9df73f0327248db954 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/859891248205829cd71abab5de054e9242761adf...adf2e02e405c8cfa46b42f9df73f0327248db954 You're receiving 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 Nov 12 23:02:11 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 12 Nov 2022 18:02:11 -0500 Subject: [Git][ghc/ghc][wip/p547] 2 commits: Fix merge conflict in T18355.stderr Message-ID: <637025f3780e7_24229e527603982b2@gitlab.mail> Simon Peyton Jones pushed to branch wip/p547 at Glasgow Haskell Compiler / GHC Commits: e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 9d48a1b7 by Richard Eisenberg at 2022-11-12T23:01:33+00:00 Drop support for kind constraints. This implements GHC proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. - - - - - 19 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Rewrite.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Var.hs - docs/users_guide/exts/data_kinds.rst - testsuite/tests/simplCore/should_compile/T18355.stderr Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -614,7 +614,7 @@ A DataCon has two different sets of type variables: (that is, they are TyVars/TyCoVars instead of ForAllTyBinders). Often (dcUnivTyVars ++ dcExTyCoVars) = dcUserTyVarBinders; but they may differ -for three reasons, coming next: +for two reasons, coming next: --- Reason (R1): Order of quantification in GADT syntax --- @@ -703,55 +703,6 @@ Putting this all together, all variables used on the left-hand side of an equation in the dcEqSpec will be in dcUnivTyVars but *not* in dcUserTyVarBinders. ---- Reason (R3): Kind equalities may have been solved --- - -Consider now this case: - - type family F a where - F Type = False - F _ = True - type T :: forall k. (F k ~ True) => k -> k -> Type - data T a b where - MkT :: T Maybe List - -The constraint F k ~ True tells us that T does not want to be indexed by, say, -Int. Now let's consider the Core types involved: - - axiom for F: axF[0] :: F Type ~ False - axF[1] :: forall a. F a ~ True (a must be apart from Type) - tycon: T :: forall k. (F k ~ True) -> k -> k -> Type - wrapper: MkT :: T @(Type -> Type) @(Eq# (axF[1] (Type -> Type)) Maybe List - worker: MkT :: forall k (c :: F k ~ True) (a :: k) (b :: k). - (k ~# (Type -> Type), a ~# Maybe, b ~# List) => - T @k @c a b - -The key observation here is that the worker quantifies over c, while the wrapper -does not. The worker *must* quantify over c, because c is a universal variable, -and the result of the worker must be the type constructor applied to a sequence -of plain type variables. But the wrapper certainly does not need to quantify over -any evidence that F (Type -> Type) ~ True, as no variables are needed there. - -(Aside: the c here is a regular type variable, *not* a coercion variable. This -is because F k ~ True is a *lifted* equality, not the unlifted ~#. This is why -we see Eq# in the type of the wrapper: Eq# boxes the unlifted ~# to become a -lifted ~. See also Note [The equality types story] in GHC.Builtin.Types.Prim about -Eq# and Note [Constraints in kinds] in GHC.Core.TyCo.Rep about having this constraint -in the first place.) - -In this case, we'll have these fields of the DataCon: - - dcUserTyVarBinders = [] -- the wrapper quantifies over nothing - dcUnivTyVars = [k, c, a, b] - dcExTyCoVars = [] -- no existentials here, but a different constructor might have - dcEqSpec = [k ~# (Type -> Type), a ~# Maybe, b ~# List] - -Note that c is in the dcUserTyVars, but mentioned neither in the dcUserTyVarBinders nor -in the dcEqSpec. We thus have Reason (R3): a variable might be missing from the -dcUserTyVarBinders if its type's kind is Constraint. - -(At one point, we thought that the dcEqSpec would have to be non-empty. But that -wouldn't account for silly cases like type T :: (True ~ True) => Type.) - --- End of Reasons --- INVARIANT(dataConTyVars): the set of tyvars in dcUserTyVarBinders @@ -1213,11 +1164,9 @@ mkDataCon name declared_infix prom_info -- fresh_names: make sure that the "anonymous" tyvars don't -- clash in name or unique with the universal/existential ones. -- Tiresome! And unnecessary because these tyvars are never looked at - prom_theta_bndrs = [ mkInvisAnonTyConBinder (mkTyVar n t) - {- Invisible -} | (n,t) <- fresh_names `zip` theta ] prom_arg_bndrs = [ mkAnonTyConBinder (mkTyVar n t) {- Visible -} | (n,t) <- dropList theta fresh_names `zip` map scaledThing orig_arg_tys ] - prom_bndrs = prom_tv_bndrs ++ prom_theta_bndrs ++ prom_arg_bndrs + prom_bndrs = prom_tv_bndrs ++ prom_arg_bndrs prom_res_kind = orig_res_ty promoted = mkPromotedDataCon con name prom_info prom_bndrs prom_res_kind roles rep_info @@ -1840,20 +1789,15 @@ checkDataConTyVars dc@(MkData { dcUnivTyVars = univ_tvs , dcExTyCoVars = ex_tvs , dcEqSpec = eq_spec }) -- use of sets here: (R1) from the Note - = mkUnVarSet depleted_worker_vars == mkUnVarSet depleted_wrapper_vars && + = mkUnVarSet depleted_worker_vars == mkUnVarSet wrapper_vars && all (not . is_eq_spec_var) wrapper_vars where - is_constraint_var v = typeTypeOrConstraint (tyVarKind v) == ConstraintLike - -- implements (R3) from the Note - worker_vars = univ_tvs ++ ex_tvs eq_spec_tvs = mkUnVarSet (map eqSpecTyVar eq_spec) is_eq_spec_var = (`elemUnVarSet` eq_spec_tvs) -- (R2) from the Note - depleted_worker_vars = filterOut (is_eq_spec_var <||> is_constraint_var) - worker_vars + depleted_worker_vars = filterOut is_eq_spec_var worker_vars wrapper_vars = dataConUserTyVars dc - depleted_wrapper_vars = filterOut is_constraint_var wrapper_vars dataConUserTyVarsNeedWrapper :: DataCon -> Bool -- Check whether the worker and wapper have the same type variables ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -325,113 +325,6 @@ Because the tyvar form above includes r in its result, we must be careful not to let any variables escape -- thus the last premise of the rule above. -Note [Constraints in kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Do we allow a type constructor to have a kind like - S :: Eq a => a -> Type - -No, we do not. Doing so would mean would need a TyConApp like - S @k @(d :: Eq k) (ty :: k) - and we have no way to build, or decompose, evidence like - (d :: Eq k) at the type level. - -But we admit one exception: equality. We /do/ allow, say, - MkT :: (a ~ b) => a -> b -> Type a b - -Why? Because we can, without much difficulty. Moreover -we can promote a GADT data constructor (see TyCon -Note [Promoted data constructors]), like - data GT a b where - MkGT : a -> a -> GT a a -so programmers might reasonably expect to be able to -promote MkT as well. - -How does this work? - -* In GHC.Tc.Validity.checkConstraintsOK we reject kinds that - have constraints other than (a~b) and (a~~b). - -* In Inst.tcInstInvisibleTyBinder we instantiate a call - of MkT by emitting - [W] co :: alpha ~# beta - and producing the elaborated term - MkT @alpha @beta (Eq# alpha beta co) - We don't generate a boxed "Wanted"; we generate only a - regular old /unboxed/ primitive-equality Wanted, and build - the box on the spot. - -* How can we get such a MkT? By promoting a GADT-style data - constructor, written with an explicit equality constraint. - data T a b where - MkT :: (a~b) => a -> b -> T a b - See DataCon.mkPromotedDataCon - and Note [Promoted data constructors] in GHC.Core.TyCon - -* We support both homogeneous (~) and heterogeneous (~~) - equality. (See Note [The equality types story] - in GHC.Builtin.Types.Prim for a primer on these equality types.) - -* How do we prevent a MkT having an illegal constraint like - Eq a? We check for this at use-sites; see GHC.Tc.Gen.HsType.tcTyVar, - specifically dc_theta_illegal_constraint. - -* Notice that nothing special happens if - K :: (a ~# b) => blah - because (a ~# b) is not a predicate type, and is never - implicitly instantiated. (Mind you, it's not clear how you - could creates a type constructor with such a kind.) See - Note [Types for coercions, predicates, and evidence] - -* The existence of promoted MkT with an equality-constraint - argument is the (only) reason that the AnonTCB constructor - of TyConBndrVis carries an FunTyFlag. - For example, when we promote the data constructor - MkT :: forall a b. (a~b) => a -> b -> T a b - we get a PromotedDataCon with tyConBinders - Bndr (a :: Type) (NamedTCB Inferred) - Bndr (b :: Type) (NamedTCB Inferred) - Bndr (_ :: a ~ b) (AnonTCB FTF_C_T) - Bndr (_ :: a) (AnonTCB FTF_T_T)) - Bndr (_ :: b) (AnonTCB FTF_T_T)) - -* One might reasonably wonder who *unpacks* these boxes once they are - made. After all, there is no type-level `case` construct. The - surprising answer is that no one ever does. Instead, if a GADT - constructor is used on the left-hand side of a type family equation, - that occurrence forces GHC to unify the types in question. For - example: - - data G a where - MkG :: G Bool - - type family F (x :: G a) :: a where - F MkG = False - - When checking the LHS `F MkG`, GHC sees the MkG constructor and then must - unify F's implicit parameter `a` with Bool. This succeeds, making the equation - - F Bool (MkG @Bool ) = False - - Note that we never need unpack the coercion. This is because type - family equations are *not* parametric in their kind variables. That - is, we could have just said - - type family H (x :: G a) :: a where - H _ = False - - The presence of False on the RHS also forces `a` to become Bool, - giving us - - H Bool _ = False - - The fact that any of this works stems from the lack of phase - separation between types and kinds (unlike the very present phase - separation between terms and types). - - Once we have the ability to pattern-match on types below top-level, - this will no longer cut it, but it seems fine for now. - - Note [Arguments to type constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Because of kind polymorphism, in addition to type application we now ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -20,10 +20,10 @@ module GHC.Core.TyCon( PromDataConInfo(..), TyConFlavour(..), -- * TyConBinder - TyConBinder, TyConBndrVis(..), TyConPiTyBinder, + TyConBinder, TyConBndrVis(..), mkNamedTyConBinder, mkNamedTyConBinders, mkRequiredTyConBinder, - mkAnonTyConBinder, mkAnonTyConBinders, mkInvisAnonTyConBinder, + mkAnonTyConBinder, mkAnonTyConBinders, tyConBinderForAllTyFlag, tyConBndrVisForAllTyFlag, isNamedTyConBinder, isVisibleTyConBinder, isInvisibleTyConBinder, isVisibleTcbVis, @@ -440,38 +440,29 @@ See #19367. ************************************************************************ * * - TyConBinder, TyConPiTyBinder + TyConBinder * * ************************************************************************ -} type TyConBinder = VarBndr TyVar TyConBndrVis -type TyConPiTyBinder = VarBndr TyCoVar TyConBndrVis - -- Only PromotedDataCon has TyConPiTyBinders - -- See Note [Promoted GADT data constructors] data TyConBndrVis - = NamedTCB ForAllTyFlag - | AnonTCB FunTyFlag + = NamedTCB ForAllTyFlag -- ^ A named, forall-bound variable (invisible or not) + | AnonTCB -- ^ an ordinary, visible type argument instance Outputable TyConBndrVis where ppr (NamedTCB flag) = ppr flag - ppr (AnonTCB af) = ppr af + ppr AnonTCB = text "AnonTCB" mkAnonTyConBinder :: TyVar -> TyConBinder -- Make a visible anonymous TyCon binder mkAnonTyConBinder tv = assert (isTyVar tv) $ - Bndr tv (AnonTCB visArgTypeLike) + Bndr tv AnonTCB mkAnonTyConBinders :: [TyVar] -> [TyConBinder] mkAnonTyConBinders tvs = map mkAnonTyConBinder tvs -mkInvisAnonTyConBinder :: TyVar -> TyConBinder --- Make an /invisible/ anonymous TyCon binder --- Not used much -mkInvisAnonTyConBinder tv = assert (isTyVar tv) $ - Bndr tv (AnonTCB invisArgTypeLike) - mkNamedTyConBinder :: ForAllTyFlag -> TyVar -> TyConBinder -- The odd argument order supports currying mkNamedTyConBinder vis tv = assert (isTyVar tv) $ @@ -494,10 +485,8 @@ tyConBinderForAllTyFlag :: TyConBinder -> ForAllTyFlag tyConBinderForAllTyFlag (Bndr _ vis) = tyConBndrVisForAllTyFlag vis tyConBndrVisForAllTyFlag :: TyConBndrVis -> ForAllTyFlag -tyConBndrVisForAllTyFlag (NamedTCB vis) = vis -tyConBndrVisForAllTyFlag (AnonTCB af) -- See Note [AnonTCB with constraint arg] - | isVisibleFunArg af = Required - | otherwise = Inferred +tyConBndrVisForAllTyFlag (NamedTCB vis) = vis +tyConBndrVisForAllTyFlag AnonTCB = Required isNamedTyConBinder :: TyConBinder -> Bool -- Identifies kind variables @@ -512,7 +501,7 @@ isVisibleTyConBinder (Bndr _ tcb_vis) = isVisibleTcbVis tcb_vis isVisibleTcbVis :: TyConBndrVis -> Bool isVisibleTcbVis (NamedTCB vis) = isVisibleForAllTyFlag vis -isVisibleTcbVis (AnonTCB af) = isVisibleFunArg af +isVisibleTcbVis AnonTCB = True isInvisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool -- Works for IfaceTyConBinder too @@ -525,7 +514,7 @@ mkTyConKind bndrs res_kind = foldr mk res_kind bndrs where mk :: TyConBinder -> Kind -> Kind mk (Bndr tv (NamedTCB vis)) k = mkForAllTy (Bndr tv vis) k - mk (Bndr tv (AnonTCB af)) k = mkNakedKindFunTy af (varType tv) k + mk (Bndr tv AnonTCB) k = mkNakedKindFunTy FTF_T_T (varType tv) k -- mkNakedKindFunTy: see Note [Naked FunTy] in GHC.Builtin.Types -- | (mkTyConTy tc) returns (TyConApp tc []) @@ -544,9 +533,7 @@ tyConInvisTVBinders tc_bndrs mk_binder (Bndr tv tc_vis) = mkTyVarBinder vis tv where vis = case tc_vis of - AnonTCB af -- Note [AnonTCB with constraint arg] - | isInvisibleFunArg af -> InferredSpec - | otherwise -> SpecifiedSpec + AnonTCB -> SpecifiedSpec NamedTCB Required -> SpecifiedSpec NamedTCB (Invisible vis) -> vis @@ -556,35 +543,7 @@ tyConVisibleTyVars tc = [ tv | Bndr tv vis <- tyConBinders tc , isVisibleTcbVis vis ] -{- Note [AnonTCB with constraint arg] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It's pretty rare to have an (AnonTCB af) binder with af=FTF_C_T or FTF_C_C. -The only way it can occur is through equality constraints in kinds. These -can arise in one of two ways: - -* In a PromotedDataCon whose kind has an equality constraint: - - 'MkT :: forall a b. (a~b) => blah - - See Note [Constraints in kinds] in GHC.Core.TyCo.Rep, and - Note [Promoted data constructors] in this module. - -* In a data type whose kind has an equality constraint, as in the - following example from #12102: - - data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type - -When mapping an (AnonTCB FTF_C_x) to an ForAllTyFlag, in -tyConBndrVisForAllTyFlag, we use "Inferred" to mean "the user cannot -specify this arguments, even with visible type/kind application; -instead the type checker must fill it in. - -We map (AnonTCB FTF_T_x) to Required, of course: the user must -provide it. It would be utterly wrong to do this for constraint -arguments, which is why AnonTCB must have the FunTyFlag in -the first place. - -Note [Building TyVarBinders from TyConBinders] +{- Note [Building TyVarBinders from TyConBinders] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We sometimes need to build the quantified type of a value from the TyConBinders of a type or class. For that we need not @@ -640,7 +599,7 @@ in GHC.Core.TyCo.Rep), so we change it to Specified when making MkT's PiTyBinder {- Note [The binders/kind/arity fields of a TyCon] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All TyCons have this group of fields - tyConBinders :: [TyConBinder/TyConPiTyBinder] + tyConBinders :: [TyConBinder] tyConResKind :: Kind tyConTyVars :: [TyVar] -- Cached = binderVars tyConBinders -- NB: Currently (Aug 2018), TyCons that own this @@ -651,7 +610,7 @@ All TyCons have this group of fields They fit together like so: -* tyConBinders gives the telescope of type/coercion variables on the LHS of the +* tyConBinders gives the telescope of type variables on the LHS of the type declaration. For example: type App a (b :: k) = a b @@ -668,7 +627,7 @@ They fit together like so: * See Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep for what the visibility flag means. -* Each TyConBinder tyConBinders has a TyVar (sometimes it is TyCoVar), and +* Each TyConBinder in tyConBinders has a TyVar, and that TyVar may scope over some other part of the TyCon's definition. Eg type T a = a -> a we have @@ -740,12 +699,12 @@ instance OutputableBndr tv => Outputable (VarBndr tv TyConBndrVis) where ppr (Bndr v bi) = ppr bi <+> parens (pprBndr LetBind v) instance Binary TyConBndrVis where - put_ bh (AnonTCB af) = do { putByte bh 0; put_ bh af } + put_ bh AnonTCB = do { putByte bh 0 } put_ bh (NamedTCB vis) = do { putByte bh 1; put_ bh vis } get bh = do { h <- getByte bh ; case h of - 0 -> do { af <- get bh; return (AnonTCB af) } + 0 -> return AnonTCB _ -> do { vis <- get bh; return (NamedTCB vis) } } @@ -951,13 +910,15 @@ data TyCon = } -- | Represents promoted data constructor. + -- The kind of a promoted data constructor is the *wrapper* type of + -- the original data constructor. This type must not have constraints + -- (as checked in GHC.Tc.Gen.HsType.tcTyVar). | PromotedDataCon { -- See Note [Promoted data constructors] tyConUnique :: !Unique, -- ^ Same Unique as the data constructor tyConName :: Name, -- ^ Same Name as the data constructor -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConPiTyBinder], -- ^ Full binders - -- TyConPiTyBinder: see Note [Promoted GADT data constructors] + tyConBinders :: [TyConBinder], -- ^ Full binders tyConResKind :: Kind, -- ^ Result kind tyConKind :: Kind, -- ^ Kind of this TyCon tyConArity :: Arity, -- ^ Arity @@ -1017,17 +978,6 @@ where tcTyConScopedTyVars are used only for MonoTcTyCons, not PolyTcTyCons. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType. -Note [Promoted GADT data constructors] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Any promoted GADT data constructor will have a type with equality -constraints in its type; e.g. - K :: forall a b. (a ~# [b]) => a -> b -> T a - -So, when promoted to become a type constructor, the tyConBinders -will include CoVars. That is why we use [TyConPiTyBinder] for the -tyconBinders field. TyConPiTyBinder is a synonym for TyConBinder, -but with the clue that the binder can be a CoVar not just a TyVar. - Note [Representation-polymorphic TyCons] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To check for representation-polymorphism directly in the typechecker, @@ -2044,7 +1994,7 @@ mkFamilyTyCon name binders res_kind resVar flav parent inj -- as the data constructor itself; when we pretty-print -- the TyCon we add a quote; see the Outputable TyCon instance mkPromotedDataCon :: DataCon -> Name -> TyConRepName - -> [TyConPiTyBinder] -> Kind -> [Role] + -> [TyConBinder] -> Kind -> [Role] -> PromDataConInfo -> TyCon mkPromotedDataCon con name rep_name binders res_kind roles rep_info = let tc = ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1731,7 +1731,7 @@ tyConBindersPiTyBinders :: [TyConBinder] -> [PiTyBinder] tyConBindersPiTyBinders = map to_tyb where to_tyb (Bndr tv (NamedTCB vis)) = Named (Bndr tv vis) - to_tyb (Bndr tv (AnonTCB af)) = Anon (tymult (varType tv)) af + to_tyb (Bndr tv AnonTCB) = Anon (tymult (varType tv)) FTF_T_T -- | Make a dependent forall over an 'Inferred' variable mkTyCoInvForAllTy :: TyCoVar -> Type -> Type @@ -1793,7 +1793,7 @@ mkTyConBindersPreferAnon vars inner_tkvs = assert (all isTyVar vars) = ( Bndr v (NamedTCB Required) : binders , fvs `delVarSet` v `unionVarSet` kind_vars ) | otherwise - = ( Bndr v (AnonTCB visArgTypeLike) : binders + = ( Bndr v AnonTCB : binders , fvs `unionVarSet` kind_vars ) where (binders, fvs) = go vs @@ -2484,9 +2484,8 @@ Here are the key kinding rules for types -- in GHC.Builtin.Types.Prim torc is TYPE or CONSTRAINT - ty : body_torc rep - bndr_torc is Type or Constraint - ki : bndr_torc + ty : torc rep + ki : Type `a` is a type variable `a` is not free in rep (FORALL1) ----------------------- @@ -2504,10 +2503,6 @@ Here are the key kinding rules for types Note that: * (FORALL1) rejects (forall (a::Maybe). blah) -* (FORALL1) accepts (forall (a :: t1~t2) blah), where the type variable - (not coercion variable!) 'a' has a kind (t1~t2) that in turn has kind - Constraint. See Note [Constraints in kinds] in GHC.Core.TyCo.Rep. - * (FORALL2) Surprise 1: See GHC.Core.TyCo.Rep Note [Unused coercion variable in ForAllTy] @@ -2805,8 +2800,7 @@ tyConAppNeedsKindSig spec_inj_pos tc n_args injective_vars_of_binder :: TyConBinder -> FV injective_vars_of_binder (Bndr tv vis) = case vis of - AnonTCB af | isVisibleFunArg af - -> injectiveVarsOfType False -- conservative choice + AnonTCB -> injectiveVarsOfType False -- conservative choice (varType tv) NamedTCB argf | source_of_injectivity argf -> unitFV tv `unionFV` ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -81,6 +81,7 @@ import GHC.Types.Cpr ( topCprSig ) import GHC.Utils.Outputable import GHC.Utils.Panic +import GHC.Utils.Panic.Plain import GHC.Utils.Misc import Data.Maybe ( isNothing, catMaybes ) @@ -353,12 +354,8 @@ toIfaceAppArgsX fr kind ty_args ts' = go (extendTCvSubst env tv t) res ts go env (FunTy { ft_af = af, ft_res = res }) (t:ts) - = IA_Arg (toIfaceTypeX fr t) argf (go env res ts) - where - argf | isVisibleFunArg af = Required - | otherwise = Inferred - -- It's rare for a kind to have a constraint argument, but it - -- can happen. See Note [AnonTCB with constraint arg] in GHC.Core.TyCon. + = assert (isVisibleFunArg af) + IA_Arg (toIfaceTypeX fr t) Required (go env res ts) go env ty ts@(t1:ts1) | not (isEmptyTCvSubst env) ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -205,7 +205,7 @@ mkIfaceTyConKind :: [IfaceTyConBinder] -> IfaceKind -> IfaceKind mkIfaceTyConKind bndrs res_kind = foldr mk res_kind bndrs where mk :: IfaceTyConBinder -> IfaceKind -> IfaceKind - mk (Bndr tv (AnonTCB af)) k = IfaceFunTy af many_ty (ifaceBndrType tv) k + mk (Bndr tv AnonTCB) k = IfaceFunTy FTF_T_T many_ty (ifaceBndrType tv) k mk (Bndr tv (NamedTCB vis)) k = IfaceForAllTy (Bndr tv vis) k ifaceForAllSpecToBndrs :: [IfaceForAllSpecBndr] -> [IfaceForAllBndr] @@ -890,12 +890,7 @@ pprIfaceTyConBinders suppress_sig = sep . map go go (Bndr (IfaceTvBndr bndr) vis) = -- See Note [Pretty-printing invisible arguments] case vis of - AnonTCB af - | isVisibleFunArg af -> ppr_bndr (UseBndrParens True) - | otherwise -> char '@' <> braces (ppr_bndr (UseBndrParens False)) - -- The above case is rare. (See Note [AnonTCB with constraint arg] - -- in GHC.Core.TyCon.) - -- Should we print these differently? + AnonTCB -> ppr_bndr (UseBndrParens True) NamedTCB Required -> ppr_bndr (UseBndrParens True) NamedTCB Specified -> char '@' <> ppr_bndr (UseBndrParens True) NamedTCB Inferred -> char '@' <> braces (ppr_bndr (UseBndrParens False)) ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -13,7 +13,7 @@ module GHC.Rename.HsType ( -- Type related stuff rnHsType, rnLHsType, rnLHsTypes, rnContext, rnMaybeContext, - rnHsKind, rnLHsKind, rnLHsTypeArgs, + rnLHsKind, rnLHsTypeArgs, rnHsSigType, rnHsWcType, rnHsPatSigTypeBindingVars, HsPatSigTypeScoping(..), rnHsSigWcType, rnHsPatSigType, newTyVarNameRn, @@ -468,35 +468,6 @@ rnImplicitTvBndrs ctx mb_assoc implicit_vs_with_dups thing_inside {- rnHsType is here because we call it from loadInstDecl, and I didn't want a gratuitous knot. - -Note [HsQualTy in kinds] -~~~~~~~~~~~~~~~~~~~~~~ -I was wondering whether HsQualTy could occur only at TypeLevel. But no, -we can have a qualified type in a kind too. Here is an example: - - type family F a where - F Bool = Nat - F Nat = Type - - type family G a where - G Type = Type -> Type - G () = Nat - - data X :: forall k1 k2. (F k1 ~ G k2) => k1 -> k2 -> Type where - MkX :: X 'True '() - -See that k1 becomes Bool and k2 becomes (), so the equality is -satisfied. If I write MkX :: X 'True 'False, compilation fails with a -suitable message: - - MkX :: X 'True '() - • Couldn't match kind ‘G Bool’ with ‘Nat’ - Expected kind: G Bool - Actual kind: F Bool - -However: in a kind, the constraints in the HsQualTy must all be -equalities; or at least, any kinds with a class constraint are -uninhabited. See Note [Constraints in kinds] in GHC.Core.TyCo.Rep. -} data RnTyKiEnv @@ -552,9 +523,6 @@ rnHsType ctxt ty = rnHsTyKi (mkTyKiEnv ctxt TypeLevel RnTypeBody) ty rnLHsKind :: HsDocContext -> LHsKind GhcPs -> RnM (LHsKind GhcRn, FreeVars) rnLHsKind ctxt kind = rnLHsTyKi (mkTyKiEnv ctxt KindLevel RnTypeBody) kind -rnHsKind :: HsDocContext -> HsKind GhcPs -> RnM (HsKind GhcRn, FreeVars) -rnHsKind ctxt kind = rnHsTyKi (mkTyKiEnv ctxt KindLevel RnTypeBody) kind - -- renaming a type only, not a kind rnLHsTypeArg :: HsDocContext -> LHsTypeArg GhcPs -> RnM (LHsTypeArg GhcRn, FreeVars) @@ -610,11 +578,11 @@ rnHsTyKi env ty@(HsForAllTy { hst_tele = tele, hst_body = tau }) , hst_tele = tele' , hst_body = tau' } , fvs) } } -rnHsTyKi env ty@(HsQualTy { hst_ctxt = lctxt, hst_body = tau }) - = do { data_kinds <- xoptM LangExt.DataKinds -- See Note [HsQualTy in kinds] - ; when (not data_kinds && isRnKindLevel env) - (addErr (dataKindsErr env ty)) - ; (ctxt', fvs1) <- rnTyKiContext env lctxt +rnHsTyKi env (HsQualTy { hst_ctxt = lctxt, hst_body = tau }) + = do { -- no need to check type vs kind level here; this is + -- checked in the type checker. See + -- Note [No constraints in kinds] in GHC.Tc.Validity + (ctxt', fvs1) <- rnTyKiContext env lctxt ; (tau', fvs2) <- rnLHsTyKi env tau ; return (HsQualTy { hst_xqual = noExtField, hst_ctxt = ctxt' , hst_body = tau' } ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2066,14 +2066,7 @@ preceded by `type`, with the following restrictions: (R3) There are no strictness flags, because they don't make sense at the type level. -(R4) The types of the constructors contain no constraints other than - equality constraints. (This is the same restriction imposed - on constructors to be promoted with the DataKinds extension in - dc_theta_illegal_constraint called from GHC.Tc.Gen.HsType.tcTyVar, - but in that case the restriction is imposed if and when a data - constructor is used in a type, whereas here it is imposed at - the point of definition. See also Note [Constraints in kinds] - in GHC.Core.TyCo.Rep.) +(R4) The types of the constructors contain no constraints. (R5) There are no deriving clauses. ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -913,9 +913,7 @@ instance Diagnostic TcRnMessage where 2 (parens reason)) where reason = case err of - ConstrainedDataConPE pred - -> text "it has an unpromotable context" - <+> quotes (ppr pred) + ConstrainedDataConPE -> text "it has a context" FamDataConPE -> text "it comes from a data family instance" NoDataKindsDC -> text "perhaps you intended to use DataKinds" PatSynPE -> text "pattern synonyms cannot be promoted" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -3724,9 +3724,7 @@ data PromotionErr | FamDataConPE -- Data constructor for a data family -- See Note [AFamDataCon: not promoting data family constructors] -- in GHC.Tc.Utils.Env. - | ConstrainedDataConPE PredType - -- Data constructor with a non-equality context - -- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep + | ConstrainedDataConPE -- Data constructor with a context | PatSynPE -- Pattern synonyms -- See Note [Don't promote pattern synonyms] in GHC.Tc.Utils.Env @@ -3736,28 +3734,27 @@ data PromotionErr | NoDataKindsDC -- -XDataKinds not enabled (for a datacon) instance Outputable PromotionErr where - ppr ClassPE = text "ClassPE" - ppr TyConPE = text "TyConPE" - ppr PatSynPE = text "PatSynPE" - ppr FamDataConPE = text "FamDataConPE" - ppr (ConstrainedDataConPE pred) = text "ConstrainedDataConPE" - <+> parens (ppr pred) - ppr RecDataConPE = text "RecDataConPE" - ppr NoDataKindsDC = text "NoDataKindsDC" - ppr TermVariablePE = text "TermVariablePE" + ppr ClassPE = text "ClassPE" + ppr TyConPE = text "TyConPE" + ppr PatSynPE = text "PatSynPE" + ppr FamDataConPE = text "FamDataConPE" + ppr ConstrainedDataConPE = text "ConstrainedDataConPE" + ppr RecDataConPE = text "RecDataConPE" + ppr NoDataKindsDC = text "NoDataKindsDC" + ppr TermVariablePE = text "TermVariablePE" pprPECategory :: PromotionErr -> SDoc pprPECategory = text . capitalise . peCategory peCategory :: PromotionErr -> String -peCategory ClassPE = "class" -peCategory TyConPE = "type constructor" -peCategory PatSynPE = "pattern synonym" -peCategory FamDataConPE = "data constructor" -peCategory ConstrainedDataConPE{} = "data constructor" -peCategory RecDataConPE = "data constructor" -peCategory NoDataKindsDC = "data constructor" -peCategory TermVariablePE = "term variable" +peCategory ClassPE = "class" +peCategory TyConPE = "type constructor" +peCategory PatSynPE = "pattern synonym" +peCategory FamDataConPE = "data constructor" +peCategory ConstrainedDataConPE = "data constructor" +peCategory RecDataConPE = "data constructor" +peCategory NoDataKindsDC = "data constructor" +peCategory TermVariablePE = "term variable" -- | Stores the information to be reported in a representation-polymorphism -- error message. ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -1613,8 +1613,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args case ki_binder of -- FunTy with PredTy on LHS, or ForAllTy with Inferred - Named (Bndr _ Inferred) -> instantiate ki_binder inner_ki - Anon _ af | isInvisibleFunArg af -> instantiate ki_binder inner_ki + Named (Bndr kv Inferred) -> instantiate kv inner_ki Named (Bndr _ Specified) -> -- Visible kind application do { traceTc "tcInferTyApps (vis kind app)" @@ -1644,9 +1643,9 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args ---------------- HsValArg: a normal argument (fun ty) (HsValArg arg : args, Just (ki_binder, inner_ki)) -- next binder is invisible; need to instantiate it - | isInvisiblePiTyBinder ki_binder -- FunTy with constraint on LHS; - -- or ForAllTy with Inferred or Specified - -> instantiate ki_binder inner_ki + | Named (Bndr kv flag) <- ki_binder + , isInvisibleForAllTyFlag flag -- ForAllTy with Inferred or Specified + -> instantiate kv inner_ki -- "normal" case | otherwise @@ -1984,23 +1983,16 @@ tcTyVar name -- Could be a tyvar, a tycon, or a datacon -- see #15245 promotionErr name FamDataConPE ; let (_, _, _, theta, _, _) = dataConFullSig dc - ; traceTc "tcTyVar" (ppr dc <+> ppr theta $$ ppr (dc_theta_illegal_constraint theta)) - ; case dc_theta_illegal_constraint theta of - Just pred -> promotionErr name $ - ConstrainedDataConPE pred - Nothing -> pure () + ; traceTc "tcTyVar" (ppr dc <+> ppr theta) + -- promotionErr: Note [No constraints in kinds] in GHC.Tc.Validity + ; unless (null theta) $ + promotionErr name ConstrainedDataConPE ; let tc = promoteDataCon dc ; return (mkTyConApp tc [], tyConKind tc) } APromotionErr err -> promotionErr name err _ -> wrongThingErr "type" thing name } - where - -- We cannot promote a data constructor with a context that contains - -- constraints other than equalities, so error if we find one. - -- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep - dc_theta_illegal_constraint :: ThetaType -> Maybe PredType - dc_theta_illegal_constraint = find (not . isEqPred) {- Note [Recursion through the kinds] @@ -3715,9 +3707,10 @@ splitTyConKind skol_info in_scope avoid_occs kind Nothing -> (reverse acc, substTy subst kind) Just (Anon arg af, kind') - -> go occs' uniqs' subst' (tcb : acc) kind' + -> assert (af == FTF_T_T) $ + go occs' uniqs' subst' (tcb : acc) kind' where - tcb = Bndr tv (AnonTCB af) + tcb = Bndr tv AnonTCB arg' = substTy subst (scaledThing arg) name = mkInternalName uniq occ loc tv = mkTcTyVar name arg' details @@ -3858,7 +3851,8 @@ tcbVisibilities tc orig_args go fun_kind subst all_args@(arg : args) | Just (tcb, inner_kind) <- splitPiTy_maybe fun_kind = case tcb of - Anon _ af -> AnonTCB af : go inner_kind subst args + Anon _ af -> assert (af == FTF_T_T) $ + AnonTCB : go inner_kind subst args Named (Bndr tv vis) -> NamedTCB vis : go inner_kind subst' args where subst' = extendTCvSubst subst tv arg ===================================== compiler/GHC/Tc/Solver/Rewrite.hs ===================================== @@ -1079,7 +1079,7 @@ ty_con_binders_ty_binders' = foldr go ([], False) where go (Bndr tv (NamedTCB vis)) (bndrs, _) = (Named (Bndr tv vis) : bndrs, True) - go (Bndr tv (AnonTCB af)) (bndrs, n) - = (Anon (tymult (tyVarKind tv)) af : bndrs, n) + go (Bndr tv AnonTCB) (bndrs, n) + = (Anon (tymult (tyVarKind tv)) FTF_T_T : bndrs, n) {-# INLINE go #-} {-# INLINE ty_con_binders_ty_binders' #-} ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -4069,8 +4069,7 @@ mkGADTVars tmpl_tvs dc_tvs subst tv_kind = tyVarKind t_tv tv_kind' = substTy t_sub tv_kind t_tv' = setTyVarKind t_tv tv_kind' - eqs' | isConstraintLikeKind (typeKind tv_kind') = eqs - | otherwise = (t_tv', r_ty) : eqs + eqs' = (t_tv', r_ty) : eqs | otherwise = pprPanic "mkGADTVars" (ppr tmpl_tvs $$ ppr subst) ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -44,7 +44,7 @@ import GHC.Prelude import GHC.Driver.Session import GHC.Driver.Env -import GHC.Builtin.Types ( heqDataCon, eqDataCon, integerTyConName ) +import GHC.Builtin.Types ( heqDataCon, integerTyConName ) import GHC.Builtin.Names import GHC.Hs @@ -54,14 +54,12 @@ import GHC.Core.InstEnv import GHC.Core.Predicate import GHC.Core ( Expr(..), isOrphan ) -- For the Coercion constructor import GHC.Core.Type -import GHC.Core.Multiplicity -import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr ( debugPprType ) import GHC.Core.Class( Class ) import GHC.Core.DataCon import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcCheckPolyExpr, tcSyntaxOp ) -import {-# SOURCE #-} GHC.Tc.Utils.Unify( unifyType, unifyKind ) +import {-# SOURCE #-} GHC.Tc.Utils.Unify( unifyType ) import GHC.Tc.Utils.Zonk import GHC.Tc.Utils.Monad import GHC.Tc.Types.Constraint @@ -387,71 +385,21 @@ tcInstInvisibleTyBindersN n ty go n subst kind | n > 0 - , Just (bndr, body) <- tcSplitPiTy_maybe kind - , isInvisiblePiTyBinder bndr - = do { (subst', arg) <- tcInstInvisibleTyBinder subst bndr + , Just (bndr, body) <- tcSplitForAllTyVarBinder_maybe kind + , isInvisibleForAllTyFlag (binderFlag bndr) + = do { (subst', arg) <- tcInstInvisibleTyBinder subst (binderVar bndr) ; (args, inner_ty) <- go (n-1) subst' body ; return (arg:args, inner_ty) } | otherwise = return ([], substTy subst kind) -tcInstInvisibleTyBinder :: Subst -> PiTyVarBinder -> TcM (Subst, TcType) +tcInstInvisibleTyBinder :: Subst -> TyVar -> TcM (Subst, TcType) -- Called only to instantiate kinds, in user-written type signatures -tcInstInvisibleTyBinder subst (Named (Bndr tv _)) +tcInstInvisibleTyBinder subst tv = do { (subst', tv') <- newMetaTyVarX subst tv ; return (subst', mkTyVarTy tv') } -tcInstInvisibleTyBinder subst (Anon ty af) - | Just (mk, k1, k2) <- get_eq_tys_maybe (substTy subst (scaledThing ty)) - -- For kinds like (k1 ~ k2) => blah, we want to emit a unification - -- constraint for (k1 ~# k2) and return the argument (Eq# k1 k2) - -- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep - -- Equality is the *only* constraint currently handled in types. - = assert (isInvisibleFunArg af) $ - do { co <- unifyKind Nothing k1 k2 - ; return (subst, mk co) } - - | otherwise -- This should never happen - -- See GHC.Core.TyCo.Rep Note [Constraints in kinds] - = pprPanic "tcInvisibleTyBinder" (ppr ty) - -------------------------------- -get_eq_tys_maybe :: Type - -> Maybe ( Coercion -> Type - -- Given a coercion proving t1 ~# t2, produce the - -- right instantiation for the PiTyVarBinder at hand - , Type -- t1 - , Type -- t2 - ) --- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep -get_eq_tys_maybe ty - -- Lifted heterogeneous equality (~~) - | Just (tc, [_, _, k1, k2]) <- splitTyConApp_maybe ty - , tc `hasKey` heqTyConKey - = Just (mkHEqBoxTy k1 k2, k1, k2) - - -- Lifted homogeneous equality (~) - | Just (tc, [_, k1, k2]) <- splitTyConApp_maybe ty - , tc `hasKey` eqTyConKey - = Just (mkEqBoxTy k1 k2, k1, k2) - - | otherwise - = Nothing - --- | This takes @a ~# b@ and returns @a ~~ b at . -mkHEqBoxTy :: Type -> Type -> TcCoercion -> Type -mkHEqBoxTy ty1 ty2 co - = mkTyConApp (promoteDataCon heqDataCon) [k1, k2, ty1, ty2, mkCoercionTy co] - where k1 = typeKind ty1 - k2 = typeKind ty2 - --- | This takes @a ~# b@ and returns @a ~ b at . -mkEqBoxTy :: Type -> Type -> TcCoercion -> Type -mkEqBoxTy ty1 ty2 co - = mkTyConApp (promoteDataCon eqDataCon) [k, ty1, ty2, mkCoercionTy co] - where k = typeKind ty1 - {- ********************************************************************* * * SkolemTvs (immutable) ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -1344,7 +1344,7 @@ getDFunTyLitKey (CharTyLit n) = mkOccName Name.varName (show n) -- Always succeeds, even if it returns an empty list. tcSplitPiTys :: Type -> ([PiTyVarBinder], Type) tcSplitPiTys ty - = assert (all isTyBinder (fst sty) ) -- No CoVar binders here + = assert (all isTyBinder (fst sty)) -- No CoVar binders here sty where sty = splitPiTys ty @@ -1367,7 +1367,7 @@ tcSplitForAllTyVarBinder_maybe _ = Nothing -- returning just the tyvars. tcSplitForAllTyVars :: Type -> ([TyVar], Type) tcSplitForAllTyVars ty - = assert (all isTyVar (fst sty) ) sty + = assert (all isTyVar (fst sty)) sty where sty = splitForAllTyCoVars ty -- | Like 'tcSplitForAllTyVars', but only splits 'ForAllTy's with 'Invisible' ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -520,6 +520,8 @@ typeOrKindCtxt (DataKindCtxt {}) = OnlyKindCtxt typeOrKindCtxt (TySynKindCtxt {}) = OnlyKindCtxt typeOrKindCtxt (TyFamResKindCtxt {}) = OnlyKindCtxt +-- These cases are also described in Note [No constraints in kinds], so any +-- change here should be reflected in that note. typeOrKindCtxt (TySynCtxt {}) = BothTypeAndKindCtxt -- Type synonyms can have types and kinds on their RHSs typeOrKindCtxt (GhciCtxt {}) = BothTypeAndKindCtxt @@ -543,7 +545,6 @@ typeLevelUserTypeCtxt ctxt = case typeOrKindCtxt ctxt of -- | Returns 'True' if the supplied 'UserTypeCtxt' is unambiguously not the -- context for a kind of a type, where the arbitrary use of constraints is -- currently disallowed. --- (See @Note [Constraints in kinds]@ in "GHC.Core.TyCo.Rep".) allConstraintsAllowed :: UserTypeCtxt -> Bool allConstraintsAllowed = typeLevelUserTypeCtxt @@ -931,10 +932,9 @@ checkConstraintsOK :: ValidityEnv -> ThetaType -> Type -> TcM () checkConstraintsOK ve theta ty | null theta = return () | allConstraintsAllowed (ve_ctxt ve) = return () - | otherwise - = -- We are in a kind, where we allow only equality predicates - -- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep, and #16263 - checkTcM (all isEqPred theta) (env, TcRnConstraintInKind (tidyType env ty)) + | otherwise -- We are unambiguously in a kind; see + -- Note [No constraints in kinds] + = failWithTcM (env, TcRnConstraintInKind (tidyType env ty)) where env = ve_tidy_env ve checkVdqOK :: ValidityEnv -> [TyVarBinder] -> Type -> TcM () @@ -945,7 +945,25 @@ checkVdqOK ve tvbs ty = do no_vdq = all (isInvisibleForAllTyFlag . binderFlag) tvbs ValidityEnv{ve_tidy_env = env, ve_ctxt = ctxt} = ve -{- +{- Note [No constraints in kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +GHC does not allow constraints in kinds. Equality constraints +in kinds were allowed from GHC 8.0, but this "feature" was removed +as part of Proposal #547 (https://github.com/ghc-proposals/ghc-proposals/pull/547), +which contains further context and motivation for this removal. + +The lack of constraints in kinds is enforced by checkConstraintsOK, which +uses the UserTypeCtxt to determine if we are unambiguously checking a kind. +There are two ambiguous contexts (constructor BothTypeAndKindCtxt of TypeOrKindCtxt) +as written in typeOfKindCtxt: + - TySynCtxt: this is the RHS of a type synonym. We check the expansion of type + synonyms for constraints, so this is handled at the usage site of the synonym. + - GhciCtxt: This is the type in a :kind command. A constraint here does not cause + any trouble, because the type cannot be used to classify a type. + +Beyond these two cases, we also promote data constructors. We check for constraints +in data constructor types in GHC.Tc.Gen.HsType.tcTyVar. + Note [Liberal type synonyms] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If -XLiberalTypeSynonyms is on, expand closed type synonyms *before* ===================================== compiler/GHC/Types/Var.hs ===================================== @@ -682,10 +682,6 @@ Currently there are nine different uses of 'VarBndr': * TyCon.TyConBinder = VarBndr TyVar TyConBndrVis Binders of a TyCon; see TyCon in GHC.Core.TyCon -* TyCon.TyConPiTyBinder = VarBndr TyCoVar TyConBndrVis - Binders of a PromotedDataCon - See Note [Promoted GADT data constructors] in GHC.Core.TyCon - * IfaceType.IfaceForAllBndr = VarBndr IfaceBndr ForAllTyFlag * IfaceType.IfaceForAllSpecBndr = VarBndr IfaceBndr Specificity * IfaceType.IfaceTyConBinder = VarBndr IfaceBndr TyConBndrVis ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -91,17 +91,12 @@ There are only a couple of exceptions to this rule: type theory just isn’t up to the task of promoting data families, which requires full dependent types. -- Data constructors with contexts that contain non-equality constraints cannot - be promoted. For example: :: +- Data constructors with contexts cannot be promoted; but GADTs can. For example:: data Foo :: Type -> Type where - MkFoo1 :: a ~ Int => Foo a -- promotable - MkFoo2 :: a ~~ Int => Foo a -- promotable - MkFoo3 :: Show a => Foo a -- not promotable - - ``MkFoo1`` and ``MkFoo2`` can be promoted, since their contexts - only involve equality-oriented constraints. However, ``MkFoo3``'s context - contains a non-equality constraint ``Show a``, and thus cannot be promoted. + MkFoo1 :: Show a => Foo a -- not promotable + MkFoo2 :: (a ~ Int) => Foo a -- not promotable + MkFoo3 :: Foo Int -- promotable .. _promotion-syntax: @@ -215,28 +210,3 @@ parameter to ``UnEx``, the kind is not escaping the existential, and the above code is valid. See also :ghc-ticket:`7347`. - -.. _constraints_in_kinds: - -Constraints in kinds --------------------- - -Kinds can (with :extension:`DataKinds`) contain type constraints. However, -only equality constraints are supported. - -Here is an example of a constrained kind: :: - - type family IsTypeLit a where - IsTypeLit Nat = True - IsTypeLit Symbol = True - IsTypeLit a = False - - data T :: forall a. (IsTypeLit a ~ True) => a -> Type where - MkNat :: T 42 - MkSymbol :: T "Don't panic!" - -The declarations above are accepted. However, if we add ``MkOther :: T Int``, -we get an error that the equality constraint is not satisfied; ``Int`` is -not a type literal. Note that explicitly quantifying with ``forall a`` is -necessary in order for ``T`` to typecheck -(see :ref:`complete-kind-signatures`). ===================================== testsuite/tests/simplCore/should_compile/T18355.stderr ===================================== @@ -7,16 +7,8 @@ Result size of Tidy Core f :: forall {a}. Num a => a -> Bool -> a -> a [GblId, Arity=4, -<<<<<<< HEAD - Str=<1P(MC1(C1(L)),MC1(C1(L)),A,A,A,A,A)><1L>, + Str=<1P(MC(1,C(1,L)),MC(1,C(1,L)),A,A,A,A,A)><1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, -||||||| parent of 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, -======= - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, ->>>>>>> 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 0 70 0] 100 0}] f = \ (@a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3120a7928168618f3f91ba72e19fb0dbd5a89f9b...9d48a1b74bd6c5ab6af8e322250f6109a6d8c856 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3120a7928168618f3f91ba72e19fb0dbd5a89f9b...9d48a1b74bd6c5ab6af8e322250f6109a6d8c856 You're receiving 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 Nov 12 23:07:43 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 12 Nov 2022 18:07:43 -0500 Subject: [Git][ghc/ghc][wip/T21623-faster] Better implementation of typeKind Message-ID: <6370273f59f4c_24229e526c0402834@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623-faster at Glasgow Haskell Compiler / GHC Commits: 5bf6af99 by Simon Peyton Jones at 2022-11-12T23:07:02+00:00 Better implementation of typeKind - - - - - 5 changed files: - + compiler/GHC/Core/TyCo/FVs.hs-boot - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/TcType.hs Changes: ===================================== compiler/GHC/Core/TyCo/FVs.hs-boot ===================================== @@ -0,0 +1,6 @@ +module GHC.Core.TyCo.FVs where + +import GHC.Prelude ( Bool ) +import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Type ) + +noFreeVarsOfType :: Type -> Bool ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -105,6 +105,7 @@ module GHC.Core.TyCon( tyConPromDataConInfo, tyConBinders, tyConResKind, tyConInvisTVBinders, tcTyConScopedTyVars, tcTyConIsPoly, + tyConHasClosedResKind, tyConTypeKindPieces, mkTyConTagMap, -- ** Manipulating TyCons @@ -138,6 +139,8 @@ import GHC.Platform import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Kind, Type, PredType, mkForAllTy, mkNakedKindFunTy, mkNakedTyConTy ) +import {-# SOURCE #-} GHC.Core.TyCo.FVs + ( noFreeVarsOfType ) import {-# SOURCE #-} GHC.Core.TyCo.Ppr ( pprType ) import {-# SOURCE #-} GHC.Builtin.Types @@ -803,6 +806,7 @@ data TyCon = tyConKind :: Kind, -- ^ Kind of this TyCon tyConArity :: Arity, -- ^ Arity tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ + tyConHasClosedResKind :: Bool, -- The tyConTyVars scope over: -- @@ -864,6 +868,7 @@ data TyCon = tyConKind :: Kind, -- ^ Kind of this TyCon tyConArity :: Arity, -- ^ Arity tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ + tyConHasClosedResKind :: Bool, -- tyConTyVars scope over: synTcRhs tcRoles :: [Role], -- ^ The role for each type variable @@ -903,6 +908,7 @@ data TyCon = tyConKind :: Kind, -- ^ Kind of this TyCon tyConArity :: Arity, -- ^ Arity tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ + tyConHasClosedResKind :: Bool, -- tyConTyVars connect an associated family TyCon -- with its parent class; see GHC.Tc.Validity.checkConsistentFamInst @@ -940,6 +946,7 @@ data TyCon = tyConKind :: Kind, -- ^ Kind of this TyCon tyConArity :: Arity, -- ^ Arity tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ + tyConHasClosedResKind :: Bool, tcRoles :: [Role], -- ^ The role for each type variable -- This list has length = tyConArity @@ -962,6 +969,7 @@ data TyCon = tyConKind :: Kind, -- ^ Kind of this TyCon tyConArity :: Arity, -- ^ Arity tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ + tyConHasClosedResKind :: Bool, tcRoles :: [Role], -- ^ Roles: N for kind vars, R for type vars dataCon :: DataCon, -- ^ Corresponding data constructor @@ -982,6 +990,7 @@ data TyCon = tyConKind :: Kind, -- ^ Kind of this TyCon tyConArity :: Arity, -- ^ Arity tyConNullaryTy :: Type, -- ^ A pre-allocated @TyConApp tycon []@ + tyConHasClosedResKind :: Bool, -- NB: the tyConArity of a TcTyCon must match -- the number of Required (positional, user-specified) @@ -994,7 +1003,10 @@ data TyCon = -- MonoTcTyCon only: see Note [Scoped tyvars in a TcTyCon] tcTyConIsPoly :: Bool, -- ^ Is this TcTyCon already generalized? - -- Used only to make zonking more efficient + -- True for PolyTcTyCon, False for MonoTcTyCon + -- Used only to make zonking more efficient + -- See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in + -- GHC.Tc.Utils.TcType tcTyConFlavour :: TyConFlavour -- ^ What sort of 'TyCon' this represents. @@ -1043,7 +1055,7 @@ to know, given a TyCon 'T' of arity 'n', does always have a fixed RuntimeRep? That is, is it always the case that this application has a kind of the form - +v T a_1 ... a_n :: TYPE rep in which 'rep' is a concrete 'RuntimeRep'? @@ -1856,6 +1868,7 @@ mkAlgTyCon name binders res_kind roles cType stupid rhs parent gadt_syn tyConKind = mkTyConKind binders res_kind, tyConArity = length binders, tyConNullaryTy = mkNakedTyConTy tc, + tyConHasClosedResKind = noFreeVarsOfType res_kind, tyConTyVars = binderVars binders, tcRoles = roles, tyConCType = cType, @@ -1895,6 +1908,7 @@ mkTupleTyCon name binders res_kind arity con sort parent tyConKind = mkTyConKind binders res_kind, tyConArity = arity, tyConNullaryTy = mkNakedTyConTy tc, + tyConHasClosedResKind = noFreeVarsOfType res_kind, tcRoles = replicate arity Representational, tyConCType = Nothing, algTcGadtSyntax = False, @@ -1925,6 +1939,7 @@ mkSumTyCon name binders res_kind arity tyvars cons parent tyConKind = mkTyConKind binders res_kind, tyConArity = arity, tyConNullaryTy = mkNakedTyConTy tc, + tyConHasClosedResKind = noFreeVarsOfType res_kind, tcRoles = replicate arity Representational, tyConCType = Nothing, algTcGadtSyntax = False, @@ -1960,6 +1975,7 @@ mkTcTyCon name binders res_kind scoped_tvs poly flav , tyConKind = mkTyConKind binders res_kind , tyConArity = length binders , tyConNullaryTy = mkNakedTyConTy tc + , tyConHasClosedResKind = noFreeVarsOfType res_kind , tcTyConScopedTyVars = scoped_tvs , tcTyConIsPoly = poly , tcTyConFlavour = flav } @@ -1989,6 +2005,7 @@ mkPrimTyCon name binders res_kind roles tyConKind = mkTyConKind binders res_kind, tyConArity = length roles, tyConNullaryTy = mkNakedTyConTy tc, + tyConHasClosedResKind = noFreeVarsOfType res_kind, tcRoles = roles, primRepName = mkPrelTyConRepName name } @@ -2007,6 +2024,7 @@ mkSynonymTyCon name binders res_kind roles rhs is_tau is_fam_free is_forgetful tyConKind = mkTyConKind binders res_kind, tyConArity = length binders, tyConNullaryTy = mkNakedTyConTy tc, + tyConHasClosedResKind = noFreeVarsOfType res_kind, tyConTyVars = binderVars binders, tcRoles = roles, synTcRhs = rhs, @@ -2030,6 +2048,7 @@ mkFamilyTyCon name binders res_kind resVar flav parent inj , tyConKind = mkTyConKind binders res_kind , tyConArity = length binders , tyConNullaryTy = mkNakedTyConTy tc + , tyConHasClosedResKind = noFreeVarsOfType res_kind , tyConTyVars = binderVars binders , famTcResVar = resVar , famTcFlav = flav @@ -2053,6 +2072,7 @@ mkPromotedDataCon con name rep_name binders res_kind roles rep_info tyConName = name, tyConArity = length roles, tyConNullaryTy = mkNakedTyConTy tc, + tyConHasClosedResKind = noFreeVarsOfType res_kind, tcRoles = roles, tyConBinders = binders, tyConResKind = res_kind, @@ -2435,6 +2455,16 @@ isTcTyCon :: TyCon -> Bool isTcTyCon (TcTyCon {}) = True isTcTyCon _ = False +tyConTypeKindPieces :: TyCon -> ([TyConBinder], Kind, Bool) +-- This rather specialised function returns the bits needed for typeKind +tyConTypeKindPieces tc + | TcTyCon { tyConKind = kind, tcTyConIsPoly = False } <- tc + = -- For MonoTcTyCons we must use the tyConKind + -- because only that is zonked. See setTcTyConKind + ([], kind, False) + | otherwise + = (tyConBinders tc, tyConResKind tc, tyConHasClosedResKind tc) + setTcTyConKind :: TyCon -> Kind -> TyCon -- Update the Kind of a TcTyCon -- The new kind is always a zonked version of its previous ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1444,7 +1444,7 @@ piResultTys ty orig_args@(arg:args) = piResultTys res args | ForAllTy (Bndr tv _) res <- ty - = go (extendTCvSubst init_subst tv arg) res args + = piResultTysX (extendTCvSubst init_subst tv arg) res args | Just ty' <- coreView ty = piResultTys ty' orig_args @@ -1454,31 +1454,57 @@ piResultTys ty orig_args@(arg:args) where init_subst = mkEmptySubst $ mkInScopeSet (tyCoVarsOfTypes (ty:orig_args)) - go :: Subst -> Type -> [Type] -> Type - go subst ty [] = substTyUnchecked subst ty - - go subst ty all_args@(arg:args) - | FunTy { ft_res = res } <- ty - = go subst res args +piResultTysX :: Subst -> Type -> [Type] -> Type +piResultTysX subst ty [] = substTy subst ty +piResultTysX subst ty all_args@(arg:args) + | FunTy { ft_res = res } <- ty + = piResultTysX subst res args - | ForAllTy (Bndr tv _) res <- ty - = go (extendTCvSubst subst tv arg) res args + | ForAllTy (Bndr tv _) res <- ty + = piResultTysX (extendTCvSubst subst tv arg) res args - | Just ty' <- coreView ty - = go subst ty' all_args + | Just ty' <- coreView ty + = piResultTysX subst ty' all_args - | not (isEmptyTCvSubst subst) -- See Note [Care with kind instantiation] - = go init_subst - (substTy subst ty) - all_args + | not (isEmptyTCvSubst subst) -- See Note [Care with kind instantiation] + = piResultTysX (zapSubst subst) (substTy subst ty) all_args - | otherwise - = -- We have not run out of arguments, but the function doesn't - -- have the right kind to apply to them; so panic. - -- Without the explicit isEmptyVarEnv test, an ill-kinded type - -- would give an infinite loop, which is very unhelpful - -- c.f. #15473 - pprPanic "piResultTys2" (ppr ty $$ ppr orig_args $$ ppr all_args) + | otherwise + = -- We have not run out of arguments, but the function doesn't + -- have the right kind to apply to them; so panic. + -- Without the explicit isEmptyTCvSubst test, an ill-kinded type + -- would give an infinite loop, which is very unhelpful + -- c.f. #15473 + pprPanic "piResultTys2" (ppr ty $$ ppr all_args) + +tyConAppResKind :: TyCon -> [Type] -> Kind +-- This is a hot function, so we give it special code. +-- Its specification is: +-- tyConAppResKind tc tys = piResultTys (tyConKind tc) tys +tyConAppResKind tc args + | null args = tyConKind tc + | otherwise + = go1 tc_bndrs args + where + !(tc_bndrs, tc_res_kind, closed_res_kind) = tyConTypeKindPieces tc + init_subst = mkEmptySubst $ mkInScopeSet (tyCoVarsOfTypes args) + + go1 :: [TyConBinder] -> [Type] -> Type + go1 [] [] = tc_res_kind + go1 [] args = piResultTys tc_res_kind args + go1 bndrs [] = mkTyConKind bndrs tc_res_kind + go1 (Bndr tv vis : bndrs) (arg:args) + | AnonTCB {} <- vis = go1 bndrs args + | NamedTCB {} <- vis = go2 (extendTCvSubst init_subst tv arg) bndrs args + + go2 :: Subst -> [TyConBinder] -> [Type] -> Type + go2 subst [] [] | closed_res_kind = tc_res_kind + | otherwise = substTy subst tc_res_kind + go2 subst [] args = piResultTysX subst tc_res_kind args + go2 subst bndrs [] = substTy subst (mkTyConKind bndrs tc_res_kind) + go2 subst (Bndr tv vis : bndrs) (arg:args) + | AnonTCB {} <- vis = go2 subst bndrs args + | NamedTCB {} <- vis = go2 (extendTCvSubst subst tv arg) bndrs args applyTysX :: [TyVar] -> Type -> [Type] -> Type -- applyTysX beta-reduces (/\tvs. body_ty) arg_tys @@ -2550,7 +2576,7 @@ See #14939. ----------------------------- typeKind :: HasDebugCallStack => Type -> Kind -- No need to expand synonyms -typeKind (TyConApp tc tys) = piResultTys (tyConKind tc) tys +typeKind (TyConApp tc tys) = tyConAppResKind tc tys typeKind (LitTy l) = typeLiteralKind l typeKind (FunTy { ft_af = af }) = case funTyFlagResultTypeOrConstraint af of TypeLike -> liftedTypeKind ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -400,6 +400,8 @@ See also Note [Kind checking recursive type and class declarations] Note [How TcTyCons work] ~~~~~~~~~~~~~~~~~~~~~~~~ +See also Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType + TcTyCons are used for two distinct purposes 1. When recovering from a type error in a type declaration, ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -396,7 +396,7 @@ type TcTyCoVarSet = TyCoVarSet type TcDTyVarSet = DTyVarSet type TcDTyCoVarSet = DTyCoVarSet -{- Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] +{- Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon]o ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ See Note [How TcTyCons work] in GHC.Tc.TyCl @@ -425,6 +425,11 @@ Invariants: and so allows up to distinguish between the Specified and Required elements of tyConScopedTyVars. + - When zonking (which is necesary because, uniquely, MonoTcTyCons have unification + variables), we set tyConKind, but leave the binders and tyConResKind un-zonked. + See GHC.Core.TyCon.setTcTyConKind. + + * PolyTcTyCon: - Flag tcTyConIsPoly = True; this is used only to short-cut zonking View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5bf6af995037edf53457a134e951765de4a46e8b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5bf6af995037edf53457a134e951765de4a46e8b You're receiving 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 Nov 12 23:14:33 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sat, 12 Nov 2022 18:14:33 -0500 Subject: [Git][ghc/ghc][wip/T22416] Fix a trivial typo in dataConNonlinearType Message-ID: <637028d97103d_24229e527c44035e3@gitlab.mail> Simon Peyton Jones pushed to branch wip/T22416 at Glasgow Haskell Compiler / GHC Commits: 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 6 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Type.hs - + testsuite/tests/hiefile/should_compile/T22416.hs - + testsuite/tests/hiefile/should_compile/T22416.stderr - testsuite/tests/hiefile/should_compile/all.T - testsuite/tests/roles/should_compile/T8958.stderr Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -1542,14 +1542,18 @@ dataConWrapperType (MkData { dcUserTyVarBinders = user_tvbs, res_ty dataConNonlinearType :: DataCon -> Type +-- Just like dataConWrapperType, but with the +-- linearity on the arguments all zapped to Many dataConNonlinearType (MkData { dcUserTyVarBinders = user_tvbs, dcOtherTheta = theta, dcOrigArgTys = arg_tys, - dcOrigResTy = res_ty }) - = let arg_tys' = map (\(Scaled w t) -> Scaled (case w of OneTy -> ManyTy; _ -> w) t) arg_tys - in mkInvisForAllTys user_tvbs $ - mkInvisFunTys theta $ - mkScaledFunTys arg_tys' $ - res_ty + dcOrigResTy = res_ty, + dcStupidTheta = stupid_theta }) + = mkInvisForAllTys user_tvbs $ + mkInvisFunTys (stupid_theta ++ theta) $ + mkScaledFunTys arg_tys' $ + res_ty + where + arg_tys' = map (\(Scaled w t) -> Scaled (case w of OneTy -> ManyTy; _ -> w) t) arg_tys dataConDisplayType :: Bool -> DataCon -> Type dataConDisplayType show_linear_types dc ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1383,7 +1383,7 @@ splitFunTys ty = split [] ty ty split args orig_ty ty | Just ty' <- coreView ty = split args orig_ty ty' split args orig_ty _ = (reverse args, orig_ty) -funResultTy :: Type -> Type +funResultTy :: HasDebugCallStack => Type -> Type -- ^ Extract the function result type and panic if that is not possible funResultTy ty | FunTy { ft_res = res } <- coreFullView ty = res ===================================== testsuite/tests/hiefile/should_compile/T22416.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE Haskell2010 #-} +module Swish.GraphMatch where + +import qualified Data.Map as M +import Data.Word (Word32) + +class Label lb + +type LabelIndex = (Word32, Word32) + +data (Label lb, Eq lv, Show lv) => GenLabelMap lb lv = + MkLabelMap Word32 (M.Map lb lv) + +type LabelMap lb = GenLabelMap lb LabelIndex + +emptyMap :: Label lb => LabelMap lb +emptyMap = MkLabelMap 1 M.empty + +-- MkLabelMap :: forall lb lv. (Label lb, Eq lv, Show lv) +-- => Word32 -> M.Map lb lv -> GenLabelMap lb lv \ No newline at end of file ===================================== testsuite/tests/hiefile/should_compile/T22416.stderr ===================================== @@ -0,0 +1,2 @@ +Got valid scopes +Got no roundtrip errors ===================================== testsuite/tests/hiefile/should_compile/all.T ===================================== @@ -22,3 +22,4 @@ test('Scopes', normal, compile, ['-fno-code -fwrite-ide- # See https://gitlab.haskell.org/ghc/ghc/-/issues/18425 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2464#note_301989 test('ScopesBug', expect_broken(18425), compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) test('T18425', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) +test('T22416', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) ===================================== testsuite/tests/roles/should_compile/T8958.stderr ===================================== @@ -10,7 +10,9 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom T8958.N:Map :: Map k v = [(k, v)] DATA CONSTRUCTORS - MkMap :: forall k v. [(k, v)] -> Map k v + MkMap :: forall k v. + (Nominal k, Representational v) => + [(k, v)] -> Map k v CLASS INSTANCES instance [incoherent] Representational a -- Defined at T8958.hs:11:10 @@ -92,3 +94,19 @@ AbsBinds [a] [] Evidence: [EvBinds{}]} + +T8958.hs:14:54: warning: [-Wsimplifiable-class-constraints (in -Wdefault)] + • The constraint ‘Representational v’ matches + instance Representational a -- Defined at T8958.hs:11:10 + This makes type inference for inner bindings fragile; + either use MonoLocalBinds, or simplify it using the instance + • In the definition of data constructor ‘MkMap’ + In the newtype declaration for ‘Map’ + +T8958.hs:14:54: warning: [-Wsimplifiable-class-constraints (in -Wdefault)] + • The constraint ‘Nominal k’ matches + instance Nominal a -- Defined at T8958.hs:8:10 + This makes type inference for inner bindings fragile; + either use MonoLocalBinds, or simplify it using the instance + • In the definition of data constructor ‘MkMap’ + In the newtype declaration for ‘Map’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/294f907370fadd3313f8c5e6aa87a93c8b86f139 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/294f907370fadd3313f8c5e6aa87a93c8b86f139 You're receiving 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 Nov 13 19:31:14 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Sun, 13 Nov 2022 14:31:14 -0500 Subject: [Git][ghc/ghc][wip/p547] Drop support for kind constraints. Message-ID: <6371460260c3_24229e2763c154455811@gitlab.mail> Simon Peyton Jones pushed to branch wip/p547 at Glasgow Haskell Compiler / GHC Commits: 0c12ceb4 by Richard Eisenberg at 2022-11-13T19:30:49+00:00 Drop support for kind constraints. This implements GHC proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. - - - - - 18 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/TyCo/Rep.hs - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs - compiler/GHC/CoreToIface.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Rename/HsType.hs - compiler/GHC/Rename/Module.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/HsType.hs - compiler/GHC/Tc/Solver/Rewrite.hs - compiler/GHC/Tc/TyCl.hs - compiler/GHC/Tc/Utils/Instantiate.hs - compiler/GHC/Tc/Utils/TcType.hs - compiler/GHC/Tc/Validity.hs - compiler/GHC/Types/Var.hs - docs/users_guide/exts/data_kinds.rst Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -614,7 +614,7 @@ A DataCon has two different sets of type variables: (that is, they are TyVars/TyCoVars instead of ForAllTyBinders). Often (dcUnivTyVars ++ dcExTyCoVars) = dcUserTyVarBinders; but they may differ -for three reasons, coming next: +for two reasons, coming next: --- Reason (R1): Order of quantification in GADT syntax --- @@ -703,55 +703,6 @@ Putting this all together, all variables used on the left-hand side of an equation in the dcEqSpec will be in dcUnivTyVars but *not* in dcUserTyVarBinders. ---- Reason (R3): Kind equalities may have been solved --- - -Consider now this case: - - type family F a where - F Type = False - F _ = True - type T :: forall k. (F k ~ True) => k -> k -> Type - data T a b where - MkT :: T Maybe List - -The constraint F k ~ True tells us that T does not want to be indexed by, say, -Int. Now let's consider the Core types involved: - - axiom for F: axF[0] :: F Type ~ False - axF[1] :: forall a. F a ~ True (a must be apart from Type) - tycon: T :: forall k. (F k ~ True) -> k -> k -> Type - wrapper: MkT :: T @(Type -> Type) @(Eq# (axF[1] (Type -> Type)) Maybe List - worker: MkT :: forall k (c :: F k ~ True) (a :: k) (b :: k). - (k ~# (Type -> Type), a ~# Maybe, b ~# List) => - T @k @c a b - -The key observation here is that the worker quantifies over c, while the wrapper -does not. The worker *must* quantify over c, because c is a universal variable, -and the result of the worker must be the type constructor applied to a sequence -of plain type variables. But the wrapper certainly does not need to quantify over -any evidence that F (Type -> Type) ~ True, as no variables are needed there. - -(Aside: the c here is a regular type variable, *not* a coercion variable. This -is because F k ~ True is a *lifted* equality, not the unlifted ~#. This is why -we see Eq# in the type of the wrapper: Eq# boxes the unlifted ~# to become a -lifted ~. See also Note [The equality types story] in GHC.Builtin.Types.Prim about -Eq# and Note [Constraints in kinds] in GHC.Core.TyCo.Rep about having this constraint -in the first place.) - -In this case, we'll have these fields of the DataCon: - - dcUserTyVarBinders = [] -- the wrapper quantifies over nothing - dcUnivTyVars = [k, c, a, b] - dcExTyCoVars = [] -- no existentials here, but a different constructor might have - dcEqSpec = [k ~# (Type -> Type), a ~# Maybe, b ~# List] - -Note that c is in the dcUserTyVars, but mentioned neither in the dcUserTyVarBinders nor -in the dcEqSpec. We thus have Reason (R3): a variable might be missing from the -dcUserTyVarBinders if its type's kind is Constraint. - -(At one point, we thought that the dcEqSpec would have to be non-empty. But that -wouldn't account for silly cases like type T :: (True ~ True) => Type.) - --- End of Reasons --- INVARIANT(dataConTyVars): the set of tyvars in dcUserTyVarBinders @@ -1213,11 +1164,9 @@ mkDataCon name declared_infix prom_info -- fresh_names: make sure that the "anonymous" tyvars don't -- clash in name or unique with the universal/existential ones. -- Tiresome! And unnecessary because these tyvars are never looked at - prom_theta_bndrs = [ mkInvisAnonTyConBinder (mkTyVar n t) - {- Invisible -} | (n,t) <- fresh_names `zip` theta ] prom_arg_bndrs = [ mkAnonTyConBinder (mkTyVar n t) {- Visible -} | (n,t) <- dropList theta fresh_names `zip` map scaledThing orig_arg_tys ] - prom_bndrs = prom_tv_bndrs ++ prom_theta_bndrs ++ prom_arg_bndrs + prom_bndrs = prom_tv_bndrs ++ prom_arg_bndrs prom_res_kind = orig_res_ty promoted = mkPromotedDataCon con name prom_info prom_bndrs prom_res_kind roles rep_info @@ -1840,20 +1789,15 @@ checkDataConTyVars dc@(MkData { dcUnivTyVars = univ_tvs , dcExTyCoVars = ex_tvs , dcEqSpec = eq_spec }) -- use of sets here: (R1) from the Note - = mkUnVarSet depleted_worker_vars == mkUnVarSet depleted_wrapper_vars && + = mkUnVarSet depleted_worker_vars == mkUnVarSet wrapper_vars && all (not . is_eq_spec_var) wrapper_vars where - is_constraint_var v = typeTypeOrConstraint (tyVarKind v) == ConstraintLike - -- implements (R3) from the Note - worker_vars = univ_tvs ++ ex_tvs eq_spec_tvs = mkUnVarSet (map eqSpecTyVar eq_spec) is_eq_spec_var = (`elemUnVarSet` eq_spec_tvs) -- (R2) from the Note - depleted_worker_vars = filterOut (is_eq_spec_var <||> is_constraint_var) - worker_vars + depleted_worker_vars = filterOut is_eq_spec_var worker_vars wrapper_vars = dataConUserTyVars dc - depleted_wrapper_vars = filterOut is_constraint_var wrapper_vars dataConUserTyVarsNeedWrapper :: DataCon -> Bool -- Check whether the worker and wapper have the same type variables ===================================== compiler/GHC/Core/TyCo/Rep.hs ===================================== @@ -325,113 +325,6 @@ Because the tyvar form above includes r in its result, we must be careful not to let any variables escape -- thus the last premise of the rule above. -Note [Constraints in kinds] -~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Do we allow a type constructor to have a kind like - S :: Eq a => a -> Type - -No, we do not. Doing so would mean would need a TyConApp like - S @k @(d :: Eq k) (ty :: k) - and we have no way to build, or decompose, evidence like - (d :: Eq k) at the type level. - -But we admit one exception: equality. We /do/ allow, say, - MkT :: (a ~ b) => a -> b -> Type a b - -Why? Because we can, without much difficulty. Moreover -we can promote a GADT data constructor (see TyCon -Note [Promoted data constructors]), like - data GT a b where - MkGT : a -> a -> GT a a -so programmers might reasonably expect to be able to -promote MkT as well. - -How does this work? - -* In GHC.Tc.Validity.checkConstraintsOK we reject kinds that - have constraints other than (a~b) and (a~~b). - -* In Inst.tcInstInvisibleTyBinder we instantiate a call - of MkT by emitting - [W] co :: alpha ~# beta - and producing the elaborated term - MkT @alpha @beta (Eq# alpha beta co) - We don't generate a boxed "Wanted"; we generate only a - regular old /unboxed/ primitive-equality Wanted, and build - the box on the spot. - -* How can we get such a MkT? By promoting a GADT-style data - constructor, written with an explicit equality constraint. - data T a b where - MkT :: (a~b) => a -> b -> T a b - See DataCon.mkPromotedDataCon - and Note [Promoted data constructors] in GHC.Core.TyCon - -* We support both homogeneous (~) and heterogeneous (~~) - equality. (See Note [The equality types story] - in GHC.Builtin.Types.Prim for a primer on these equality types.) - -* How do we prevent a MkT having an illegal constraint like - Eq a? We check for this at use-sites; see GHC.Tc.Gen.HsType.tcTyVar, - specifically dc_theta_illegal_constraint. - -* Notice that nothing special happens if - K :: (a ~# b) => blah - because (a ~# b) is not a predicate type, and is never - implicitly instantiated. (Mind you, it's not clear how you - could creates a type constructor with such a kind.) See - Note [Types for coercions, predicates, and evidence] - -* The existence of promoted MkT with an equality-constraint - argument is the (only) reason that the AnonTCB constructor - of TyConBndrVis carries an FunTyFlag. - For example, when we promote the data constructor - MkT :: forall a b. (a~b) => a -> b -> T a b - we get a PromotedDataCon with tyConBinders - Bndr (a :: Type) (NamedTCB Inferred) - Bndr (b :: Type) (NamedTCB Inferred) - Bndr (_ :: a ~ b) (AnonTCB FTF_C_T) - Bndr (_ :: a) (AnonTCB FTF_T_T)) - Bndr (_ :: b) (AnonTCB FTF_T_T)) - -* One might reasonably wonder who *unpacks* these boxes once they are - made. After all, there is no type-level `case` construct. The - surprising answer is that no one ever does. Instead, if a GADT - constructor is used on the left-hand side of a type family equation, - that occurrence forces GHC to unify the types in question. For - example: - - data G a where - MkG :: G Bool - - type family F (x :: G a) :: a where - F MkG = False - - When checking the LHS `F MkG`, GHC sees the MkG constructor and then must - unify F's implicit parameter `a` with Bool. This succeeds, making the equation - - F Bool (MkG @Bool ) = False - - Note that we never need unpack the coercion. This is because type - family equations are *not* parametric in their kind variables. That - is, we could have just said - - type family H (x :: G a) :: a where - H _ = False - - The presence of False on the RHS also forces `a` to become Bool, - giving us - - H Bool _ = False - - The fact that any of this works stems from the lack of phase - separation between types and kinds (unlike the very present phase - separation between terms and types). - - Once we have the ability to pattern-match on types below top-level, - this will no longer cut it, but it seems fine for now. - - Note [Arguments to type constructors] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Because of kind polymorphism, in addition to type application we now ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -20,10 +20,10 @@ module GHC.Core.TyCon( PromDataConInfo(..), TyConFlavour(..), -- * TyConBinder - TyConBinder, TyConBndrVis(..), TyConPiTyBinder, + TyConBinder, TyConBndrVis(..), mkNamedTyConBinder, mkNamedTyConBinders, mkRequiredTyConBinder, - mkAnonTyConBinder, mkAnonTyConBinders, mkInvisAnonTyConBinder, + mkAnonTyConBinder, mkAnonTyConBinders, tyConBinderForAllTyFlag, tyConBndrVisForAllTyFlag, isNamedTyConBinder, isVisibleTyConBinder, isInvisibleTyConBinder, isVisibleTcbVis, @@ -440,38 +440,29 @@ See #19367. ************************************************************************ * * - TyConBinder, TyConPiTyBinder + TyConBinder * * ************************************************************************ -} type TyConBinder = VarBndr TyVar TyConBndrVis -type TyConPiTyBinder = VarBndr TyCoVar TyConBndrVis - -- Only PromotedDataCon has TyConPiTyBinders - -- See Note [Promoted GADT data constructors] data TyConBndrVis - = NamedTCB ForAllTyFlag - | AnonTCB FunTyFlag + = NamedTCB ForAllTyFlag -- ^ A named, forall-bound variable (invisible or not) + | AnonTCB -- ^ an ordinary, visible type argument instance Outputable TyConBndrVis where ppr (NamedTCB flag) = ppr flag - ppr (AnonTCB af) = ppr af + ppr AnonTCB = text "AnonTCB" mkAnonTyConBinder :: TyVar -> TyConBinder -- Make a visible anonymous TyCon binder mkAnonTyConBinder tv = assert (isTyVar tv) $ - Bndr tv (AnonTCB visArgTypeLike) + Bndr tv AnonTCB mkAnonTyConBinders :: [TyVar] -> [TyConBinder] mkAnonTyConBinders tvs = map mkAnonTyConBinder tvs -mkInvisAnonTyConBinder :: TyVar -> TyConBinder --- Make an /invisible/ anonymous TyCon binder --- Not used much -mkInvisAnonTyConBinder tv = assert (isTyVar tv) $ - Bndr tv (AnonTCB invisArgTypeLike) - mkNamedTyConBinder :: ForAllTyFlag -> TyVar -> TyConBinder -- The odd argument order supports currying mkNamedTyConBinder vis tv = assert (isTyVar tv) $ @@ -494,10 +485,8 @@ tyConBinderForAllTyFlag :: TyConBinder -> ForAllTyFlag tyConBinderForAllTyFlag (Bndr _ vis) = tyConBndrVisForAllTyFlag vis tyConBndrVisForAllTyFlag :: TyConBndrVis -> ForAllTyFlag -tyConBndrVisForAllTyFlag (NamedTCB vis) = vis -tyConBndrVisForAllTyFlag (AnonTCB af) -- See Note [AnonTCB with constraint arg] - | isVisibleFunArg af = Required - | otherwise = Inferred +tyConBndrVisForAllTyFlag (NamedTCB vis) = vis +tyConBndrVisForAllTyFlag AnonTCB = Required isNamedTyConBinder :: TyConBinder -> Bool -- Identifies kind variables @@ -512,7 +501,7 @@ isVisibleTyConBinder (Bndr _ tcb_vis) = isVisibleTcbVis tcb_vis isVisibleTcbVis :: TyConBndrVis -> Bool isVisibleTcbVis (NamedTCB vis) = isVisibleForAllTyFlag vis -isVisibleTcbVis (AnonTCB af) = isVisibleFunArg af +isVisibleTcbVis AnonTCB = True isInvisibleTyConBinder :: VarBndr tv TyConBndrVis -> Bool -- Works for IfaceTyConBinder too @@ -525,7 +514,7 @@ mkTyConKind bndrs res_kind = foldr mk res_kind bndrs where mk :: TyConBinder -> Kind -> Kind mk (Bndr tv (NamedTCB vis)) k = mkForAllTy (Bndr tv vis) k - mk (Bndr tv (AnonTCB af)) k = mkNakedKindFunTy af (varType tv) k + mk (Bndr tv AnonTCB) k = mkNakedKindFunTy FTF_T_T (varType tv) k -- mkNakedKindFunTy: see Note [Naked FunTy] in GHC.Builtin.Types -- | (mkTyConTy tc) returns (TyConApp tc []) @@ -544,9 +533,7 @@ tyConInvisTVBinders tc_bndrs mk_binder (Bndr tv tc_vis) = mkTyVarBinder vis tv where vis = case tc_vis of - AnonTCB af -- Note [AnonTCB with constraint arg] - | isInvisibleFunArg af -> InferredSpec - | otherwise -> SpecifiedSpec + AnonTCB -> SpecifiedSpec NamedTCB Required -> SpecifiedSpec NamedTCB (Invisible vis) -> vis @@ -556,35 +543,7 @@ tyConVisibleTyVars tc = [ tv | Bndr tv vis <- tyConBinders tc , isVisibleTcbVis vis ] -{- Note [AnonTCB with constraint arg] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It's pretty rare to have an (AnonTCB af) binder with af=FTF_C_T or FTF_C_C. -The only way it can occur is through equality constraints in kinds. These -can arise in one of two ways: - -* In a PromotedDataCon whose kind has an equality constraint: - - 'MkT :: forall a b. (a~b) => blah - - See Note [Constraints in kinds] in GHC.Core.TyCo.Rep, and - Note [Promoted data constructors] in this module. - -* In a data type whose kind has an equality constraint, as in the - following example from #12102: - - data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type - -When mapping an (AnonTCB FTF_C_x) to an ForAllTyFlag, in -tyConBndrVisForAllTyFlag, we use "Inferred" to mean "the user cannot -specify this arguments, even with visible type/kind application; -instead the type checker must fill it in. - -We map (AnonTCB FTF_T_x) to Required, of course: the user must -provide it. It would be utterly wrong to do this for constraint -arguments, which is why AnonTCB must have the FunTyFlag in -the first place. - -Note [Building TyVarBinders from TyConBinders] +{- Note [Building TyVarBinders from TyConBinders] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We sometimes need to build the quantified type of a value from the TyConBinders of a type or class. For that we need not @@ -640,7 +599,7 @@ in GHC.Core.TyCo.Rep), so we change it to Specified when making MkT's PiTyBinder {- Note [The binders/kind/arity fields of a TyCon] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All TyCons have this group of fields - tyConBinders :: [TyConBinder/TyConPiTyBinder] + tyConBinders :: [TyConBinder] tyConResKind :: Kind tyConTyVars :: [TyVar] -- Cached = binderVars tyConBinders -- NB: Currently (Aug 2018), TyCons that own this @@ -651,7 +610,7 @@ All TyCons have this group of fields They fit together like so: -* tyConBinders gives the telescope of type/coercion variables on the LHS of the +* tyConBinders gives the telescope of type variables on the LHS of the type declaration. For example: type App a (b :: k) = a b @@ -668,7 +627,7 @@ They fit together like so: * See Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility] in GHC.Core.TyCo.Rep for what the visibility flag means. -* Each TyConBinder tyConBinders has a TyVar (sometimes it is TyCoVar), and +* Each TyConBinder in tyConBinders has a TyVar, and that TyVar may scope over some other part of the TyCon's definition. Eg type T a = a -> a we have @@ -740,12 +699,12 @@ instance OutputableBndr tv => Outputable (VarBndr tv TyConBndrVis) where ppr (Bndr v bi) = ppr bi <+> parens (pprBndr LetBind v) instance Binary TyConBndrVis where - put_ bh (AnonTCB af) = do { putByte bh 0; put_ bh af } + put_ bh AnonTCB = do { putByte bh 0 } put_ bh (NamedTCB vis) = do { putByte bh 1; put_ bh vis } get bh = do { h <- getByte bh ; case h of - 0 -> do { af <- get bh; return (AnonTCB af) } + 0 -> return AnonTCB _ -> do { vis <- get bh; return (NamedTCB vis) } } @@ -951,13 +910,15 @@ data TyCon = } -- | Represents promoted data constructor. + -- The kind of a promoted data constructor is the *wrapper* type of + -- the original data constructor. This type must not have constraints + -- (as checked in GHC.Tc.Gen.HsType.tcTyVar). | PromotedDataCon { -- See Note [Promoted data constructors] tyConUnique :: !Unique, -- ^ Same Unique as the data constructor tyConName :: Name, -- ^ Same Name as the data constructor -- See Note [The binders/kind/arity fields of a TyCon] - tyConBinders :: [TyConPiTyBinder], -- ^ Full binders - -- TyConPiTyBinder: see Note [Promoted GADT data constructors] + tyConBinders :: [TyConBinder], -- ^ Full binders tyConResKind :: Kind, -- ^ Result kind tyConKind :: Kind, -- ^ Kind of this TyCon tyConArity :: Arity, -- ^ Arity @@ -1017,17 +978,6 @@ where tcTyConScopedTyVars are used only for MonoTcTyCons, not PolyTcTyCons. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon] in GHC.Tc.Utils.TcType. -Note [Promoted GADT data constructors] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Any promoted GADT data constructor will have a type with equality -constraints in its type; e.g. - K :: forall a b. (a ~# [b]) => a -> b -> T a - -So, when promoted to become a type constructor, the tyConBinders -will include CoVars. That is why we use [TyConPiTyBinder] for the -tyconBinders field. TyConPiTyBinder is a synonym for TyConBinder, -but with the clue that the binder can be a CoVar not just a TyVar. - Note [Representation-polymorphic TyCons] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To check for representation-polymorphism directly in the typechecker, @@ -2044,7 +1994,7 @@ mkFamilyTyCon name binders res_kind resVar flav parent inj -- as the data constructor itself; when we pretty-print -- the TyCon we add a quote; see the Outputable TyCon instance mkPromotedDataCon :: DataCon -> Name -> TyConRepName - -> [TyConPiTyBinder] -> Kind -> [Role] + -> [TyConBinder] -> Kind -> [Role] -> PromDataConInfo -> TyCon mkPromotedDataCon con name rep_name binders res_kind roles rep_info = let tc = ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1731,7 +1731,7 @@ tyConBindersPiTyBinders :: [TyConBinder] -> [PiTyBinder] tyConBindersPiTyBinders = map to_tyb where to_tyb (Bndr tv (NamedTCB vis)) = Named (Bndr tv vis) - to_tyb (Bndr tv (AnonTCB af)) = Anon (tymult (varType tv)) af + to_tyb (Bndr tv AnonTCB) = Anon (tymult (varType tv)) FTF_T_T -- | Make a dependent forall over an 'Inferred' variable mkTyCoInvForAllTy :: TyCoVar -> Type -> Type @@ -1793,7 +1793,7 @@ mkTyConBindersPreferAnon vars inner_tkvs = assert (all isTyVar vars) = ( Bndr v (NamedTCB Required) : binders , fvs `delVarSet` v `unionVarSet` kind_vars ) | otherwise - = ( Bndr v (AnonTCB visArgTypeLike) : binders + = ( Bndr v AnonTCB : binders , fvs `unionVarSet` kind_vars ) where (binders, fvs) = go vs @@ -2484,9 +2484,8 @@ Here are the key kinding rules for types -- in GHC.Builtin.Types.Prim torc is TYPE or CONSTRAINT - ty : body_torc rep - bndr_torc is Type or Constraint - ki : bndr_torc + ty : torc rep + ki : Type `a` is a type variable `a` is not free in rep (FORALL1) ----------------------- @@ -2504,10 +2503,6 @@ Here are the key kinding rules for types Note that: * (FORALL1) rejects (forall (a::Maybe). blah) -* (FORALL1) accepts (forall (a :: t1~t2) blah), where the type variable - (not coercion variable!) 'a' has a kind (t1~t2) that in turn has kind - Constraint. See Note [Constraints in kinds] in GHC.Core.TyCo.Rep. - * (FORALL2) Surprise 1: See GHC.Core.TyCo.Rep Note [Unused coercion variable in ForAllTy] @@ -2805,8 +2800,7 @@ tyConAppNeedsKindSig spec_inj_pos tc n_args injective_vars_of_binder :: TyConBinder -> FV injective_vars_of_binder (Bndr tv vis) = case vis of - AnonTCB af | isVisibleFunArg af - -> injectiveVarsOfType False -- conservative choice + AnonTCB -> injectiveVarsOfType False -- conservative choice (varType tv) NamedTCB argf | source_of_injectivity argf -> unitFV tv `unionFV` ===================================== compiler/GHC/CoreToIface.hs ===================================== @@ -81,6 +81,7 @@ import GHC.Types.Cpr ( topCprSig ) import GHC.Utils.Outputable import GHC.Utils.Panic +import GHC.Utils.Panic.Plain import GHC.Utils.Misc import Data.Maybe ( isNothing, catMaybes ) @@ -353,12 +354,8 @@ toIfaceAppArgsX fr kind ty_args ts' = go (extendTCvSubst env tv t) res ts go env (FunTy { ft_af = af, ft_res = res }) (t:ts) - = IA_Arg (toIfaceTypeX fr t) argf (go env res ts) - where - argf | isVisibleFunArg af = Required - | otherwise = Inferred - -- It's rare for a kind to have a constraint argument, but it - -- can happen. See Note [AnonTCB with constraint arg] in GHC.Core.TyCon. + = assert (isVisibleFunArg af) + IA_Arg (toIfaceTypeX fr t) Required (go env res ts) go env ty ts@(t1:ts1) | not (isEmptyTCvSubst env) ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -205,7 +205,7 @@ mkIfaceTyConKind :: [IfaceTyConBinder] -> IfaceKind -> IfaceKind mkIfaceTyConKind bndrs res_kind = foldr mk res_kind bndrs where mk :: IfaceTyConBinder -> IfaceKind -> IfaceKind - mk (Bndr tv (AnonTCB af)) k = IfaceFunTy af many_ty (ifaceBndrType tv) k + mk (Bndr tv AnonTCB) k = IfaceFunTy FTF_T_T many_ty (ifaceBndrType tv) k mk (Bndr tv (NamedTCB vis)) k = IfaceForAllTy (Bndr tv vis) k ifaceForAllSpecToBndrs :: [IfaceForAllSpecBndr] -> [IfaceForAllBndr] @@ -890,12 +890,7 @@ pprIfaceTyConBinders suppress_sig = sep . map go go (Bndr (IfaceTvBndr bndr) vis) = -- See Note [Pretty-printing invisible arguments] case vis of - AnonTCB af - | isVisibleFunArg af -> ppr_bndr (UseBndrParens True) - | otherwise -> char '@' <> braces (ppr_bndr (UseBndrParens False)) - -- The above case is rare. (See Note [AnonTCB with constraint arg] - -- in GHC.Core.TyCon.) - -- Should we print these differently? + AnonTCB -> ppr_bndr (UseBndrParens True) NamedTCB Required -> ppr_bndr (UseBndrParens True) NamedTCB Specified -> char '@' <> ppr_bndr (UseBndrParens True) NamedTCB Inferred -> char '@' <> braces (ppr_bndr (UseBndrParens False)) ===================================== compiler/GHC/Rename/HsType.hs ===================================== @@ -13,7 +13,7 @@ module GHC.Rename.HsType ( -- Type related stuff rnHsType, rnLHsType, rnLHsTypes, rnContext, rnMaybeContext, - rnHsKind, rnLHsKind, rnLHsTypeArgs, + rnLHsKind, rnLHsTypeArgs, rnHsSigType, rnHsWcType, rnHsPatSigTypeBindingVars, HsPatSigTypeScoping(..), rnHsSigWcType, rnHsPatSigType, newTyVarNameRn, @@ -468,35 +468,6 @@ rnImplicitTvBndrs ctx mb_assoc implicit_vs_with_dups thing_inside {- rnHsType is here because we call it from loadInstDecl, and I didn't want a gratuitous knot. - -Note [HsQualTy in kinds] -~~~~~~~~~~~~~~~~~~~~~~ -I was wondering whether HsQualTy could occur only at TypeLevel. But no, -we can have a qualified type in a kind too. Here is an example: - - type family F a where - F Bool = Nat - F Nat = Type - - type family G a where - G Type = Type -> Type - G () = Nat - - data X :: forall k1 k2. (F k1 ~ G k2) => k1 -> k2 -> Type where - MkX :: X 'True '() - -See that k1 becomes Bool and k2 becomes (), so the equality is -satisfied. If I write MkX :: X 'True 'False, compilation fails with a -suitable message: - - MkX :: X 'True '() - • Couldn't match kind ‘G Bool’ with ‘Nat’ - Expected kind: G Bool - Actual kind: F Bool - -However: in a kind, the constraints in the HsQualTy must all be -equalities; or at least, any kinds with a class constraint are -uninhabited. See Note [Constraints in kinds] in GHC.Core.TyCo.Rep. -} data RnTyKiEnv @@ -552,9 +523,6 @@ rnHsType ctxt ty = rnHsTyKi (mkTyKiEnv ctxt TypeLevel RnTypeBody) ty rnLHsKind :: HsDocContext -> LHsKind GhcPs -> RnM (LHsKind GhcRn, FreeVars) rnLHsKind ctxt kind = rnLHsTyKi (mkTyKiEnv ctxt KindLevel RnTypeBody) kind -rnHsKind :: HsDocContext -> HsKind GhcPs -> RnM (HsKind GhcRn, FreeVars) -rnHsKind ctxt kind = rnHsTyKi (mkTyKiEnv ctxt KindLevel RnTypeBody) kind - -- renaming a type only, not a kind rnLHsTypeArg :: HsDocContext -> LHsTypeArg GhcPs -> RnM (LHsTypeArg GhcRn, FreeVars) @@ -610,11 +578,11 @@ rnHsTyKi env ty@(HsForAllTy { hst_tele = tele, hst_body = tau }) , hst_tele = tele' , hst_body = tau' } , fvs) } } -rnHsTyKi env ty@(HsQualTy { hst_ctxt = lctxt, hst_body = tau }) - = do { data_kinds <- xoptM LangExt.DataKinds -- See Note [HsQualTy in kinds] - ; when (not data_kinds && isRnKindLevel env) - (addErr (dataKindsErr env ty)) - ; (ctxt', fvs1) <- rnTyKiContext env lctxt +rnHsTyKi env (HsQualTy { hst_ctxt = lctxt, hst_body = tau }) + = do { -- no need to check type vs kind level here; this is + -- checked in the type checker. See + -- Note [No constraints in kinds] in GHC.Tc.Validity + (ctxt', fvs1) <- rnTyKiContext env lctxt ; (tau', fvs2) <- rnLHsTyKi env tau ; return (HsQualTy { hst_xqual = noExtField, hst_ctxt = ctxt' , hst_body = tau' } ===================================== compiler/GHC/Rename/Module.hs ===================================== @@ -2066,14 +2066,7 @@ preceded by `type`, with the following restrictions: (R3) There are no strictness flags, because they don't make sense at the type level. -(R4) The types of the constructors contain no constraints other than - equality constraints. (This is the same restriction imposed - on constructors to be promoted with the DataKinds extension in - dc_theta_illegal_constraint called from GHC.Tc.Gen.HsType.tcTyVar, - but in that case the restriction is imposed if and when a data - constructor is used in a type, whereas here it is imposed at - the point of definition. See also Note [Constraints in kinds] - in GHC.Core.TyCo.Rep.) +(R4) The types of the constructors contain no constraints. (R5) There are no deriving clauses. ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -913,9 +913,7 @@ instance Diagnostic TcRnMessage where 2 (parens reason)) where reason = case err of - ConstrainedDataConPE pred - -> text "it has an unpromotable context" - <+> quotes (ppr pred) + ConstrainedDataConPE -> text "it has a context" FamDataConPE -> text "it comes from a data family instance" NoDataKindsDC -> text "perhaps you intended to use DataKinds" PatSynPE -> text "pattern synonyms cannot be promoted" ===================================== compiler/GHC/Tc/Errors/Types.hs ===================================== @@ -3724,9 +3724,7 @@ data PromotionErr | FamDataConPE -- Data constructor for a data family -- See Note [AFamDataCon: not promoting data family constructors] -- in GHC.Tc.Utils.Env. - | ConstrainedDataConPE PredType - -- Data constructor with a non-equality context - -- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep + | ConstrainedDataConPE -- Data constructor with a context | PatSynPE -- Pattern synonyms -- See Note [Don't promote pattern synonyms] in GHC.Tc.Utils.Env @@ -3736,28 +3734,27 @@ data PromotionErr | NoDataKindsDC -- -XDataKinds not enabled (for a datacon) instance Outputable PromotionErr where - ppr ClassPE = text "ClassPE" - ppr TyConPE = text "TyConPE" - ppr PatSynPE = text "PatSynPE" - ppr FamDataConPE = text "FamDataConPE" - ppr (ConstrainedDataConPE pred) = text "ConstrainedDataConPE" - <+> parens (ppr pred) - ppr RecDataConPE = text "RecDataConPE" - ppr NoDataKindsDC = text "NoDataKindsDC" - ppr TermVariablePE = text "TermVariablePE" + ppr ClassPE = text "ClassPE" + ppr TyConPE = text "TyConPE" + ppr PatSynPE = text "PatSynPE" + ppr FamDataConPE = text "FamDataConPE" + ppr ConstrainedDataConPE = text "ConstrainedDataConPE" + ppr RecDataConPE = text "RecDataConPE" + ppr NoDataKindsDC = text "NoDataKindsDC" + ppr TermVariablePE = text "TermVariablePE" pprPECategory :: PromotionErr -> SDoc pprPECategory = text . capitalise . peCategory peCategory :: PromotionErr -> String -peCategory ClassPE = "class" -peCategory TyConPE = "type constructor" -peCategory PatSynPE = "pattern synonym" -peCategory FamDataConPE = "data constructor" -peCategory ConstrainedDataConPE{} = "data constructor" -peCategory RecDataConPE = "data constructor" -peCategory NoDataKindsDC = "data constructor" -peCategory TermVariablePE = "term variable" +peCategory ClassPE = "class" +peCategory TyConPE = "type constructor" +peCategory PatSynPE = "pattern synonym" +peCategory FamDataConPE = "data constructor" +peCategory ConstrainedDataConPE = "data constructor" +peCategory RecDataConPE = "data constructor" +peCategory NoDataKindsDC = "data constructor" +peCategory TermVariablePE = "term variable" -- | Stores the information to be reported in a representation-polymorphism -- error message. ===================================== compiler/GHC/Tc/Gen/HsType.hs ===================================== @@ -137,7 +137,7 @@ import GHC.Data.Bag( unitBag ) import Data.Function ( on ) import Data.List.NonEmpty ( NonEmpty(..), nonEmpty ) import qualified Data.List.NonEmpty as NE -import Data.List ( find, mapAccumL ) +import Data.List ( mapAccumL ) import Control.Monad import Data.Tuple( swap ) @@ -1613,8 +1613,7 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args case ki_binder of -- FunTy with PredTy on LHS, or ForAllTy with Inferred - Named (Bndr _ Inferred) -> instantiate ki_binder inner_ki - Anon _ af | isInvisibleFunArg af -> instantiate ki_binder inner_ki + Named (Bndr kv Inferred) -> instantiate kv inner_ki Named (Bndr _ Specified) -> -- Visible kind application do { traceTc "tcInferTyApps (vis kind app)" @@ -1644,9 +1643,9 @@ tcInferTyApps_nosat mode orig_hs_ty fun orig_hs_args ---------------- HsValArg: a normal argument (fun ty) (HsValArg arg : args, Just (ki_binder, inner_ki)) -- next binder is invisible; need to instantiate it - | isInvisiblePiTyBinder ki_binder -- FunTy with constraint on LHS; - -- or ForAllTy with Inferred or Specified - -> instantiate ki_binder inner_ki + | Named (Bndr kv flag) <- ki_binder + , isInvisibleForAllTyFlag flag -- ForAllTy with Inferred or Specified + -> instantiate kv inner_ki -- "normal" case | otherwise @@ -1984,23 +1983,16 @@ tcTyVar name -- Could be a tyvar, a tycon, or a datacon -- see #15245 promotionErr name FamDataConPE ; let (_, _, _, theta, _, _) = dataConFullSig dc - ; traceTc "tcTyVar" (ppr dc <+> ppr theta $$ ppr (dc_theta_illegal_constraint theta)) - ; case dc_theta_illegal_constraint theta of - Just pred -> promotionErr name $ - ConstrainedDataConPE pred - Nothing -> pure () + ; traceTc "tcTyVar" (ppr dc <+> ppr theta) + -- promotionErr: Note [No constraints in kinds] in GHC.Tc.Validity + ; unless (null theta) $ + promotionErr name ConstrainedDataConPE ; let tc = promoteDataCon dc ; return (mkTyConApp tc [], tyConKind tc) } APromotionErr err -> promotionErr name err _ -> wrongThingErr "type" thing name } - where - -- We cannot promote a data constructor with a context that contains - -- constraints other than equalities, so error if we find one. - -- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep - dc_theta_illegal_constraint :: ThetaType -> Maybe PredType - dc_theta_illegal_constraint = find (not . isEqPred) {- Note [Recursion through the kinds] @@ -3715,9 +3707,10 @@ splitTyConKind skol_info in_scope avoid_occs kind Nothing -> (reverse acc, substTy subst kind) Just (Anon arg af, kind') - -> go occs' uniqs' subst' (tcb : acc) kind' + -> assert (af == FTF_T_T) $ + go occs' uniqs' subst' (tcb : acc) kind' where - tcb = Bndr tv (AnonTCB af) + tcb = Bndr tv AnonTCB arg' = substTy subst (scaledThing arg) name = mkInternalName uniq occ loc tv = mkTcTyVar name arg' details @@ -3858,7 +3851,8 @@ tcbVisibilities tc orig_args go fun_kind subst all_args@(arg : args) | Just (tcb, inner_kind) <- splitPiTy_maybe fun_kind = case tcb of - Anon _ af -> AnonTCB af : go inner_kind subst args + Anon _ af -> assert (af == FTF_T_T) $ + AnonTCB : go inner_kind subst args Named (Bndr tv vis) -> NamedTCB vis : go inner_kind subst' args where subst' = extendTCvSubst subst tv arg ===================================== compiler/GHC/Tc/Solver/Rewrite.hs ===================================== @@ -1079,7 +1079,7 @@ ty_con_binders_ty_binders' = foldr go ([], False) where go (Bndr tv (NamedTCB vis)) (bndrs, _) = (Named (Bndr tv vis) : bndrs, True) - go (Bndr tv (AnonTCB af)) (bndrs, n) - = (Anon (tymult (tyVarKind tv)) af : bndrs, n) + go (Bndr tv AnonTCB) (bndrs, n) + = (Anon (tymult (tyVarKind tv)) FTF_T_T : bndrs, n) {-# INLINE go #-} {-# INLINE ty_con_binders_ty_binders' #-} ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -4069,8 +4069,7 @@ mkGADTVars tmpl_tvs dc_tvs subst tv_kind = tyVarKind t_tv tv_kind' = substTy t_sub tv_kind t_tv' = setTyVarKind t_tv tv_kind' - eqs' | isConstraintLikeKind (typeKind tv_kind') = eqs - | otherwise = (t_tv', r_ty) : eqs + eqs' = (t_tv', r_ty) : eqs | otherwise = pprPanic "mkGADTVars" (ppr tmpl_tvs $$ ppr subst) ===================================== compiler/GHC/Tc/Utils/Instantiate.hs ===================================== @@ -44,7 +44,7 @@ import GHC.Prelude import GHC.Driver.Session import GHC.Driver.Env -import GHC.Builtin.Types ( heqDataCon, eqDataCon, integerTyConName ) +import GHC.Builtin.Types ( heqDataCon, integerTyConName ) import GHC.Builtin.Names import GHC.Hs @@ -54,14 +54,12 @@ import GHC.Core.InstEnv import GHC.Core.Predicate import GHC.Core ( Expr(..), isOrphan ) -- For the Coercion constructor import GHC.Core.Type -import GHC.Core.Multiplicity -import GHC.Core.TyCo.Rep import GHC.Core.TyCo.Ppr ( debugPprType ) import GHC.Core.Class( Class ) import GHC.Core.DataCon import {-# SOURCE #-} GHC.Tc.Gen.Expr( tcCheckPolyExpr, tcSyntaxOp ) -import {-# SOURCE #-} GHC.Tc.Utils.Unify( unifyType, unifyKind ) +import {-# SOURCE #-} GHC.Tc.Utils.Unify( unifyType ) import GHC.Tc.Utils.Zonk import GHC.Tc.Utils.Monad import GHC.Tc.Types.Constraint @@ -387,71 +385,21 @@ tcInstInvisibleTyBindersN n ty go n subst kind | n > 0 - , Just (bndr, body) <- tcSplitPiTy_maybe kind - , isInvisiblePiTyBinder bndr - = do { (subst', arg) <- tcInstInvisibleTyBinder subst bndr + , Just (bndr, body) <- tcSplitForAllTyVarBinder_maybe kind + , isInvisibleForAllTyFlag (binderFlag bndr) + = do { (subst', arg) <- tcInstInvisibleTyBinder subst (binderVar bndr) ; (args, inner_ty) <- go (n-1) subst' body ; return (arg:args, inner_ty) } | otherwise = return ([], substTy subst kind) -tcInstInvisibleTyBinder :: Subst -> PiTyVarBinder -> TcM (Subst, TcType) +tcInstInvisibleTyBinder :: Subst -> TyVar -> TcM (Subst, TcType) -- Called only to instantiate kinds, in user-written type signatures -tcInstInvisibleTyBinder subst (Named (Bndr tv _)) +tcInstInvisibleTyBinder subst tv = do { (subst', tv') <- newMetaTyVarX subst tv ; return (subst', mkTyVarTy tv') } -tcInstInvisibleTyBinder subst (Anon ty af) - | Just (mk, k1, k2) <- get_eq_tys_maybe (substTy subst (scaledThing ty)) - -- For kinds like (k1 ~ k2) => blah, we want to emit a unification - -- constraint for (k1 ~# k2) and return the argument (Eq# k1 k2) - -- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep - -- Equality is the *only* constraint currently handled in types. - = assert (isInvisibleFunArg af) $ - do { co <- unifyKind Nothing k1 k2 - ; return (subst, mk co) } - - | otherwise -- This should never happen - -- See GHC.Core.TyCo.Rep Note [Constraints in kinds] - = pprPanic "tcInvisibleTyBinder" (ppr ty) - -------------------------------- -get_eq_tys_maybe :: Type - -> Maybe ( Coercion -> Type - -- Given a coercion proving t1 ~# t2, produce the - -- right instantiation for the PiTyVarBinder at hand - , Type -- t1 - , Type -- t2 - ) --- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep -get_eq_tys_maybe ty - -- Lifted heterogeneous equality (~~) - | Just (tc, [_, _, k1, k2]) <- splitTyConApp_maybe ty - , tc `hasKey` heqTyConKey - = Just (mkHEqBoxTy k1 k2, k1, k2) - - -- Lifted homogeneous equality (~) - | Just (tc, [_, k1, k2]) <- splitTyConApp_maybe ty - , tc `hasKey` eqTyConKey - = Just (mkEqBoxTy k1 k2, k1, k2) - - | otherwise - = Nothing - --- | This takes @a ~# b@ and returns @a ~~ b at . -mkHEqBoxTy :: Type -> Type -> TcCoercion -> Type -mkHEqBoxTy ty1 ty2 co - = mkTyConApp (promoteDataCon heqDataCon) [k1, k2, ty1, ty2, mkCoercionTy co] - where k1 = typeKind ty1 - k2 = typeKind ty2 - --- | This takes @a ~# b@ and returns @a ~ b at . -mkEqBoxTy :: Type -> Type -> TcCoercion -> Type -mkEqBoxTy ty1 ty2 co - = mkTyConApp (promoteDataCon eqDataCon) [k, ty1, ty2, mkCoercionTy co] - where k = typeKind ty1 - {- ********************************************************************* * * SkolemTvs (immutable) ===================================== compiler/GHC/Tc/Utils/TcType.hs ===================================== @@ -1344,7 +1344,7 @@ getDFunTyLitKey (CharTyLit n) = mkOccName Name.varName (show n) -- Always succeeds, even if it returns an empty list. tcSplitPiTys :: Type -> ([PiTyVarBinder], Type) tcSplitPiTys ty - = assert (all isTyBinder (fst sty) ) -- No CoVar binders here + = assert (all isTyBinder (fst sty)) -- No CoVar binders here sty where sty = splitPiTys ty @@ -1367,7 +1367,7 @@ tcSplitForAllTyVarBinder_maybe _ = Nothing -- returning just the tyvars. tcSplitForAllTyVars :: Type -> ([TyVar], Type) tcSplitForAllTyVars ty - = assert (all isTyVar (fst sty) ) sty + = assert (all isTyVar (fst sty)) sty where sty = splitForAllTyCoVars ty -- | Like 'tcSplitForAllTyVars', but only splits 'ForAllTy's with 'Invisible' ===================================== compiler/GHC/Tc/Validity.hs ===================================== @@ -520,6 +520,8 @@ typeOrKindCtxt (DataKindCtxt {}) = OnlyKindCtxt typeOrKindCtxt (TySynKindCtxt {}) = OnlyKindCtxt typeOrKindCtxt (TyFamResKindCtxt {}) = OnlyKindCtxt +-- These cases are also described in Note [No constraints in kinds], so any +-- change here should be reflected in that note. typeOrKindCtxt (TySynCtxt {}) = BothTypeAndKindCtxt -- Type synonyms can have types and kinds on their RHSs typeOrKindCtxt (GhciCtxt {}) = BothTypeAndKindCtxt @@ -543,7 +545,6 @@ typeLevelUserTypeCtxt ctxt = case typeOrKindCtxt ctxt of -- | Returns 'True' if the supplied 'UserTypeCtxt' is unambiguously not the -- context for a kind of a type, where the arbitrary use of constraints is -- currently disallowed. --- (See @Note [Constraints in kinds]@ in "GHC.Core.TyCo.Rep".) allConstraintsAllowed :: UserTypeCtxt -> Bool allConstraintsAllowed = typeLevelUserTypeCtxt @@ -931,10 +932,9 @@ checkConstraintsOK :: ValidityEnv -> ThetaType -> Type -> TcM () checkConstraintsOK ve theta ty | null theta = return () | allConstraintsAllowed (ve_ctxt ve) = return () - | otherwise - = -- We are in a kind, where we allow only equality predicates - -- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep, and #16263 - checkTcM (all isEqPred theta) (env, TcRnConstraintInKind (tidyType env ty)) + | otherwise -- We are unambiguously in a kind; see + -- Note [No constraints in kinds] + = failWithTcM (env, TcRnConstraintInKind (tidyType env ty)) where env = ve_tidy_env ve checkVdqOK :: ValidityEnv -> [TyVarBinder] -> Type -> TcM () @@ -945,7 +945,25 @@ checkVdqOK ve tvbs ty = do no_vdq = all (isInvisibleForAllTyFlag . binderFlag) tvbs ValidityEnv{ve_tidy_env = env, ve_ctxt = ctxt} = ve -{- +{- Note [No constraints in kinds] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +GHC does not allow constraints in kinds. Equality constraints +in kinds were allowed from GHC 8.0, but this "feature" was removed +as part of Proposal #547 (https://github.com/ghc-proposals/ghc-proposals/pull/547), +which contains further context and motivation for this removal. + +The lack of constraints in kinds is enforced by checkConstraintsOK, which +uses the UserTypeCtxt to determine if we are unambiguously checking a kind. +There are two ambiguous contexts (constructor BothTypeAndKindCtxt of TypeOrKindCtxt) +as written in typeOfKindCtxt: + - TySynCtxt: this is the RHS of a type synonym. We check the expansion of type + synonyms for constraints, so this is handled at the usage site of the synonym. + - GhciCtxt: This is the type in a :kind command. A constraint here does not cause + any trouble, because the type cannot be used to classify a type. + +Beyond these two cases, we also promote data constructors. We check for constraints +in data constructor types in GHC.Tc.Gen.HsType.tcTyVar. + Note [Liberal type synonyms] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If -XLiberalTypeSynonyms is on, expand closed type synonyms *before* ===================================== compiler/GHC/Types/Var.hs ===================================== @@ -682,10 +682,6 @@ Currently there are nine different uses of 'VarBndr': * TyCon.TyConBinder = VarBndr TyVar TyConBndrVis Binders of a TyCon; see TyCon in GHC.Core.TyCon -* TyCon.TyConPiTyBinder = VarBndr TyCoVar TyConBndrVis - Binders of a PromotedDataCon - See Note [Promoted GADT data constructors] in GHC.Core.TyCon - * IfaceType.IfaceForAllBndr = VarBndr IfaceBndr ForAllTyFlag * IfaceType.IfaceForAllSpecBndr = VarBndr IfaceBndr Specificity * IfaceType.IfaceTyConBinder = VarBndr IfaceBndr TyConBndrVis ===================================== docs/users_guide/exts/data_kinds.rst ===================================== @@ -91,17 +91,12 @@ There are only a couple of exceptions to this rule: type theory just isn’t up to the task of promoting data families, which requires full dependent types. -- Data constructors with contexts that contain non-equality constraints cannot - be promoted. For example: :: +- Data constructors with contexts cannot be promoted; but GADTs can. For example:: data Foo :: Type -> Type where - MkFoo1 :: a ~ Int => Foo a -- promotable - MkFoo2 :: a ~~ Int => Foo a -- promotable - MkFoo3 :: Show a => Foo a -- not promotable - - ``MkFoo1`` and ``MkFoo2`` can be promoted, since their contexts - only involve equality-oriented constraints. However, ``MkFoo3``'s context - contains a non-equality constraint ``Show a``, and thus cannot be promoted. + MkFoo1 :: Show a => Foo a -- not promotable + MkFoo2 :: (a ~ Int) => Foo a -- not promotable + MkFoo3 :: Foo Int -- promotable .. _promotion-syntax: @@ -215,28 +210,3 @@ parameter to ``UnEx``, the kind is not escaping the existential, and the above code is valid. See also :ghc-ticket:`7347`. - -.. _constraints_in_kinds: - -Constraints in kinds --------------------- - -Kinds can (with :extension:`DataKinds`) contain type constraints. However, -only equality constraints are supported. - -Here is an example of a constrained kind: :: - - type family IsTypeLit a where - IsTypeLit Nat = True - IsTypeLit Symbol = True - IsTypeLit a = False - - data T :: forall a. (IsTypeLit a ~ True) => a -> Type where - MkNat :: T 42 - MkSymbol :: T "Don't panic!" - -The declarations above are accepted. However, if we add ``MkOther :: T Int``, -we get an error that the equality constraint is not satisfied; ``Int`` is -not a type literal. Note that explicitly quantifying with ``forall a`` is -necessary in order for ``T`` to typecheck -(see :ref:`complete-kind-signatures`). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c12ceb41c3267cef61a837d9c5d8ed184c23e8f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0c12ceb41c3267cef61a837d9c5d8ed184c23e8f You're receiving 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 Nov 14 11:46:26 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 06:46:26 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Fix merge conflict in T18355.stderr Message-ID: <63722a9276e82_24229e33e5607c553517@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - c938a1db by Ben Gamari at 2022-11-14T06:46:18-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - 9 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Type.hs - rts/eventlog/EventLog.c - rts/include/rts/IPE.h - + testsuite/tests/hiefile/should_compile/T22416.hs - + testsuite/tests/hiefile/should_compile/T22416.stderr - testsuite/tests/hiefile/should_compile/all.T - testsuite/tests/roles/should_compile/T8958.stderr - testsuite/tests/simplCore/should_compile/T18355.stderr Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -1542,14 +1542,18 @@ dataConWrapperType (MkData { dcUserTyVarBinders = user_tvbs, res_ty dataConNonlinearType :: DataCon -> Type +-- Just like dataConWrapperType, but with the +-- linearity on the arguments all zapped to Many dataConNonlinearType (MkData { dcUserTyVarBinders = user_tvbs, dcOtherTheta = theta, dcOrigArgTys = arg_tys, - dcOrigResTy = res_ty }) - = let arg_tys' = map (\(Scaled w t) -> Scaled (case w of OneTy -> ManyTy; _ -> w) t) arg_tys - in mkInvisForAllTys user_tvbs $ - mkInvisFunTys theta $ - mkScaledFunTys arg_tys' $ - res_ty + dcOrigResTy = res_ty, + dcStupidTheta = stupid_theta }) + = mkInvisForAllTys user_tvbs $ + mkInvisFunTys (stupid_theta ++ theta) $ + mkScaledFunTys arg_tys' $ + res_ty + where + arg_tys' = map (\(Scaled w t) -> Scaled (case w of OneTy -> ManyTy; _ -> w) t) arg_tys dataConDisplayType :: Bool -> DataCon -> Type dataConDisplayType show_linear_types dc ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1383,7 +1383,7 @@ splitFunTys ty = split [] ty ty split args orig_ty ty | Just ty' <- coreView ty = split args orig_ty ty' split args orig_ty _ = (reverse args, orig_ty) -funResultTy :: Type -> Type +funResultTy :: HasDebugCallStack => Type -> Type -- ^ Extract the function result type and panic if that is not possible funResultTy ty | FunTy { ft_res = res } <- coreFullView ty = res ===================================== rts/eventlog/EventLog.c ===================================== @@ -1429,7 +1429,7 @@ void postIPE(const InfoProvEnt *ipe) ensureRoomForVariableEvent(&eventBuf, len); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); - postWord64(&eventBuf, (StgWord) ipe->info); + postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postString(&eventBuf, ipe->prov.table_name); postString(&eventBuf, ipe->prov.closure_desc); postString(&eventBuf, ipe->prov.ty_desc); ===================================== rts/include/rts/IPE.h ===================================== @@ -24,6 +24,8 @@ typedef struct InfoProv_ { } InfoProv; typedef struct InfoProvEnt_ { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; InfoProv prov; } InfoProvEnt; @@ -50,6 +52,8 @@ typedef uint32_t StringIdx; // The size of this must be a multiple of the word size // to ensure correct packing. typedef struct { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; StringIdx table_name; StringIdx closure_desc; ===================================== testsuite/tests/hiefile/should_compile/T22416.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE Haskell2010 #-} +module Swish.GraphMatch where + +import qualified Data.Map as M +import Data.Word (Word32) + +class Label lb + +type LabelIndex = (Word32, Word32) + +data (Label lb, Eq lv, Show lv) => GenLabelMap lb lv = + MkLabelMap Word32 (M.Map lb lv) + +type LabelMap lb = GenLabelMap lb LabelIndex + +emptyMap :: Label lb => LabelMap lb +emptyMap = MkLabelMap 1 M.empty + +-- MkLabelMap :: forall lb lv. (Label lb, Eq lv, Show lv) +-- => Word32 -> M.Map lb lv -> GenLabelMap lb lv \ No newline at end of file ===================================== testsuite/tests/hiefile/should_compile/T22416.stderr ===================================== @@ -0,0 +1,2 @@ +Got valid scopes +Got no roundtrip errors ===================================== testsuite/tests/hiefile/should_compile/all.T ===================================== @@ -22,3 +22,4 @@ test('Scopes', normal, compile, ['-fno-code -fwrite-ide- # See https://gitlab.haskell.org/ghc/ghc/-/issues/18425 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2464#note_301989 test('ScopesBug', expect_broken(18425), compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) test('T18425', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) +test('T22416', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) ===================================== testsuite/tests/roles/should_compile/T8958.stderr ===================================== @@ -10,7 +10,9 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom T8958.N:Map :: Map k v = [(k, v)] DATA CONSTRUCTORS - MkMap :: forall k v. [(k, v)] -> Map k v + MkMap :: forall k v. + (Nominal k, Representational v) => + [(k, v)] -> Map k v CLASS INSTANCES instance [incoherent] Representational a -- Defined at T8958.hs:11:10 @@ -92,3 +94,19 @@ AbsBinds [a] [] Evidence: [EvBinds{}]} + +T8958.hs:14:54: warning: [-Wsimplifiable-class-constraints (in -Wdefault)] + • The constraint ‘Representational v’ matches + instance Representational a -- Defined at T8958.hs:11:10 + This makes type inference for inner bindings fragile; + either use MonoLocalBinds, or simplify it using the instance + • In the definition of data constructor ‘MkMap’ + In the newtype declaration for ‘Map’ + +T8958.hs:14:54: warning: [-Wsimplifiable-class-constraints (in -Wdefault)] + • The constraint ‘Nominal k’ matches + instance Nominal a -- Defined at T8958.hs:8:10 + This makes type inference for inner bindings fragile; + either use MonoLocalBinds, or simplify it using the instance + • In the definition of data constructor ‘MkMap’ + In the newtype declaration for ‘Map’ ===================================== testsuite/tests/simplCore/should_compile/T18355.stderr ===================================== @@ -7,16 +7,8 @@ Result size of Tidy Core f :: forall {a}. Num a => a -> Bool -> a -> a [GblId, Arity=4, -<<<<<<< HEAD - Str=<1P(MC1(C1(L)),MC1(C1(L)),A,A,A,A,A)><1L>, + Str=<1P(MC(1,C(1,L)),MC(1,C(1,L)),A,A,A,A,A)><1L>, Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, -||||||| parent of 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, -======= - Str=, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, ->>>>>>> 75ae893f7c (Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)) WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 0 70 0] 100 0}] f = \ (@a) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18b8c1777766bd44d29874ac46a27c96137f2dea...c938a1db8e51bba1cff55f5493157e4c8afea8b8 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/18b8c1777766bd44d29874ac46a27c96137f2dea...c938a1db8e51bba1cff55f5493157e4c8afea8b8 You're receiving 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 Nov 14 14:04:11 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Mon, 14 Nov 2022 09:04:11 -0500 Subject: [Git][ghc/ghc][wip/T21623-faster] Wibbles Message-ID: <63724adb7e604_24229e33bfa4545843f@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623-faster at Glasgow Haskell Compiler / GHC Commits: a72901a2 by Simon Peyton Jones at 2022-11-14T14:05:38+00:00 Wibbles - - - - - 2 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Core/Type.hs Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -2455,15 +2455,25 @@ isTcTyCon :: TyCon -> Bool isTcTyCon (TcTyCon {}) = True isTcTyCon _ = False -tyConTypeKindPieces :: TyCon -> ([TyConBinder], Kind, Bool) +tyConTypeKindPieces :: TyCon -> (Kind, [TyConBinder], Kind, Bool) -- This rather specialised function returns the bits needed for typeKind tyConTypeKindPieces tc - | TcTyCon { tyConKind = kind, tcTyConIsPoly = False } <- tc - = -- For MonoTcTyCons we must use the tyConKind - -- because only that is zonked. See setTcTyConKind - ([], kind, False) - | otherwise - = (tyConBinders tc, tyConResKind tc, tyConHasClosedResKind tc) + | AlgTyCon { tyConKind = k, tyConBinders = bs, tyConResKind = rk, tyConHasClosedResKind = cl } <- tc + = (k, bs, rk, cl) + | SynonymTyCon { tyConKind = k, tyConBinders = bs, tyConResKind = rk, tyConHasClosedResKind = cl } <- tc + = (k, bs, rk, cl) + | FamilyTyCon { tyConKind = k, tyConBinders = bs, tyConResKind = rk, tyConHasClosedResKind = cl } <- tc + = (k, bs, rk, cl) + | PrimTyCon { tyConKind = k, tyConBinders = bs, tyConResKind = rk, tyConHasClosedResKind = cl } <- tc + = (k, bs, rk, cl) + | PromotedDataCon { tyConKind = k, tyConBinders = bs, tyConResKind = rk, tyConHasClosedResKind = cl } <- tc + = (k, bs, rk, cl) + | TcTyCon { tyConKind = k, tyConBinders = bs, tyConResKind = rk, tyConHasClosedResKind = cl + , tcTyConIsPoly = is_poly } <- tc + = if is_poly -- For MonoTcTyCons we must use the tyConKind + then (k, bs, rk, cl) -- because only that is zonked. See setTcTyConKind + else (k, [], k, False) -- is_closed = False because kind k has free unification variables + -- but actually will is_closed will never be looked at setTcTyConKind :: TyCon -> Kind -> TyCon -- Update the Kind of a TcTyCon ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1482,11 +1482,11 @@ tyConAppResKind :: TyCon -> [Type] -> Kind -- Its specification is: -- tyConAppResKind tc tys = piResultTys (tyConKind tc) tys tyConAppResKind tc args - | null args = tyConKind tc + | null args = tc_kind | otherwise = go1 tc_bndrs args where - !(tc_bndrs, tc_res_kind, closed_res_kind) = tyConTypeKindPieces tc + !(tc_kind, tc_bndrs, !tc_res_kind, closed_res_kind) = tyConTypeKindPieces tc init_subst = mkEmptySubst $ mkInScopeSet (tyCoVarsOfTypes args) go1 :: [TyConBinder] -> [Type] -> Type View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a72901a23706212f6d99251b0a993278b5d3171b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a72901a23706212f6d99251b0a993278b5d3171b You're receiving 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 Nov 14 14:36:42 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 09:36:42 -0500 Subject: [Git][ghc/ghc][master] Fix a trivial typo in dataConNonlinearType Message-ID: <6372527acf5b9_24229e33e8cab45941db@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 6 changed files: - compiler/GHC/Core/DataCon.hs - compiler/GHC/Core/Type.hs - + testsuite/tests/hiefile/should_compile/T22416.hs - + testsuite/tests/hiefile/should_compile/T22416.stderr - testsuite/tests/hiefile/should_compile/all.T - testsuite/tests/roles/should_compile/T8958.stderr Changes: ===================================== compiler/GHC/Core/DataCon.hs ===================================== @@ -1542,14 +1542,18 @@ dataConWrapperType (MkData { dcUserTyVarBinders = user_tvbs, res_ty dataConNonlinearType :: DataCon -> Type +-- Just like dataConWrapperType, but with the +-- linearity on the arguments all zapped to Many dataConNonlinearType (MkData { dcUserTyVarBinders = user_tvbs, dcOtherTheta = theta, dcOrigArgTys = arg_tys, - dcOrigResTy = res_ty }) - = let arg_tys' = map (\(Scaled w t) -> Scaled (case w of OneTy -> ManyTy; _ -> w) t) arg_tys - in mkInvisForAllTys user_tvbs $ - mkInvisFunTys theta $ - mkScaledFunTys arg_tys' $ - res_ty + dcOrigResTy = res_ty, + dcStupidTheta = stupid_theta }) + = mkInvisForAllTys user_tvbs $ + mkInvisFunTys (stupid_theta ++ theta) $ + mkScaledFunTys arg_tys' $ + res_ty + where + arg_tys' = map (\(Scaled w t) -> Scaled (case w of OneTy -> ManyTy; _ -> w) t) arg_tys dataConDisplayType :: Bool -> DataCon -> Type dataConDisplayType show_linear_types dc ===================================== compiler/GHC/Core/Type.hs ===================================== @@ -1383,7 +1383,7 @@ splitFunTys ty = split [] ty ty split args orig_ty ty | Just ty' <- coreView ty = split args orig_ty ty' split args orig_ty _ = (reverse args, orig_ty) -funResultTy :: Type -> Type +funResultTy :: HasDebugCallStack => Type -> Type -- ^ Extract the function result type and panic if that is not possible funResultTy ty | FunTy { ft_res = res } <- coreFullView ty = res ===================================== testsuite/tests/hiefile/should_compile/T22416.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE Haskell2010 #-} +module Swish.GraphMatch where + +import qualified Data.Map as M +import Data.Word (Word32) + +class Label lb + +type LabelIndex = (Word32, Word32) + +data (Label lb, Eq lv, Show lv) => GenLabelMap lb lv = + MkLabelMap Word32 (M.Map lb lv) + +type LabelMap lb = GenLabelMap lb LabelIndex + +emptyMap :: Label lb => LabelMap lb +emptyMap = MkLabelMap 1 M.empty + +-- MkLabelMap :: forall lb lv. (Label lb, Eq lv, Show lv) +-- => Word32 -> M.Map lb lv -> GenLabelMap lb lv \ No newline at end of file ===================================== testsuite/tests/hiefile/should_compile/T22416.stderr ===================================== @@ -0,0 +1,2 @@ +Got valid scopes +Got no roundtrip errors ===================================== testsuite/tests/hiefile/should_compile/all.T ===================================== @@ -22,3 +22,4 @@ test('Scopes', normal, compile, ['-fno-code -fwrite-ide- # See https://gitlab.haskell.org/ghc/ghc/-/issues/18425 and https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2464#note_301989 test('ScopesBug', expect_broken(18425), compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) test('T18425', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) +test('T22416', normal, compile, ['-fno-code -fwrite-ide-info -fvalidate-ide-info']) ===================================== testsuite/tests/roles/should_compile/T8958.stderr ===================================== @@ -10,7 +10,9 @@ TYPE CONSTRUCTORS COERCION AXIOMS axiom T8958.N:Map :: Map k v = [(k, v)] DATA CONSTRUCTORS - MkMap :: forall k v. [(k, v)] -> Map k v + MkMap :: forall k v. + (Nominal k, Representational v) => + [(k, v)] -> Map k v CLASS INSTANCES instance [incoherent] Representational a -- Defined at T8958.hs:11:10 @@ -92,3 +94,19 @@ AbsBinds [a] [] Evidence: [EvBinds{}]} + +T8958.hs:14:54: warning: [-Wsimplifiable-class-constraints (in -Wdefault)] + • The constraint ‘Representational v’ matches + instance Representational a -- Defined at T8958.hs:11:10 + This makes type inference for inner bindings fragile; + either use MonoLocalBinds, or simplify it using the instance + • In the definition of data constructor ‘MkMap’ + In the newtype declaration for ‘Map’ + +T8958.hs:14:54: warning: [-Wsimplifiable-class-constraints (in -Wdefault)] + • The constraint ‘Nominal k’ matches + instance Nominal a -- Defined at T8958.hs:8:10 + This makes type inference for inner bindings fragile; + either use MonoLocalBinds, or simplify it using the instance + • In the definition of data constructor ‘MkMap’ + In the newtype declaration for ‘Map’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/294f907370fadd3313f8c5e6aa87a93c8b86f139 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/294f907370fadd3313f8c5e6aa87a93c8b86f139 You're receiving 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 Nov 14 14:37:16 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 09:37:16 -0500 Subject: [Git][ghc/ghc][master] eventlog: Ensure that IPE output contains actual info table pointers Message-ID: <6372529c8fa8d_24229e33e8ca785994b6@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - 2 changed files: - rts/eventlog/EventLog.c - rts/include/rts/IPE.h Changes: ===================================== rts/eventlog/EventLog.c ===================================== @@ -1429,7 +1429,7 @@ void postIPE(const InfoProvEnt *ipe) ensureRoomForVariableEvent(&eventBuf, len); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); - postWord64(&eventBuf, (StgWord) ipe->info); + postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postString(&eventBuf, ipe->prov.table_name); postString(&eventBuf, ipe->prov.closure_desc); postString(&eventBuf, ipe->prov.ty_desc); ===================================== rts/include/rts/IPE.h ===================================== @@ -24,6 +24,8 @@ typedef struct InfoProv_ { } InfoProv; typedef struct InfoProvEnt_ { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; InfoProv prov; } InfoProvEnt; @@ -50,6 +52,8 @@ typedef uint32_t StringIdx; // The size of this must be a multiple of the word size // to ensure correct packing. typedef struct { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; StringIdx table_name; StringIdx closure_desc; View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/268a3ce952f6be00a1dd164dc4d7acb346045e90 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/268a3ce952f6be00a1dd164dc4d7acb346045e90 You're receiving 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 Nov 14 15:36:41 2022 From: gitlab at gitlab.haskell.org (Andreas Klebinger (@AndreasK)) Date: Mon, 14 Nov 2022 10:36:41 -0500 Subject: [Git][ghc/ghc][ghc-9.4] Bump hadrian index state to allow 9.4 as boot compiler Message-ID: <637260896c09b_24229e32febb6861592e@gitlab.mail> Andreas Klebinger pushed to branch ghc-9.4 at Glasgow Haskell Compiler / GHC Commits: 79a09016 by Andreas Klebinger at 2022-11-10T13:14:04+01:00 Bump hadrian index state to allow 9.4 as boot compiler - - - - - 1 changed file: - hadrian/cabal.project Changes: ===================================== hadrian/cabal.project ===================================== @@ -1,7 +1,7 @@ packages: ./ -- This essentially freezes the build plan for hadrian -index-state: 2022-03-26T18:46:55Z +index-state: 2022-11-10T10:48:39Z -- N.B. Compile with -O0 since this is not a performance-critical executable -- and the Cabal takes nearly twice as long to build with -O1. See #16817. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/79a09016efc097b34f2229990c39bd18d3303fa7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/79a09016efc097b34f2229990c39bd18d3303fa7 You're receiving 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 Nov 14 15:37:56 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 10:37:56 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: eventlog: Ensure that IPE output contains actual info table pointers Message-ID: <637260d41fe8a_24229e33e5459c61861c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - 52213820 by Matthew Pickering at 2022-11-14T10:37:45-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 4f98c9f3 by Matthew Pickering at 2022-11-14T10:37:47-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 6 changed files: - rts/eventlog/EventLog.c - rts/include/rts/IPE.h - testsuite/driver/testlib.py - + testsuite/tests/simplCore/should_compile/T22347.hs - + testsuite/tests/simplCore/should_compile/T22347a.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== rts/eventlog/EventLog.c ===================================== @@ -1429,7 +1429,7 @@ void postIPE(const InfoProvEnt *ipe) ensureRoomForVariableEvent(&eventBuf, len); postEventHeader(&eventBuf, EVENT_IPE); postPayloadSize(&eventBuf, len); - postWord64(&eventBuf, (StgWord) ipe->info); + postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info)); postString(&eventBuf, ipe->prov.table_name); postString(&eventBuf, ipe->prov.closure_desc); postString(&eventBuf, ipe->prov.ty_desc); ===================================== rts/include/rts/IPE.h ===================================== @@ -24,6 +24,8 @@ typedef struct InfoProv_ { } InfoProv; typedef struct InfoProvEnt_ { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; InfoProv prov; } InfoProvEnt; @@ -50,6 +52,8 @@ typedef uint32_t StringIdx; // The size of this must be a multiple of the word size // to ensure correct packing. typedef struct { + // When TNTC is enabled this will point to the entry code + // not the info table itself. const StgInfoTable *info; StringIdx table_name; StringIdx closure_desc; ===================================== testsuite/driver/testlib.py ===================================== @@ -1247,14 +1247,23 @@ def do_test(name: TestName, dst_makefile.write_text(makefile, encoding='UTF-8') if opts.pre_cmd: + stdout_path = in_testdir(name, 'pre_cmd_stdout') + stderr_path = in_testdir(name, 'pre_cmd_stderr') exit_code = runCmd('cd "{0}" && {1}'.format(opts.testdir, override_options(opts.pre_cmd)), - stderr = subprocess.STDOUT, + stdout = stdout_path, + stderr = stderr_path, print_output = config.verbose >= 3) # If user used expect_broken then don't record failures of pre_cmd if exit_code != 0 and opts.expect not in ['fail']: framework_fail(name, way, 'pre_cmd failed: {0}'.format(exit_code)) if_verbose(1, '** pre_cmd was "{0}".'.format(override_options(opts.pre_cmd))) + stderr_contents = stderr_path.read_text(encoding='UTF-8', errors='replace') + stdout_contents = stdout_path.read_text(encoding='UTF-8', errors='replace') + if_verbose(1, 'stdout: {0}'.format(stdout_contents)) + if_verbose(1, 'stderr: {0}'.format(stderr_contents)) + # Don't continue and try to run the test if the pre_cmd fails. + return result = func(*[name,way] + args) ===================================== testsuite/tests/simplCore/should_compile/T22347.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module M where + +import Control.Monad.ST +import Data.Array.ST +import Data.Array.Unboxed + +bfs :: Array Int [Int] -> ST s (STArray s Int ()) +bfs g = do + vis :: STArray s Int () <- newArray (bounds g) () + ch :: STArray s Int () <- newArray (bounds g) () + let go [] = pure () :: ST s () + go q = do + flip mapM_ q $ \u -> do + readArray vis (head (g!u)) + readArray ch u + writeArray ch u () + go [] + go [] + pure ch ===================================== testsuite/tests/simplCore/should_compile/T22347a.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module M where + +import Control.Monad.ST +import Data.Array.ST +import Data.Array.Unboxed + +bfs :: Array Int [Int] -> ST s (STArray s Int ()) +bfs g = do + vis :: STArray s Int () <- newArray (bounds g) () + ch :: STArray s Int () <- newArray (bounds g) () + let go [] = pure () :: ST s () + go q = do + flip mapM_ q $ \u -> do + readArray vis (head (g!u)) + readArray ch u + writeArray ch u () + go [] + go [] + pure ch ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -437,6 +437,8 @@ test('T22097', [grep_errmsg(r'case.*wgoEven') ], multimod_compile, ['T22097', '- test('T13873', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-rules']) test('T22357', normal, compile, ['-O']) +test('T22347', normal, compile, ['-O -fno-full-laziness']) +test('T22347a', normal, compile, ['-O2 -fno-full-laziness']) # T17366: expecting to see a rule # Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c938a1db8e51bba1cff55f5493157e4c8afea8b8...4f98c9f3781ebd64b84336ea90a4c5dbb7a66221 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c938a1db8e51bba1cff55f5493157e4c8afea8b8...4f98c9f3781ebd64b84336ea90a4c5dbb7a66221 You're receiving 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 Nov 14 15:53:31 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 14 Nov 2022 10:53:31 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/constraint-printing Message-ID: <6372647bdbcd3_24229e33e754cc62325b@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/constraint-printing at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/constraint-printing You're receiving 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 Nov 14 16:02:24 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 14 Nov 2022 11:02:24 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] 7 commits: Fix fragile RULE setup in GHC.Float Message-ID: <637266903bc31_24229e33e5607c6253b4@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - ce2c832e by Sylvain Henry at 2022-11-14T17:05:53+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump submodules Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 15 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/Core/Coercion.hs - compiler/GHC/Core/Coercion.hs-boot The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c08b438b9d91f64652bad149047d47b58fd8e4cd...ce2c832e563c913c635b0a7b35cf93d8be0bbd9b -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c08b438b9d91f64652bad149047d47b58fd8e4cd...ce2c832e563c913c635b0a7b35cf93d8be0bbd9b You're receiving 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 Nov 14 16:40:55 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 14 Nov 2022 11:40:55 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22428 Message-ID: <63726f972092f_24229e32febb686304b4@gitlab.mail> Sebastian Graf pushed new branch wip/T22428 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22428 You're receiving 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 Nov 14 16:50:03 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 14 Nov 2022 11:50:03 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <637271bb5e043_24229e32febb6863242e@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: 6dd0b6cb by Sebastian Graf at 2022-11-14T17:49:57+01:00 Fix contification with stable unfoldings (#22428) - - - - - 1 changed file: - compiler/GHC/Core/Opt/OccurAnal.hs Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -754,12 +754,11 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage = WithUsageDetails body_usage [] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs2] where (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr final_bndr = tagged_bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] @@ -773,13 +772,18 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + (WithUsageDetails rhs_uds rhs1) = occAnalLam rhs_env rhs + -- corresponding call to adjustRhsUsage directly below + rhs2 = markNonRecJoinOneShots mb_join_arity rhs1 + rhs_usage = adjustRhsUsage mb_join_arity rhs1 $ + rhs_uds `andUDs` unf_uds `andUDs` rule_uds --------- Unfolding --------- -- See Note [Unfoldings and join points] + -- and Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env mb_join_arity unf --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] @@ -848,10 +852,14 @@ occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs | otherwise -- It's mentioned in the body = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + (NonRec tagged_bndr rhs' : binds) where (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + rhs' = markNonRecJoinOneShots mb_join_arity rhs + rhs_uds' = adjustRhsUsage mb_join_arity rhs' rhs_uds + -- corresponding call to occAnalLam is in makeNode + -- rhs_uds is for a non-recursive join point; we should to do the same + -- as occAnalNonRecBind, so we do 'markNonRecJoinOneShots' before. mb_join_arity = willBeJoinId_maybe tagged_bndr -- The Rec case is the interesting one @@ -1412,27 +1420,45 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added + mb_opt_join_arity = Just (manifestJoinArity rhs) + -- We don't know yet if bndr will become a join point. + -- But *if* it becomes one, we can guess its join arity: manifestJoinArity. + -- Here, we pretend that bndr will become a join point so that we preserve + -- tail calls (perhaps to other binders) in scope_uds. If it turns out + -- that bndr cannot become a join point, we take care of it later, in + -- occAnalRec and tagRecBinders, through calling adjustRhsUsage on the + -- merged scope_uds. + -- By pretending that we know the join arity we can already zap tail call + -- info for stable unfoldings and RULES with mismatching manifestJoinArity + -- without affecting tail call info from rhs_uds. + -- There's a special case worth thinking about: If bndr ends up as an + -- AcyclicSCC it might become a non-recursive join point with join arity + -- /less/ than mb_opt_join_arity (so 'manifestJoinArity' is really a + -- maximum). Well, then we'll still adjustRhsUsage with the lower arity, so + -- the only drawback is that we *might* have discarded useful tail call info + -- in inl_uds or rule_uds that we will see on the next iteration. -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec + -- Compared to occAnalRhs, this will not adjust the RHS because + -- (a) we don't yet know the final answer for mb_join_arity + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLam call from occAnalRhs, and postpone + -- adjustRhsUsage until occAnalRec. rhs_env = rhsCtxt env (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- corresponding call to adjustRhsUsage in occAnalRec and tagRecBinders --------- Unfolding --------- -- See Note [Unfoldings and join points] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env mb_opt_join_arity unf --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1442,7 +1468,7 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) --------- All rules -------- rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = occAnalRules rhs_env mb_opt_join_arity bndr rules' = map fstOf3 rules_w_uds rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds @@ -1815,7 +1841,11 @@ occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage. +-- Every call site links to its respective adjustRhsUsage call and vice versa. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustRhsUsage does the fixup. -- See Note [Adjusting right-hand sides] occAnalLam env (Lam bndr expr) @@ -1895,51 +1925,29 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity +occAnalRhs :: OccEnv -> Maybe JoinArity -> CoreExpr -- RHS -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs +-- ^ This function immediately does adjustRhsUsage after the call to occAnalLam. +-- It's useful for anonymous lambdas and unfoldings. +occAnalRhs !env mb_join_arity rhs + = WithUsageDetails (adjustRhsUsage mb_join_arity rhs' usage) rhs' where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs + WithUsageDetails usage rhs' = occAnalLam env rhs + occAnalUnfolding :: OccEnv - -> RecFlag -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding -> WithUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env mb_join_arity unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + (WithUsageDetails usage rhs') = occAnalRhs env mb_join_arity rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } @@ -1958,9 +1966,7 @@ occAnalUnfolding !env is_rec mb_join_arity unf where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter @@ -1989,8 +1995,8 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllNonTailIf (not exact_join) $ -- Nearly adjustRhsUsage, but we don't want to + markAllMany $ -- build `mkLams (map _ args) rhs` just for the call rhs_uds `delDetailsList` bndrs exact_join = exactJoin mb_join_arity args @@ -2208,10 +2214,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = occAnalRhs env Nothing expr -- mb_join_arity == Nothing <=> markAllNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2286,7 +2289,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- occAnalRhs env (Just 1) arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -3133,7 +3136,7 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal + -> CoreExpr -- Rhs, AFTER occAnalLam -> UsageDetails -- From body of lambda -> UsageDetails adjustRhsUsage mb_join_arity rhs usage @@ -3146,6 +3149,28 @@ adjustRhsUsage mb_join_arity rhs usage exact_join = exactJoin mb_join_arity bndrs (bndrs,_) = collectBinders rhs +-- | IF rhs becomes a join point, then `manifestJoinArity rhs` returns the +-- exact join arity of `rhs`. +manifestJoinArity :: CoreExpr -> JoinArity +manifestJoinArity rhs = length $ fst $ collectBinders rhs + +markNonRecJoinOneShots :: Maybe JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots Nothing rhs = rhs +markNonRecJoinOneShots (Just join_arity) rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) + exactJoin :: Maybe JoinArity -> [a] -> Bool exactJoin Nothing _ = False exactJoin (Just join_arity) args = args `lengthIs` join_arity @@ -3224,7 +3249,7 @@ tagRecBinders lvl body_uds details_s -- 2. Adjust usage details of each RHS, taking into account the -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds + rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds -- matching occAnalLam in makeNode | ND { nd_bndr = bndr, nd_uds = rhs_uds , nd_rhs = rhs } <- details_s ] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6dd0b6cbc0e95999906363066f49e64279badf0a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6dd0b6cbc0e95999906363066f49e64279badf0a You're receiving 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 Nov 14 16:53:12 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Mon, 14 Nov 2022 11:53:12 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Add Javascript backend Message-ID: <63727278f1502_24229e33bfa454632757@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: ed531a5c by Sylvain Henry at 2022-11-14T17:56:55+01:00 Add Javascript backend Add JS backend adapted from the GHCJS project by Luite Stegeman. Some features haven't been ported or implemented yet. Tests for these features have been disabled with an associated gitlab ticket. Bump submodules Co-authored-by: Jeffrey Young <jeffrey.young at iohk.io> Co-authored-by: Luite Stegeman <stegeman at gmail.com> Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com> - - - - - 25 changed files: - .gitlab-ci.yml - .gitlab/ci.sh - .gitlab/gen_ci.hs - .gitlab/jobs.yaml - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Data/Graph/Directed.hs - compiler/GHC/Driver/Backend.hs - compiler/GHC/Driver/Backend/Internal.hs - compiler/GHC/Driver/CodeOutput.hs - compiler/GHC/Driver/Config/StgToCmm.hs - + compiler/GHC/Driver/Config/StgToJS.hs - compiler/GHC/Driver/Flags.hs - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Phases.hs - compiler/GHC/Driver/Pipeline.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Pipeline/Phases.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Foreign/Decl.hs - + compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/Iface/Binary.hs - compiler/GHC/Iface/Ext/Binary.hs - compiler/GHC/Iface/Tidy/StaticPtrTable.hs - + compiler/GHC/JS/Make.hs - + compiler/GHC/JS/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed531a5c3cebc77544e569076e53a8706f84f47a -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ed531a5c3cebc77544e569076e53a8706f84f47a You're receiving 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 Nov 14 17:04:26 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Mon, 14 Nov 2022 12:04:26 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <6372751a9dd74_24229e33e5459c6362dd@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: 1f59b85e by Sebastian Graf at 2022-11-14T18:04:18+01:00 Fix contification with stable unfoldings (#22428) - - - - - 4 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -754,12 +754,11 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage = WithUsageDetails body_usage [] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs2] where (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr final_bndr = tagged_bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] @@ -773,13 +772,18 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + (WithUsageDetails rhs_uds rhs1) = occAnalLam rhs_env rhs + -- corresponding call to adjustRhsUsage directly below + rhs2 = markNonRecJoinOneShots mb_join_arity rhs1 + rhs_usage = adjustRhsUsage mb_join_arity rhs1 $ + rhs_uds `andUDs` unf_uds `andUDs` rule_uds --------- Unfolding --------- -- See Note [Unfoldings and join points] + -- and Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env mb_join_arity unf --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] @@ -848,10 +852,14 @@ occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs | otherwise -- It's mentioned in the body = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + (NonRec tagged_bndr rhs' : binds) where (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + rhs' = markNonRecJoinOneShots mb_join_arity rhs + rhs_uds' = adjustRhsUsage mb_join_arity rhs' rhs_uds + -- corresponding call to occAnalLam is in makeNode + -- rhs_uds is for a non-recursive join point; we should to do the same + -- as occAnalNonRecBind, so we do 'markNonRecJoinOneShots' before. mb_join_arity = willBeJoinId_maybe tagged_bndr -- The Rec case is the interesting one @@ -1412,27 +1420,45 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added + mb_opt_join_arity = Just (manifestJoinArity rhs) + -- We don't know yet if bndr will become a join point. + -- But *if* it becomes one, we can guess its join arity: manifestJoinArity. + -- Here, we pretend that bndr will become a join point so that we preserve + -- tail calls (perhaps to other binders) in scope_uds. If it turns out + -- that bndr cannot become a join point, we take care of it later, in + -- occAnalRec and tagRecBinders, through calling adjustRhsUsage on the + -- merged scope_uds. + -- By pretending that we know the join arity we can already zap tail call + -- info for stable unfoldings and RULES with mismatching manifestJoinArity + -- without affecting tail call info from rhs_uds. + -- There's a special case worth thinking about: If bndr ends up as an + -- AcyclicSCC it might become a non-recursive join point with join arity + -- /less/ than mb_opt_join_arity (so 'manifestJoinArity' is really a + -- maximum). Well, then we'll still adjustRhsUsage with the lower arity, so + -- the only drawback is that we *might* have discarded useful tail call info + -- in inl_uds or rule_uds that we will see on the next iteration. -- See Note [Join points and unfoldings/rules] --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec + -- Compared to occAnalRhs, this will not adjust the RHS because + -- (a) we don't yet know the final answer for mb_join_arity + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLam call from occAnalRhs, and postpone + -- adjustRhsUsage until occAnalRec. rhs_env = rhsCtxt env (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + -- corresponding call to adjustRhsUsage in occAnalRec and tagRecBinders --------- Unfolding --------- -- See Note [Unfoldings and join points] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env mb_opt_join_arity unf --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1442,7 +1468,7 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) --------- All rules -------- rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = occAnalRules rhs_env mb_opt_join_arity bndr rules' = map fstOf3 rules_w_uds rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds @@ -1815,7 +1841,11 @@ occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage. +-- Every call site links to its respective adjustRhsUsage call and vice versa. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustRhsUsage does the fixup. -- See Note [Adjusting right-hand sides] occAnalLam env (Lam bndr expr) @@ -1895,51 +1925,29 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity +occAnalRhs :: OccEnv -> Maybe JoinArity -> CoreExpr -- RHS -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs +-- ^ This function immediately does adjustRhsUsage after the call to occAnalLam. +-- It's useful for anonymous lambdas and unfoldings. +occAnalRhs !env mb_join_arity rhs + = WithUsageDetails (adjustRhsUsage mb_join_arity rhs' usage) rhs' where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs + WithUsageDetails usage rhs' = occAnalLam env rhs + occAnalUnfolding :: OccEnv - -> RecFlag -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding -> WithUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env mb_join_arity unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + (WithUsageDetails usage rhs') = occAnalRhs env mb_join_arity rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } @@ -1958,9 +1966,7 @@ occAnalUnfolding !env is_rec mb_join_arity unf where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter @@ -1989,8 +1995,8 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllNonTailIf (not exact_join) $ -- Nearly adjustRhsUsage, but we don't want to + markAllMany $ -- build `mkLams (map _ args) rhs` just for the call rhs_uds `delDetailsList` bndrs exact_join = exactJoin mb_join_arity args @@ -2208,10 +2214,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = occAnalRhs env Nothing expr -- mb_join_arity == Nothing <=> markAllNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2286,7 +2289,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- occAnalRhs env (Just 1) arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -3133,7 +3136,7 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal + -> CoreExpr -- Rhs, AFTER occAnalLam -> UsageDetails -- From body of lambda -> UsageDetails adjustRhsUsage mb_join_arity rhs usage @@ -3146,6 +3149,28 @@ adjustRhsUsage mb_join_arity rhs usage exact_join = exactJoin mb_join_arity bndrs (bndrs,_) = collectBinders rhs +-- | IF rhs becomes a join point, then `manifestJoinArity rhs` returns the +-- exact join arity of `rhs`. +manifestJoinArity :: CoreExpr -> JoinArity +manifestJoinArity rhs = length $ fst $ collectBinders rhs + +markNonRecJoinOneShots :: Maybe JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots Nothing rhs = rhs +markNonRecJoinOneShots (Just join_arity) rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) + exactJoin :: Maybe JoinArity -> [a] -> Bool exactJoin Nothing _ = False exactJoin (Just join_arity) args = args `lengthIs` join_arity @@ -3224,7 +3249,7 @@ tagRecBinders lvl body_uds details_s -- 2. Adjust usage details of each RHS, taking into account the -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds + rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds -- matching occAnalLam in makeNode | ND { nd_bndr = bndr, nd_uds = rhs_uds , nd_rhs = rhs } <- details_s ] ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -447,3 +447,6 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f59b85ed94f1519154280251b115e5afd6ad1e4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f59b85ed94f1519154280251b115e5afd6ad1e4 You're receiving 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 Nov 14 18:33:39 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 14 Nov 2022 13:33:39 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 31 commits: rts: Introduce getNumCapabilities Message-ID: <63728a03d9312_38f79f528dc8617c@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 5c940c72 by Ben Gamari at 2022-11-10T12:38:18-05:00 rts: Introduce getNumCapabilities - - - - - a7b46140 by Ben Gamari at 2022-11-10T12:38:18-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - e0815d4e by Ben Gamari at 2022-11-10T12:38:18-05:00 rts: Mark accesses to Capability.context_switch as relaxed Also Capability.interrupt. - - - - - f64d394d by Ben Gamari at 2022-11-10T12:38:19-05:00 Note - - - - - 0a103d2d by Ben Gamari at 2022-11-10T12:38:19-05:00 GET_INFO_ACQUIRE - - - - - 68accaf9 by Ben Gamari at 2022-11-10T12:38:19-05:00 fences - - - - - 04ffc731 by Ben Gamari at 2022-11-10T12:38:19-05:00 fence - - - - - 3b75c8bc by Ben Gamari at 2022-11-10T12:38:19-05:00 nonmoving: Silence benign data race warning from TSAN - - - - - b8b62d78 by Ben Gamari at 2022-11-10T12:38:19-05:00 Note - - - - - 9cfc8be3 by Ben Gamari at 2022-11-10T12:38:19-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - eab5f680 by Ben Gamari at 2022-11-10T13:17:18-05:00 fences - - - - - 3d5b43b9 by Ben Gamari at 2022-11-10T13:17:34-05:00 nonmoving: Fix segment list races - - - - - 1d2f83b3 by Ben Gamari at 2022-11-10T13:18:04-05:00 nonmoving: Use atomic when looking at bd->gen - - - - - 687e4ad5 by Ben Gamari at 2022-11-10T13:29:14-05:00 nonmoving: Eliminate race in bump_static_flag - - - - - 35bd443d by Ben Gamari at 2022-11-10T14:19:52-05:00 Note - - - - - c09d6f7b by Ben Gamari at 2022-11-10T14:25:41-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 2934537b by Ben Gamari at 2022-11-10T18:29:45-05:00 rts/Timer: Always use atomic operations As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded. - - - - - 166fd0ea by Ben Gamari at 2022-11-10T19:31:51-05:00 rts: Encapsulate recent_activity access - - - - - 38630874 by Ben Gamari at 2022-11-10T19:32:57-05:00 Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 8357f552 by Ben Gamari at 2022-11-10T19:34:12-05:00 n_capabilities - - - - - 6b0c2c2a by Ben Gamari at 2022-11-10T19:34:32-05:00 Updates - - - - - 4b648070 by Ben Gamari at 2022-11-10T19:34:40-05:00 Note - - - - - 50302656 by Ben Gamari at 2022-11-10T19:35:00-05:00 nonmoving: Collection running - - - - - 46525371 by Ben Gamari at 2022-11-10T19:47:41-05:00 Mark epoch - - - - - 8b0ba5f6 by Ben Gamari at 2022-11-10T19:47:53-05:00 Segment state - - - - - 767cd3ec by Ben Gamari at 2022-11-11T17:58:18-05:00 capabilities - - - - - 58790e40 by Ben Gamari at 2022-11-11T17:59:12-05:00 rts: Encapsulate sched_state - - - - - 5464034f by Ben Gamari at 2022-11-11T18:01:53-05:00 rts/Proftimer: Encapsulate - - - - - e7893bc1 by Ben Gamari at 2022-11-11T18:32:43-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - 0190fdf0 by Ben Gamari at 2022-11-14T13:31:06-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex. - - - - - 4ed4a512 by Ben Gamari at 2022-11-14T13:32:00-05:00 nonmoving: link_field - - - - - 30 changed files: - compiler/GHC/Utils/Logger.hs - hadrian/src/Flavour.hs - rts/Capability.c - rts/Capability.h - rts/HeapStackCheck.cmm - rts/Messages.h - rts/PrimOps.cmm - rts/Printer.c - rts/ProfHeap.c - rts/ProfilerReport.c - rts/ProfilerReportJson.c - rts/Profiling.c - rts/Proftimer.c - rts/RetainerProfile.c - rts/RtsAPI.c - rts/RtsStartup.c - rts/SMPClosureOps.h - rts/STM.c - rts/Schedule.c - rts/Schedule.h - rts/Stats.c - rts/StgMiscClosures.cmm - rts/Task.c - rts/Threads.c - rts/Timer.c - rts/TraverseHeap.c - rts/Updates.h - rts/eventlog/EventLog.c - rts/hooks/LongGCSync.c - rts/include/Cmm.h The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d883495cd2d6c5370d5db83171355be9dc17a629...4ed4a5128b29d82d4e1f0ce12a38f61b5e60d258 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d883495cd2d6c5370d5db83171355be9dc17a629...4ed4a5128b29d82d4e1f0ce12a38f61b5e60d258 You're receiving 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 Nov 14 18:38:14 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 13:38:14 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: testsuite: Add tests for T22347 Message-ID: <63728b164cc1d_38f79f52878938c6@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 4c4d9fbd by Matthew Pickering at 2022-11-14T13:38:03-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - eda1aa28 by Matthew Pickering at 2022-11-14T13:38:05-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 4 changed files: - testsuite/driver/testlib.py - + testsuite/tests/simplCore/should_compile/T22347.hs - + testsuite/tests/simplCore/should_compile/T22347a.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1247,14 +1247,23 @@ def do_test(name: TestName, dst_makefile.write_text(makefile, encoding='UTF-8') if opts.pre_cmd: + stdout_path = in_testdir(name, 'pre_cmd_stdout') + stderr_path = in_testdir(name, 'pre_cmd_stderr') exit_code = runCmd('cd "{0}" && {1}'.format(opts.testdir, override_options(opts.pre_cmd)), - stderr = subprocess.STDOUT, + stdout = stdout_path, + stderr = stderr_path, print_output = config.verbose >= 3) # If user used expect_broken then don't record failures of pre_cmd if exit_code != 0 and opts.expect not in ['fail']: framework_fail(name, way, 'pre_cmd failed: {0}'.format(exit_code)) if_verbose(1, '** pre_cmd was "{0}".'.format(override_options(opts.pre_cmd))) + stderr_contents = stderr_path.read_text(encoding='UTF-8', errors='replace') + stdout_contents = stdout_path.read_text(encoding='UTF-8', errors='replace') + if_verbose(1, 'stdout: {0}'.format(stdout_contents)) + if_verbose(1, 'stderr: {0}'.format(stderr_contents)) + # Don't continue and try to run the test if the pre_cmd fails. + return result = func(*[name,way] + args) ===================================== testsuite/tests/simplCore/should_compile/T22347.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module M where + +import Control.Monad.ST +import Data.Array.ST +import Data.Array.Unboxed + +bfs :: Array Int [Int] -> ST s (STArray s Int ()) +bfs g = do + vis :: STArray s Int () <- newArray (bounds g) () + ch :: STArray s Int () <- newArray (bounds g) () + let go [] = pure () :: ST s () + go q = do + flip mapM_ q $ \u -> do + readArray vis (head (g!u)) + readArray ch u + writeArray ch u () + go [] + go [] + pure ch ===================================== testsuite/tests/simplCore/should_compile/T22347a.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module M where + +import Control.Monad.ST +import Data.Array.ST +import Data.Array.Unboxed + +bfs :: Array Int [Int] -> ST s (STArray s Int ()) +bfs g = do + vis :: STArray s Int () <- newArray (bounds g) () + ch :: STArray s Int () <- newArray (bounds g) () + let go [] = pure () :: ST s () + go q = do + flip mapM_ q $ \u -> do + readArray vis (head (g!u)) + readArray ch u + writeArray ch u () + go [] + go [] + pure ch ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -437,6 +437,8 @@ test('T22097', [grep_errmsg(r'case.*wgoEven') ], multimod_compile, ['T22097', '- test('T13873', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-rules']) test('T22357', normal, compile, ['-O']) +test('T22347', normal, compile, ['-O -fno-full-laziness']) +test('T22347a', normal, compile, ['-O2 -fno-full-laziness']) # T17366: expecting to see a rule # Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f98c9f3781ebd64b84336ea90a4c5dbb7a66221...eda1aa2803a5aa16955cc28f71240792b6466e3f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4f98c9f3781ebd64b84336ea90a4c5dbb7a66221...eda1aa2803a5aa16955cc28f71240792b6466e3f You're receiving 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 Nov 14 18:57:50 2022 From: gitlab at gitlab.haskell.org (Krzysztof Gogolewski (@monoidal)) Date: Mon, 14 Nov 2022 13:57:50 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/misc-cleanup2 Message-ID: <63728fae570c0_38f79f528c81012ee@gitlab.mail> Krzysztof Gogolewski pushed new branch wip/misc-cleanup2 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/misc-cleanup2 You're receiving 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 Nov 14 21:48:25 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 16:48:25 -0500 Subject: [Git][ghc/ghc][master] testsuite: Add tests for T22347 Message-ID: <6372b7a9adf9a_38f79f528781237aa@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 3 changed files: - + testsuite/tests/simplCore/should_compile/T22347.hs - + testsuite/tests/simplCore/should_compile/T22347a.hs - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== testsuite/tests/simplCore/should_compile/T22347.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module M where + +import Control.Monad.ST +import Data.Array.ST +import Data.Array.Unboxed + +bfs :: Array Int [Int] -> ST s (STArray s Int ()) +bfs g = do + vis :: STArray s Int () <- newArray (bounds g) () + ch :: STArray s Int () <- newArray (bounds g) () + let go [] = pure () :: ST s () + go q = do + flip mapM_ q $ \u -> do + readArray vis (head (g!u)) + readArray ch u + writeArray ch u () + go [] + go [] + pure ch ===================================== testsuite/tests/simplCore/should_compile/T22347a.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module M where + +import Control.Monad.ST +import Data.Array.ST +import Data.Array.Unboxed + +bfs :: Array Int [Int] -> ST s (STArray s Int ()) +bfs g = do + vis :: STArray s Int () <- newArray (bounds g) () + ch :: STArray s Int () <- newArray (bounds g) () + let go [] = pure () :: ST s () + go q = do + flip mapM_ q $ \u -> do + readArray vis (head (g!u)) + readArray ch u + writeArray ch u () + go [] + go [] + pure ch ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -437,6 +437,8 @@ test('T22097', [grep_errmsg(r'case.*wgoEven') ], multimod_compile, ['T22097', '- test('T13873', [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-rules']) test('T22357', normal, compile, ['-O']) +test('T22347', normal, compile, ['-O -fno-full-laziness']) +test('T22347a', normal, compile, ['-O2 -fno-full-laziness']) # T17366: expecting to see a rule # Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d91db67928d1478589d98e349954800dc9a04a34 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d91db67928d1478589d98e349954800dc9a04a34 You're receiving 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 Nov 14 21:49:04 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 16:49:04 -0500 Subject: [Git][ghc/ghc][master] testsuite: Improve output from tests which have failing pre_cmd Message-ID: <6372b7d0638ff_38f79f52940129172@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 1 changed file: - testsuite/driver/testlib.py Changes: ===================================== testsuite/driver/testlib.py ===================================== @@ -1247,14 +1247,23 @@ def do_test(name: TestName, dst_makefile.write_text(makefile, encoding='UTF-8') if opts.pre_cmd: + stdout_path = in_testdir(name, 'pre_cmd_stdout') + stderr_path = in_testdir(name, 'pre_cmd_stderr') exit_code = runCmd('cd "{0}" && {1}'.format(opts.testdir, override_options(opts.pre_cmd)), - stderr = subprocess.STDOUT, + stdout = stdout_path, + stderr = stderr_path, print_output = config.verbose >= 3) # If user used expect_broken then don't record failures of pre_cmd if exit_code != 0 and opts.expect not in ['fail']: framework_fail(name, way, 'pre_cmd failed: {0}'.format(exit_code)) if_verbose(1, '** pre_cmd was "{0}".'.format(override_options(opts.pre_cmd))) + stderr_contents = stderr_path.read_text(encoding='UTF-8', errors='replace') + stdout_contents = stdout_path.read_text(encoding='UTF-8', errors='replace') + if_verbose(1, 'stdout: {0}'.format(stdout_contents)) + if_verbose(1, 'stderr: {0}'.format(stderr_contents)) + # Don't continue and try to run the test if the pre_cmd fails. + return result = func(*[name,way] + args) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f6c576b0b9b82acf23c51ae8cb3c6e5bde61ab4 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8f6c576b0b9b82acf23c51ae8cb3c6e5bde61ab4 You're receiving 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 Nov 14 22:19:39 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 17:19:39 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: testsuite: Add tests for T22347 Message-ID: <6372befbf394a_38f79f528781319bb@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 16ca92cf by Madeline Haraj at 2022-11-14T17:19:30-05:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - f5f850b9 by Andreas Klebinger at 2022-11-14T17:19:31-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - dbefb3f6 by Krzysztof Gogolewski at 2022-11-14T17:19:32-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 30 changed files: - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Stg/Subst.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/exts/pragmas.rst - testsuite/driver/testlib.py - testsuite/tests/ghci/should_run/T18594.script - testsuite/tests/ghci/should_run/T18594.stdout - + testsuite/tests/simplCore/should_compile/T22347.hs - + testsuite/tests/simplCore/should_compile/T22347a.hs - testsuite/tests/simplCore/should_compile/all.T - + testsuite/tests/unboxedsums/Makefile - testsuite/tests/unboxedsums/all.T - + testsuite/tests/unboxedsums/unpack_sums_1.hs - + testsuite/tests/unboxedsums/unpack_sums_1.stdout - + testsuite/tests/unboxedsums/unpack_sums_2.hs - + testsuite/tests/unboxedsums/unpack_sums_3.hs - + testsuite/tests/unboxedsums/unpack_sums_4.hs - + testsuite/tests/unboxedsums/unpack_sums_4.stdout - + testsuite/tests/unboxedsums/unpack_sums_5.hs - + testsuite/tests/unboxedsums/unpack_sums_5.stderr - + testsuite/tests/unboxedsums/unpack_sums_6.hs - + testsuite/tests/unboxedsums/unpack_sums_6.stdout - + testsuite/tests/unboxedsums/unpack_sums_7.hs - + testsuite/tests/unboxedsums/unpack_sums_7.stderr - + testsuite/tests/unboxedsums/unpack_sums_8.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eda1aa2803a5aa16955cc28f71240792b6466e3f...dbefb3f64f262987e9a77432fa946198f221d2ca -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/eda1aa2803a5aa16955cc28f71240792b6466e3f...dbefb3f64f262987e9a77432fa946198f221d2ca You're receiving 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 Nov 15 01:20:01 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 20:20:01 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Implement UNPACK support for sum types. Message-ID: <6372e941ab73f_38f79f528dc17865c@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 0da5234c by Andreas Klebinger at 2022-11-14T20:19:48-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 612cc569 by Krzysztof Gogolewski at 2022-11-14T20:19:49-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 28 changed files: - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Stg/Subst.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/exts/pragmas.rst - testsuite/tests/ghci/should_run/T18594.script - testsuite/tests/ghci/should_run/T18594.stdout - + testsuite/tests/unboxedsums/Makefile - testsuite/tests/unboxedsums/all.T - + testsuite/tests/unboxedsums/unpack_sums_1.hs - + testsuite/tests/unboxedsums/unpack_sums_1.stdout - + testsuite/tests/unboxedsums/unpack_sums_2.hs - + testsuite/tests/unboxedsums/unpack_sums_3.hs - + testsuite/tests/unboxedsums/unpack_sums_4.hs - + testsuite/tests/unboxedsums/unpack_sums_4.stdout - + testsuite/tests/unboxedsums/unpack_sums_5.hs - + testsuite/tests/unboxedsums/unpack_sums_5.stderr - + testsuite/tests/unboxedsums/unpack_sums_6.hs - + testsuite/tests/unboxedsums/unpack_sums_6.stdout - + testsuite/tests/unboxedsums/unpack_sums_7.hs - + testsuite/tests/unboxedsums/unpack_sums_7.stderr - + testsuite/tests/unboxedsums/unpack_sums_8.hs - + testsuite/tests/unboxedsums/unpack_sums_8.stdout - + testsuite/tests/unboxedsums/unpack_sums_9.hs Changes: ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -23,7 +23,7 @@ module GHC.Core.Make ( FloatBind(..), wrapFloat, wrapFloats, floatBindings, -- * Constructing small tuples - mkCoreVarTupTy, mkCoreTup, mkCoreUnboxedTuple, mkCoreUbxSum, + mkCoreVarTupTy, mkCoreTup, mkCoreUnboxedTuple, mkCoreUnboxedSum, mkCoreTupBoxity, unitExpr, -- * Constructing big tuples @@ -405,8 +405,8 @@ mkCoreTup cs = mkCoreBoxedTuple cs -- non-1-tuples are uniform -- | Build an unboxed sum. -- -- Alternative number ("alt") starts from 1. -mkCoreUbxSum :: Int -> Int -> [Type] -> CoreExpr -> CoreExpr -mkCoreUbxSum arity alt tys exp +mkCoreUnboxedSum :: Int -> Int -> [Type] -> CoreExpr -> CoreExpr +mkCoreUnboxedSum arity alt tys exp = assert (length tys == arity) $ assert (alt <= arity) $ mkCoreConApps (sumDataCon alt arity) ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2097,7 +2097,7 @@ builtinBignumRules = x <- isNaturalLiteral a0 y <- isNaturalLiteral a1 -- return an unboxed sum: (# (# #) | Natural #) - let ret n v = pure $ mkCoreUbxSum 2 n [unboxedUnitTy,naturalTy] v + let ret n v = pure $ mkCoreUnboxedSum 2 n [unboxedUnitTy,naturalTy] v platform <- getPlatform if x < y then ret 1 unboxedUnitExpr ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -112,6 +112,17 @@ The goal of this pass is to prepare for code generation. and doing so would be tiresome because then we'd need to substitute in types and coercions. + We need to clone ids for two reasons: + + Things associated with labels in the final code must be truly unique in + order to avoid labels being shadowed in the final output. + + Even binders without info tables like function arguments or alternative + bound binders must be unique at least in their type/unique combination. + We only emit a single declaration for each binder when compiling to C + so if binders are not unique we would either get duplicate declarations + or misstyped variables. The later happend in #22402. + + We heavily use unique-keyed maps in the backend which can go wrong when + ids with the same unique are meant to represent the same variable. + 7. Give each dynamic CCall occurrence a fresh unique; this is rather like the cloning step above. ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -369,7 +369,7 @@ dsExpr (ExplicitTuple _ tup_args boxity) -- See Note [Don't flatten tuples from HsSyn] in GHC.Core.Make dsExpr (ExplicitSum types alt arity expr) - = mkCoreUbxSum arity alt types <$> dsLExpr expr + = mkCoreUnboxedSum arity alt types <$> dsLExpr expr dsExpr (HsPragE _ prag expr) = ds_prag_expr prag expr ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -44,7 +44,8 @@ module GHC.Iface.Syntax ( import GHC.Prelude -import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey ) +import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey, + constraintKindTyConKey ) import GHC.Types.Unique ( hasKey ) import GHC.Iface.Type import GHC.Iface.Recomp.Binary @@ -988,7 +989,8 @@ pprIfaceDecl ss (IfaceSynonym { ifName = tc -- See Note [Printing type abbreviations] in GHC.Iface.Type ppr_tau | tc `hasKey` liftedTypeKindTyConKey || - tc `hasKey` unrestrictedFunTyConKey + tc `hasKey` unrestrictedFunTyConKey || + tc `hasKey` constraintKindTyConKey = updSDocContext (\ctx -> ctx { sdocPrintTypeAbbreviations = False }) $ ppr tau | otherwise = ppr tau ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -846,7 +846,7 @@ Note [Printing type abbreviations] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Normally, we pretty-print `TYPE 'LiftedRep` as `Type` (or `*`) - `CONSTRAINT 'LiftedRep` as `Constraint` (or `*`) + `CONSTRAINT 'LiftedRep` as `Constraint` `FUN 'Many` as `(->)`. This way, error messages don't refer to representation polymorphism or linearity if it is not necessary. Normally we'd would represent @@ -856,14 +856,16 @@ command we specifically expand synonyms (see GHC.Tc.Module.tcRnExpr). So here in the pretty-printing we effectively collapse back Type and Constraint to their synonym forms. A bit confusing! -However, when printing the definition of Type or (->) with :info, +However, when printing the definition of Type, Constraint or (->) with :info, this would give confusing output: `type (->) = (->)` (#18594). Solution: detect when we are in :info and disable displaying the synonym with the SDoc option sdocPrintTypeAbbreviations. +If you are creating a similar synonym, make sure it is listed in pprIfaceDecl, +see reference to this Note. If there will be a need, in the future we could expose it as a flag --fprint-type-abbreviations or even two separate flags controlling -TYPE 'LiftedRep and FUN 'Many. +-fprint-type-abbreviations or even three separate flags controlling +TYPE 'LiftedRep, CONSTRAINT 'LiftedRep and FUN 'Many. -} -- | Do we want to suppress kind annotations on binders? ===================================== compiler/GHC/Stg/Subst.hs ===================================== @@ -12,6 +12,13 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Panic +-- TODO: This code might make folly of the work done in CorePrep where +-- we clone local ids in order to ensure *all* local binders are unique. +-- It's my understanding that here we use "the rapier"/uniqAway which makes up +-- uniques based on the ids in scope. Which can give the same unique to different +-- binders as long as they are in different scopes. A guarantee which isn't +-- strong enough for code generation in general. See Note [CorePrep Overview]. + -- | A renaming substitution from 'Id's to 'Id's. Like 'RnEnv2', but not -- maintaining pairs of substitutions. Like 'GHC.Core.Subst.Subst', but -- with the domain being 'Id's instead of entire 'CoreExpr'. ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -56,7 +56,7 @@ import GHC.Core.Coercion import GHC.Core.Reduction import GHC.Core.Make import GHC.Core.FVs ( mkRuleInfo ) -import GHC.Core.Utils ( exprType, mkCast, mkDefaultCase ) +import GHC.Core.Utils ( exprType, mkCast, mkDefaultCase, coreAltsType ) import GHC.Core.Unfold.Make import GHC.Core.SimpleOpt import GHC.Core.TyCon @@ -85,6 +85,7 @@ import GHC.Utils.Panic.Plain import GHC.Data.FastString import GHC.Data.List.SetOps +import Data.List ( zipWith4 ) {- ************************************************************************ @@ -1028,14 +1029,8 @@ dataConSrcToImplBang bang_opts fam_envs arg_ty arg_ty' = case mb_co of { Just redn -> scaledSet arg_ty (reductionReducedType redn) ; Nothing -> arg_ty } - , isUnpackableType bang_opts fam_envs (scaledThing arg_ty') - , (rep_tys, _) <- dataConArgUnpack arg_ty' - , case unpk_prag of - NoSrcUnpack -> - bang_opt_unbox_strict bang_opts - || (bang_opt_unbox_small bang_opts - && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] - srcUnpack -> isSrcUnpacked srcUnpack + , all (not . isNewTyCon . fst) (splitTyConApp_maybe $ scaledThing arg_ty') + , shouldUnpackTy bang_opts unpk_prag fam_envs arg_ty' = case mb_co of Nothing -> HsUnpack Nothing Just redn -> HsUnpack (Just $ reductionCoercion redn) @@ -1043,7 +1038,6 @@ dataConSrcToImplBang bang_opts fam_envs arg_ty | otherwise -- Record the strict-but-no-unpack decision = HsStrict - -- | Wrappers/Workers and representation following Unpack/Strictness -- decisions dataConArgRep @@ -1059,8 +1053,7 @@ dataConArgRep arg_ty HsStrict = ([(arg_ty, MarkedStrict)], (seqUnboxer, unitBoxer)) dataConArgRep arg_ty (HsUnpack Nothing) - | (rep_tys, wrappers) <- dataConArgUnpack arg_ty - = (rep_tys, wrappers) + = dataConArgUnpack arg_ty dataConArgRep (Scaled w _) (HsUnpack (Just co)) | let co_rep_ty = coercionRKind co @@ -1097,50 +1090,231 @@ unitBoxer :: Boxer unitBoxer = UnitBox ------------------------- + +{- Note [UNPACK for sum types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we have a data type D, for example: + data D = D1 [Int] [Bool] + | D2 + +and another data type which unpacks a field of type D: + data U a = MkU {-# UNPACK #-} !D + {-# UNPACK #-} !(a,a) + {-# UNPACK #-} !D + +Then the wrapper and worker for MkU have these types + + -- Wrapper + $WMkU :: D -> (a,a) -> D -> U a + + -- Worker + MkU :: (# (# [Int],[Bool] #) | (# #) #) + -> a + -> a + -> (# (# [Int],[Bool] #) | (# #) #) + -> U a + +For each unpacked /sum/-type argument, the worker gets one argument. +But for each unpacked /product/-type argument, the worker gets N +arguments (here two). + +Why treat them differently? See Note [Why sums and products are treated differently]. + +The wrapper $WMkU looks like this: + + $WMkU :: D -> (a,a) -> D -> U a + $WMkU x1 y x2 + = case (case x1 of { + D1 a b -> (# (# a,b #) | #) + D2 -> (# | (# #) #) }) of { x1_ubx -> + case y of { (y1, y2) -> + case (case x2 of { + D1 a b -> (# (# a,b #) | #) + D2 -> (# | (# #) #) }) of { x2_ubx -> + MkU x1_ubx y1 y2 x2_ubx + +Notice the nested case needed for sums. + +This different treatment for sums and product is implemented in +dataConArgUnpackSum and dataConArgUnpackProduct respectively. + +Note [Why sums and products are treated differently] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Can we handle sums like products, with each wrapper argument +occupying multiple argument slots in the worker? No: for a sum +type the number of argument slots varies, and that's exactly what +unboxed sums are designed for. + +Can we handle products like sums, with each wrapper argument occupying +exactly one argument slot (and unboxed tuple) in the worker? Yes, +we could. For example + data P = MkP {-# UNPACK #-} !Q + data Q = MkQ {-# NOUNPACK #-} !Int + {-# NOUNPACK #-} Int + +Currently could unpack P thus, taking two slots in the worker + $WMkP :: Q -> P + $WMkP x = case x of { MkQ a b -> MkP a b } + MkP :: Int -> Int -> P -- Worker + +We could instead do this (uniformly with sums) + + $WMkP1 :: Q -> P + $WMkP1 x = case (case x of { MkQ a b -> (# a, b #) }) of ubx_x + MkP1 ubx_x + MkP1 :: (# Int, Int #) -> P -- Worker + +The representation of MkP and MkP1 would be identical (a constructor +with two fields). + +BUT, with MkP (as with every data constructor) we record its argument +strictness as a bit-vector, actually [StrictnessMark] + MkP strictness: SL +This information is used in Core to record which fields are sure to +be evaluated. (Look for calls to dataConRepStrictness.) E.g. in Core + case v of MkP x y -> ........ + +Alas, with MkP1 this information is hidden by the unboxed pair, +In Core there will be an auxiliary case expression to take apart the pair: + case v of MkP1 xy -> case xy of (# x,y #) -> ... +And now we have no easy way to know that x is evaluated in the "...". + +Fixing this might be possible, but it'd be tricky. So we avoid the +problem entirely by treating sums and products differently here. +-} + dataConArgUnpack :: Scaled Type -> ( [(Scaled Type, StrictnessMark)] -- Rep types , (Unboxer, Boxer) ) - -dataConArgUnpack (Scaled arg_mult arg_ty) +dataConArgUnpack scaledTy@(Scaled _ arg_ty) | Just (tc, tc_args) <- splitTyConApp_maybe arg_ty - , Just con <- tyConSingleAlgDataCon_maybe tc - -- NB: check for an *algebraic* data type - -- A recursive newtype might mean that - -- 'arg_ty' is a newtype - , let rep_tys = map (scaleScaled arg_mult) $ dataConInstArgTys con tc_args - = assert (null (dataConExTyCoVars con)) - -- Note [Unpacking GADTs and existentials] - ( rep_tys `zip` dataConRepStrictness con - ,( \ arg_id -> - do { rep_ids <- mapM (newLocal (fsLit "unbx")) rep_tys - ; let r_mult = idMult arg_id - ; let rep_ids' = map (scaleIdBy r_mult) rep_ids - ; let unbox_fn body - = mkSingleAltCase (Var arg_id) arg_id - (DataAlt con) rep_ids' body - ; return (rep_ids, unbox_fn) } - , Boxer $ \ subst -> - do { rep_ids <- mapM (newLocal (fsLit "bx") . TcType.substScaledTyUnchecked subst) rep_tys - ; return (rep_ids, Var (dataConWorkId con) - `mkTyApps` (substTysUnchecked subst tc_args) - `mkVarApps` rep_ids ) } ) ) + = assert (not (isNewTyCon tc)) $ + case tyConDataCons tc of + [con] -> dataConArgUnpackProduct scaledTy tc_args con + cons -> dataConArgUnpackSum scaledTy tc_args cons | otherwise = pprPanic "dataConArgUnpack" (ppr arg_ty) -- An interface file specified Unpacked, but we couldn't unpack it -isUnpackableType :: BangOpts -> FamInstEnvs -> Type -> Bool --- True if we can unpack the UNPACK the argument type +dataConArgUnpackProduct + :: Scaled Type + -> [Type] + -> DataCon + -> ( [(Scaled Type, StrictnessMark)] -- Rep types + , (Unboxer, Boxer) ) +dataConArgUnpackProduct (Scaled arg_mult _) tc_args con = + assert (null (dataConExTyCoVars con)) $ + -- Note [Unpacking GADTs and existentials] + let rep_tys = map (scaleScaled arg_mult) $ dataConInstArgTys con tc_args + in ( rep_tys `zip` dataConRepStrictness con + , ( \ arg_id -> + do { rep_ids <- mapM (newLocal (fsLit "unbx")) rep_tys + ; let r_mult = idMult arg_id + ; let rep_ids' = map (scaleIdBy r_mult) rep_ids + ; let unbox_fn body + = mkSingleAltCase (Var arg_id) arg_id + (DataAlt con) rep_ids' body + ; return (rep_ids, unbox_fn) } + , Boxer $ \ subst -> + do { rep_ids <- mapM (newLocal (fsLit "bx") . TcType.substScaledTyUnchecked subst) rep_tys + ; return (rep_ids, Var (dataConWorkId con) + `mkTyApps` (substTysUnchecked subst tc_args) + `mkVarApps` rep_ids ) } ) ) + +dataConArgUnpackSum + :: Scaled Type + -> [Type] + -> [DataCon] + -> ( [(Scaled Type, StrictnessMark)] -- Rep types + , (Unboxer, Boxer) ) +dataConArgUnpackSum (Scaled arg_mult arg_ty) tc_args cons = + ( [ (sum_ty, MarkedStrict) ] -- The idea: Unpacked variant will + -- be one field only, and the type of the + -- field will be an unboxed sum. + , ( unboxer, boxer ) ) + where + !ubx_sum_arity = length cons + src_tys = map (\con -> map scaledThing $ dataConInstArgTys con tc_args) cons + sum_alt_tys = map mkUbxSumAltTy src_tys + sum_ty_unscaled = mkSumTy sum_alt_tys + sum_ty = Scaled arg_mult sum_ty_unscaled + newLocal' fs = newLocal fs . Scaled arg_mult + + -- See Note [UNPACK for sum types] + unboxer :: Unboxer + unboxer arg_id = do + con_arg_binders <- mapM (mapM (newLocal' (fsLit "unbx"))) src_tys + ubx_sum_bndr <- newLocal (fsLit "unbx") sum_ty + + let + mk_ubx_sum_alt :: Int -> DataCon -> [Var] -> CoreAlt + mk_ubx_sum_alt alt con [bndr] = Alt (DataAlt con) [bndr] + (mkCoreUnboxedSum ubx_sum_arity alt sum_alt_tys (Var bndr)) + + mk_ubx_sum_alt alt con bndrs = + let tuple = mkCoreUnboxedTuple (map Var bndrs) + in Alt (DataAlt con) bndrs (mkCoreUnboxedSum ubx_sum_arity alt sum_alt_tys tuple ) + + ubx_sum :: CoreExpr + ubx_sum = + let alts = zipWith3 mk_ubx_sum_alt [ 1 .. ] cons con_arg_binders + in Case (Var arg_id) arg_id (coreAltsType alts) alts + + unbox_fn :: CoreExpr -> CoreExpr + unbox_fn body = + mkSingleAltCase ubx_sum ubx_sum_bndr DEFAULT [] body + + return ([ubx_sum_bndr], unbox_fn) + + boxer :: Boxer + boxer = Boxer $ \ subst -> do + unboxed_field_id <- newLocal' (fsLit "bx") (TcType.substTy subst sum_ty_unscaled) + tuple_bndrs <- mapM (newLocal' (fsLit "bx") . TcType.substTy subst) sum_alt_tys + + let tc_args' = substTys subst tc_args + arg_ty' = substTy subst arg_ty + + con_arg_binders <- + mapM (mapM (newLocal' (fsLit "bx")) . map (TcType.substTy subst)) src_tys + + let mk_sum_alt :: Int -> DataCon -> Var -> [Var] -> CoreAlt + mk_sum_alt alt con _ [datacon_bndr] = + ( Alt (DataAlt (sumDataCon alt ubx_sum_arity)) [datacon_bndr] + (Var (dataConWorkId con) `mkTyApps` tc_args' + `mkVarApps` [datacon_bndr] )) + + mk_sum_alt alt con tuple_bndr datacon_bndrs = + ( Alt (DataAlt (sumDataCon alt ubx_sum_arity)) [tuple_bndr] ( + Case (Var tuple_bndr) tuple_bndr arg_ty' + [ Alt (DataAlt (tupleDataCon Unboxed (length datacon_bndrs))) datacon_bndrs + (Var (dataConWorkId con) `mkTyApps` tc_args' + `mkVarApps` datacon_bndrs ) ] )) + + return ( [unboxed_field_id], + Case (Var unboxed_field_id) unboxed_field_id arg_ty' + (zipWith4 mk_sum_alt [ 1 .. ] cons tuple_bndrs con_arg_binders) ) + +-- | Every alternative of an unboxed sum has exactly one field, and we use +-- unboxed tuples when we need more than one field. This generates an unboxed +-- tuple when necessary, to be used in unboxed sum alts. +mkUbxSumAltTy :: [Type] -> Type +mkUbxSumAltTy [ty] = ty +mkUbxSumAltTy tys = mkTupleTy Unboxed tys + +shouldUnpackTy :: BangOpts -> SrcUnpackedness -> FamInstEnvs -> Scaled Type -> Bool +-- True if we ought to unpack the UNPACK the argument type -- See Note [Recursive unboxing] -- We look "deeply" inside rather than relying on the DataCons -- we encounter on the way, because otherwise we might well -- end up relying on ourselves! -isUnpackableType bang_opts fam_envs ty - | Just data_con <- unpackable_type ty - = ok_con_args emptyNameSet data_con +shouldUnpackTy bang_opts prag fam_envs ty + | Just data_cons <- unpackable_type_datacons (scaledThing ty) + = all (ok_con_args emptyNameSet) data_cons && should_unpack data_cons | otherwise = False where + ok_con_args :: NameSet -> DataCon -> Bool ok_con_args dcs con | dc_name `elemNameSet` dcs = False @@ -1153,17 +1327,20 @@ isUnpackableType bang_opts fam_envs ty dc_name = getName con dcs' = dcs `extendNameSet` dc_name + ok_arg :: NameSet -> (Scaled Type, HsSrcBang) -> Bool ok_arg dcs (Scaled _ ty, bang) = not (attempt_unpack bang) || ok_ty dcs norm_ty where norm_ty = topNormaliseType fam_envs ty + ok_ty :: NameSet -> Type -> Bool ok_ty dcs ty - | Just data_con <- unpackable_type ty - = ok_con_args dcs data_con + | Just data_cons <- unpackable_type_datacons ty + = all (ok_con_args dcs) data_cons | otherwise = True -- NB True here, in contrast to False at top level + attempt_unpack :: HsSrcBang -> Bool attempt_unpack (HsSrcBang _ SrcUnpack NoSrcStrict) = bang_opt_strict_data bang_opts attempt_unpack (HsSrcBang _ SrcUnpack SrcStrict) @@ -1174,16 +1351,40 @@ isUnpackableType bang_opts fam_envs ty = bang_opt_strict_data bang_opts -- Be conservative attempt_unpack _ = False - unpackable_type :: Type -> Maybe DataCon - -- Works just on a single level - unpackable_type ty - | Just (tc, _) <- splitTyConApp_maybe ty - , Just data_con <- tyConSingleAlgDataCon_maybe tc - , null (dataConExTyCoVars data_con) - -- See Note [Unpacking GADTs and existentials] - = Just data_con - | otherwise - = Nothing + -- Determine whether we ought to unpack a field based on user annotations if present and heuristics if not. + should_unpack data_cons = + case prag of + SrcNoUnpack -> False -- {-# NOUNPACK #-} + SrcUnpack -> True -- {-# UNPACK #-} + NoSrcUnpack -- No explicit unpack pragma, so use heuristics + | (_:_:_) <- data_cons + -> False -- don't unpack sum types automatically, but they can be unpacked with an explicit source UNPACK. + | otherwise + -> bang_opt_unbox_strict bang_opts + || (bang_opt_unbox_small bang_opts + && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] + where (rep_tys, _) = dataConArgUnpack ty + + +-- Given a type already assumed to have been normalized by topNormaliseType, +-- unpackable_type_datacons ty = Just datacons +-- iff ty is of the form +-- T ty1 .. tyn +-- and T is an algebraic data type (not newtype), in which no data +-- constructors have existentials, and datacons is the list of data +-- constructors of T. +unpackable_type_datacons :: Type -> Maybe [DataCon] +unpackable_type_datacons ty + | Just (tc, _) <- splitTyConApp_maybe ty + , not (isNewTyCon tc) + -- Even though `ty` has been normalised, it could still + -- be a /recursive/ newtype, so we must check for that + , Just cons <- tyConDataCons_maybe tc + , not (null cons) + , all (null . dataConExTyCoVars) cons + = Just cons -- See Note [Unpacking GADTs and existentials] + | otherwise + = Nothing {- Note [Unpacking GADTs and existentials] ===================================== docs/users_guide/exts/pragmas.rst ===================================== @@ -845,8 +845,14 @@ flattening the pair. Multi-level unpacking is also supported: :: will store two unboxed ``Int#``\ s directly in the ``T`` constructor. The unpacker can see through newtypes, too. +Since 9.6.1, data types with multiple constructors can also be unpacked, effectively +transforming the field into an unboxed sum of the unpackings of each +constructor (see :extension:`UnboxedSums`). + See also the :ghc-flag:`-funbox-strict-fields` flag, which essentially has the -effect of adding ``{-# UNPACK #-}`` to every strict constructor field. +effect of adding ``{-# UNPACK #-}`` to every strict constructor field which is +of a single-constructor data type. Sum types won't be unpacked automatically +by this though, only with the explicit pragma. .. [1] In fact, :pragma:`UNPACK` has no effect without :ghc-flag:`-O`, for technical ===================================== testsuite/tests/ghci/should_run/T18594.script ===================================== @@ -1,5 +1,6 @@ :m GHC.Types :i (->) +:i Constraint :set -XStarIsType :i Type :set -XNoStarIsType ===================================== testsuite/tests/ghci/should_run/T18594.stdout ===================================== @@ -7,6 +7,9 @@ instance Semigroup b => Semigroup (a -> b) -- Defined in ‘GHC.Base’ instance Applicative ((->) r) -- Defined in ‘GHC.Base’ instance Functor ((->) r) -- Defined in ‘GHC.Base’ instance Monad ((->) r) -- Defined in ‘GHC.Base’ +type Constraint :: * +type Constraint = CONSTRAINT LiftedRep + -- Defined in ‘GHC.Types’ type Type :: * type Type = TYPE LiftedRep -- Defined in ‘GHC.Types’ ===================================== testsuite/tests/unboxedsums/Makefile ===================================== @@ -0,0 +1,11 @@ +TOP=../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +.PHONY: unpack_sums_7 + +unpack_sums_7: + $(RM) -f unpack_sums_7.o unpack_sums_7.hi + '$(TEST_HC)' $(TEST_HC_OPTS) -c unpack_sums_7.hs -O -dsuppress-all -ddump-simpl | grep -q '\(# |_ #\)' + # This is a test to check for the presence of an unboxed sum in the core for a program using UNPACK + # on a sum type which is evidence that the field has been correctly unpacked. ===================================== testsuite/tests/unboxedsums/all.T ===================================== @@ -40,3 +40,18 @@ test('T22187',[only_ways(llvm_ways)],compile,['']) test('T22187_run',[only_ways(llvm_ways) ,unless(arch('x86_64'), skip)],compile_and_run,['']) +test('unpack_sums_1', normal, compile_and_run, ['-O']) +test('unpack_sums_2', normal, compile, ['-O']) +test('unpack_sums_3', normal, compile_and_run, ['-O']) +test('unpack_sums_4', normal, compile_and_run, ['-O']) +test('unpack_sums_5', normal, compile, ['-O']) +test('unpack_sums_6', normal, compile_and_run, ['-O']) +test('unpack_sums_7', [], makefile_test, []) +test('unpack_sums_8', normal, compile_and_run, [""]) +test('unpack_sums_9', normal, compile, [""]) + +# TODO: Need to run this in --slow mode only +# test('sum_api_annots', +# [only_ways(['normal']), +# extra_files([ "unboxedsums" + str(i) + ".hs" for i in range(1, 12) ])], +# makefile_test, []) ===================================== testsuite/tests/unboxedsums/unpack_sums_1.hs ===================================== @@ -0,0 +1,22 @@ +module Main where + +data T = T1 Int | T2 String + deriving (Show, Eq, Ord, Read) + +data T' = T' {-# UNPACK #-} !T + deriving (Show, Eq, Ord, Read) + +t1, t2 :: T +t1 = T1 123 +t2 = T2 "OK" +{-# NOINLINE t1 #-} +{-# NOINLINE t2 #-} + +t'1, t'2 :: T' +t'1 = T' t1 +t'2 = T' t2 + +main :: IO () +main = do + print t'1 + print t'2 ===================================== testsuite/tests/unboxedsums/unpack_sums_1.stdout ===================================== @@ -0,0 +1,2 @@ +T' (T1 123) +T' (T2 "OK") ===================================== testsuite/tests/unboxedsums/unpack_sums_2.hs ===================================== @@ -0,0 +1,9 @@ +module Lib where + +data Number = F {-# UNPACK #-} !Float | I {-# UNPACK #-} !Int + +-- This UNPACK was causing a panic: +-- ghc-stage1: panic! (the 'impossible' happened) +-- (GHC version 8.1.20160722 for x86_64-unknown-linux): +-- LocalReg's live-in to graph crG {_grh::F32, _gri::I64} +data T = T {-# UNPACK #-} !Number ===================================== testsuite/tests/unboxedsums/unpack_sums_3.hs ===================================== @@ -0,0 +1,14 @@ +-- Check that we can unpack a strict Maybe Int field. +import System.Exit + +data T = MkT {-# UNPACK #-} !(Maybe Int) + +xs = Nothing : [Just n | n <- [1..10]] + +ts = map MkT xs + +main = if xs == map (\(MkT m) -> m) ts + then return () + else do + putStrLn "Error in packing and unpacking!" + exitFailure ===================================== testsuite/tests/unboxedsums/unpack_sums_4.hs ===================================== @@ -0,0 +1,8 @@ +-- Check that nothing goes wrong with UNPACK in recursive case. +data T = MkT {-# UNPACK #-} !(Maybe T) + deriving Show + +t :: T +t = MkT (Just t) + +main = print $ take 100 (show t) ===================================== testsuite/tests/unboxedsums/unpack_sums_4.stdout ===================================== @@ -0,0 +1 @@ +"MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (M" ===================================== testsuite/tests/unboxedsums/unpack_sums_5.hs ===================================== @@ -0,0 +1,11 @@ +module UnpackSumsFive where +-- Check that failure to unpack is warned about. + +data SMaybeT = NoT | JustT {-# UNPACK #-} !T + deriving Show + +data T = MkT {-# UNPACK #-} !SMaybeT + deriving Show + +t :: T +t = MkT (JustT (MkT (JustT (MkT NoT)))) ===================================== testsuite/tests/unboxedsums/unpack_sums_5.stderr ===================================== @@ -0,0 +1,10 @@ + +unpack_sums_5.hs:4:22: warning: + • Ignoring unusable UNPACK pragma on the first argument of ‘JustT’ + • In the definition of data constructor ‘JustT’ + In the data type declaration for ‘SMaybeT’ + +unpack_sums_5.hs:7:10: warning: + • Ignoring unusable UNPACK pragma on the first argument of ‘MkT’ + • In the definition of data constructor ‘MkT’ + In the data type declaration for ‘T’ ===================================== testsuite/tests/unboxedsums/unpack_sums_6.hs ===================================== @@ -0,0 +1,55 @@ +{-# LANGUAGE BangPatterns #-} +-- This perhaps overly simple test check if code involving +-- unbacked sums is faster than non-unpacked ones which at +-- least in this case we expect to be the case. +-- However this test isn't quite robust, should it fail in +-- the future we might want to redo it or mark it fragile. +import Data.Time.Clock + +import Data.Int +import System.Exit + +data A = ANothing | AJust {-# UNPACK #-} !Int64 +data B = BNothing | BJust {-# UNPACK #-} !A +data C = CNothing | CJust {-# UNPACK #-} !B +data D = DNothing | DJust {-# UNPACK #-} !C + +data Unlayered = Unlayered {-# UNPACK #-} !D + +data Layered = Layered !(Maybe (Maybe (Maybe (Maybe Int64)))) + +makeUnlayered :: Int64 -> [Unlayered] +makeUnlayered n = Unlayered . DJust . CJust . BJust . AJust <$> [1..n] + +makeLayered :: Int64 -> [Layered] +makeLayered n = Layered . Just . Just . Just . Just <$> [1..n] + +sumUnlayered :: [Unlayered] -> Int64 +sumUnlayered = go 0 + where + go !n [] = n + go !n (w:ws) = case w of + Unlayered (DJust (CJust (BJust (AJust i)))) -> go (n+i) ws + Unlayered _ -> go n ws + +sumLayered :: [Layered] -> Int64 +sumLayered = go 0 + where + go !n [] = n + go !n (w:ws) = case w of + Layered (Just (Just (Just (Just i)))) -> go (n+i) ws + Layered _ -> go n ws + +main :: IO () +main = do + let magnitude = 10000000 + unlayeredInts = makeUnlayered magnitude + layeredInts = makeLayered magnitude + now <- getCurrentTime + print $ sumUnlayered unlayeredInts + unlayeredTime <- getCurrentTime + print $ sumLayered layeredInts + layeredTime <- getCurrentTime + case (unlayeredTime `diffUTCTime` now) < (layeredTime `diffUTCTime` unlayeredTime) of + True -> exitSuccess + False -> exitFailure ===================================== testsuite/tests/unboxedsums/unpack_sums_6.stdout ===================================== @@ -0,0 +1,2 @@ +50000005000000 +50000005000000 ===================================== testsuite/tests/unboxedsums/unpack_sums_7.hs ===================================== @@ -0,0 +1,10 @@ +-- NB: Compiling this module throws an exception involving Weak# at the end of compilation. +-- This is unrelated to unpacked sums but we need to include the error in the expected output for the test to pass. + +module UnpackedSums7 where + +data T = MkT {-# UNPACK #-} !MI + +data MI = NoI | JI Int + +t = MkT (JI 5) ===================================== testsuite/tests/unboxedsums/unpack_sums_7.stderr ===================================== @@ -0,0 +1,2 @@ +Exception during Weak# finalization (ignored): : hFlush: resource vanished (Broken pipe) +Exception during Weak# finalization (ignored): : hFlush: resource vanished (Broken pipe) ===================================== testsuite/tests/unboxedsums/unpack_sums_8.hs ===================================== @@ -0,0 +1,29 @@ +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} + +module Main where + +data Void +data WithVoid = LV Void | RV +data EnumT = L | R + deriving Show + +data BoxEnum = BoxEnum {-# UNPACK #-} !EnumT + deriving Show + +l = BoxEnum L +r = BoxEnum R + +main = do + print l + print r + + +data BoxWithVoid = BoxWithVoid {-# UNPACK #-} !WithVoid +wv = BoxWithVoid (LV undefined) + +data BoxVoid = BoxVoid {-# UNPACK #-} Void +bv = BoxVoid undefined + +data BoxSum = BoxS {-# UNPACK #-} !(# Int | Char #) +bs = BoxS (# 1 | #) ===================================== testsuite/tests/unboxedsums/unpack_sums_8.stdout ===================================== @@ -0,0 +1,2 @@ +BoxEnum L +BoxEnum R ===================================== testsuite/tests/unboxedsums/unpack_sums_9.hs ===================================== @@ -0,0 +1,39 @@ + +module UnpackedSums8 where + +-- Unpack a sum of 100 ints in each constructor +data Unpackee + = U !Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + + | O Word Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + +data Box = Box {-# UNPACK #-} !Unpackee + +b = Box $ U 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbefb3f64f262987e9a77432fa946198f221d2ca...612cc569bcb1f77db8d9a9ced006156c0f73e0af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbefb3f64f262987e9a77432fa946198f221d2ca...612cc569bcb1f77db8d9a9ced006156c0f73e0af You're receiving 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 Nov 15 03:20:19 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 22:20:19 -0500 Subject: [Git][ghc/ghc][master] Implement UNPACK support for sum types. Message-ID: <637305734d4e2_38f79f52878202566@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 22 changed files: - compiler/GHC/Core/Make.hs - compiler/GHC/Core/Opt/ConstantFold.hs - compiler/GHC/HsToCore/Expr.hs - compiler/GHC/Types/Id/Make.hs - docs/users_guide/exts/pragmas.rst - + testsuite/tests/unboxedsums/Makefile - testsuite/tests/unboxedsums/all.T - + testsuite/tests/unboxedsums/unpack_sums_1.hs - + testsuite/tests/unboxedsums/unpack_sums_1.stdout - + testsuite/tests/unboxedsums/unpack_sums_2.hs - + testsuite/tests/unboxedsums/unpack_sums_3.hs - + testsuite/tests/unboxedsums/unpack_sums_4.hs - + testsuite/tests/unboxedsums/unpack_sums_4.stdout - + testsuite/tests/unboxedsums/unpack_sums_5.hs - + testsuite/tests/unboxedsums/unpack_sums_5.stderr - + testsuite/tests/unboxedsums/unpack_sums_6.hs - + testsuite/tests/unboxedsums/unpack_sums_6.stdout - + testsuite/tests/unboxedsums/unpack_sums_7.hs - + testsuite/tests/unboxedsums/unpack_sums_7.stderr - + testsuite/tests/unboxedsums/unpack_sums_8.hs - + testsuite/tests/unboxedsums/unpack_sums_8.stdout - + testsuite/tests/unboxedsums/unpack_sums_9.hs Changes: ===================================== compiler/GHC/Core/Make.hs ===================================== @@ -23,7 +23,7 @@ module GHC.Core.Make ( FloatBind(..), wrapFloat, wrapFloats, floatBindings, -- * Constructing small tuples - mkCoreVarTupTy, mkCoreTup, mkCoreUnboxedTuple, mkCoreUbxSum, + mkCoreVarTupTy, mkCoreTup, mkCoreUnboxedTuple, mkCoreUnboxedSum, mkCoreTupBoxity, unitExpr, -- * Constructing big tuples @@ -405,8 +405,8 @@ mkCoreTup cs = mkCoreBoxedTuple cs -- non-1-tuples are uniform -- | Build an unboxed sum. -- -- Alternative number ("alt") starts from 1. -mkCoreUbxSum :: Int -> Int -> [Type] -> CoreExpr -> CoreExpr -mkCoreUbxSum arity alt tys exp +mkCoreUnboxedSum :: Int -> Int -> [Type] -> CoreExpr -> CoreExpr +mkCoreUnboxedSum arity alt tys exp = assert (length tys == arity) $ assert (alt <= arity) $ mkCoreConApps (sumDataCon alt arity) ===================================== compiler/GHC/Core/Opt/ConstantFold.hs ===================================== @@ -2097,7 +2097,7 @@ builtinBignumRules = x <- isNaturalLiteral a0 y <- isNaturalLiteral a1 -- return an unboxed sum: (# (# #) | Natural #) - let ret n v = pure $ mkCoreUbxSum 2 n [unboxedUnitTy,naturalTy] v + let ret n v = pure $ mkCoreUnboxedSum 2 n [unboxedUnitTy,naturalTy] v platform <- getPlatform if x < y then ret 1 unboxedUnitExpr ===================================== compiler/GHC/HsToCore/Expr.hs ===================================== @@ -369,7 +369,7 @@ dsExpr (ExplicitTuple _ tup_args boxity) -- See Note [Don't flatten tuples from HsSyn] in GHC.Core.Make dsExpr (ExplicitSum types alt arity expr) - = mkCoreUbxSum arity alt types <$> dsLExpr expr + = mkCoreUnboxedSum arity alt types <$> dsLExpr expr dsExpr (HsPragE _ prag expr) = ds_prag_expr prag expr ===================================== compiler/GHC/Types/Id/Make.hs ===================================== @@ -56,7 +56,7 @@ import GHC.Core.Coercion import GHC.Core.Reduction import GHC.Core.Make import GHC.Core.FVs ( mkRuleInfo ) -import GHC.Core.Utils ( exprType, mkCast, mkDefaultCase ) +import GHC.Core.Utils ( exprType, mkCast, mkDefaultCase, coreAltsType ) import GHC.Core.Unfold.Make import GHC.Core.SimpleOpt import GHC.Core.TyCon @@ -85,6 +85,7 @@ import GHC.Utils.Panic.Plain import GHC.Data.FastString import GHC.Data.List.SetOps +import Data.List ( zipWith4 ) {- ************************************************************************ @@ -1028,14 +1029,8 @@ dataConSrcToImplBang bang_opts fam_envs arg_ty arg_ty' = case mb_co of { Just redn -> scaledSet arg_ty (reductionReducedType redn) ; Nothing -> arg_ty } - , isUnpackableType bang_opts fam_envs (scaledThing arg_ty') - , (rep_tys, _) <- dataConArgUnpack arg_ty' - , case unpk_prag of - NoSrcUnpack -> - bang_opt_unbox_strict bang_opts - || (bang_opt_unbox_small bang_opts - && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] - srcUnpack -> isSrcUnpacked srcUnpack + , all (not . isNewTyCon . fst) (splitTyConApp_maybe $ scaledThing arg_ty') + , shouldUnpackTy bang_opts unpk_prag fam_envs arg_ty' = case mb_co of Nothing -> HsUnpack Nothing Just redn -> HsUnpack (Just $ reductionCoercion redn) @@ -1043,7 +1038,6 @@ dataConSrcToImplBang bang_opts fam_envs arg_ty | otherwise -- Record the strict-but-no-unpack decision = HsStrict - -- | Wrappers/Workers and representation following Unpack/Strictness -- decisions dataConArgRep @@ -1059,8 +1053,7 @@ dataConArgRep arg_ty HsStrict = ([(arg_ty, MarkedStrict)], (seqUnboxer, unitBoxer)) dataConArgRep arg_ty (HsUnpack Nothing) - | (rep_tys, wrappers) <- dataConArgUnpack arg_ty - = (rep_tys, wrappers) + = dataConArgUnpack arg_ty dataConArgRep (Scaled w _) (HsUnpack (Just co)) | let co_rep_ty = coercionRKind co @@ -1097,50 +1090,231 @@ unitBoxer :: Boxer unitBoxer = UnitBox ------------------------- + +{- Note [UNPACK for sum types] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Suppose we have a data type D, for example: + data D = D1 [Int] [Bool] + | D2 + +and another data type which unpacks a field of type D: + data U a = MkU {-# UNPACK #-} !D + {-# UNPACK #-} !(a,a) + {-# UNPACK #-} !D + +Then the wrapper and worker for MkU have these types + + -- Wrapper + $WMkU :: D -> (a,a) -> D -> U a + + -- Worker + MkU :: (# (# [Int],[Bool] #) | (# #) #) + -> a + -> a + -> (# (# [Int],[Bool] #) | (# #) #) + -> U a + +For each unpacked /sum/-type argument, the worker gets one argument. +But for each unpacked /product/-type argument, the worker gets N +arguments (here two). + +Why treat them differently? See Note [Why sums and products are treated differently]. + +The wrapper $WMkU looks like this: + + $WMkU :: D -> (a,a) -> D -> U a + $WMkU x1 y x2 + = case (case x1 of { + D1 a b -> (# (# a,b #) | #) + D2 -> (# | (# #) #) }) of { x1_ubx -> + case y of { (y1, y2) -> + case (case x2 of { + D1 a b -> (# (# a,b #) | #) + D2 -> (# | (# #) #) }) of { x2_ubx -> + MkU x1_ubx y1 y2 x2_ubx + +Notice the nested case needed for sums. + +This different treatment for sums and product is implemented in +dataConArgUnpackSum and dataConArgUnpackProduct respectively. + +Note [Why sums and products are treated differently] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Can we handle sums like products, with each wrapper argument +occupying multiple argument slots in the worker? No: for a sum +type the number of argument slots varies, and that's exactly what +unboxed sums are designed for. + +Can we handle products like sums, with each wrapper argument occupying +exactly one argument slot (and unboxed tuple) in the worker? Yes, +we could. For example + data P = MkP {-# UNPACK #-} !Q + data Q = MkQ {-# NOUNPACK #-} !Int + {-# NOUNPACK #-} Int + +Currently could unpack P thus, taking two slots in the worker + $WMkP :: Q -> P + $WMkP x = case x of { MkQ a b -> MkP a b } + MkP :: Int -> Int -> P -- Worker + +We could instead do this (uniformly with sums) + + $WMkP1 :: Q -> P + $WMkP1 x = case (case x of { MkQ a b -> (# a, b #) }) of ubx_x + MkP1 ubx_x + MkP1 :: (# Int, Int #) -> P -- Worker + +The representation of MkP and MkP1 would be identical (a constructor +with two fields). + +BUT, with MkP (as with every data constructor) we record its argument +strictness as a bit-vector, actually [StrictnessMark] + MkP strictness: SL +This information is used in Core to record which fields are sure to +be evaluated. (Look for calls to dataConRepStrictness.) E.g. in Core + case v of MkP x y -> ........ + +Alas, with MkP1 this information is hidden by the unboxed pair, +In Core there will be an auxiliary case expression to take apart the pair: + case v of MkP1 xy -> case xy of (# x,y #) -> ... +And now we have no easy way to know that x is evaluated in the "...". + +Fixing this might be possible, but it'd be tricky. So we avoid the +problem entirely by treating sums and products differently here. +-} + dataConArgUnpack :: Scaled Type -> ( [(Scaled Type, StrictnessMark)] -- Rep types , (Unboxer, Boxer) ) - -dataConArgUnpack (Scaled arg_mult arg_ty) +dataConArgUnpack scaledTy@(Scaled _ arg_ty) | Just (tc, tc_args) <- splitTyConApp_maybe arg_ty - , Just con <- tyConSingleAlgDataCon_maybe tc - -- NB: check for an *algebraic* data type - -- A recursive newtype might mean that - -- 'arg_ty' is a newtype - , let rep_tys = map (scaleScaled arg_mult) $ dataConInstArgTys con tc_args - = assert (null (dataConExTyCoVars con)) - -- Note [Unpacking GADTs and existentials] - ( rep_tys `zip` dataConRepStrictness con - ,( \ arg_id -> - do { rep_ids <- mapM (newLocal (fsLit "unbx")) rep_tys - ; let r_mult = idMult arg_id - ; let rep_ids' = map (scaleIdBy r_mult) rep_ids - ; let unbox_fn body - = mkSingleAltCase (Var arg_id) arg_id - (DataAlt con) rep_ids' body - ; return (rep_ids, unbox_fn) } - , Boxer $ \ subst -> - do { rep_ids <- mapM (newLocal (fsLit "bx") . TcType.substScaledTyUnchecked subst) rep_tys - ; return (rep_ids, Var (dataConWorkId con) - `mkTyApps` (substTysUnchecked subst tc_args) - `mkVarApps` rep_ids ) } ) ) + = assert (not (isNewTyCon tc)) $ + case tyConDataCons tc of + [con] -> dataConArgUnpackProduct scaledTy tc_args con + cons -> dataConArgUnpackSum scaledTy tc_args cons | otherwise = pprPanic "dataConArgUnpack" (ppr arg_ty) -- An interface file specified Unpacked, but we couldn't unpack it -isUnpackableType :: BangOpts -> FamInstEnvs -> Type -> Bool --- True if we can unpack the UNPACK the argument type +dataConArgUnpackProduct + :: Scaled Type + -> [Type] + -> DataCon + -> ( [(Scaled Type, StrictnessMark)] -- Rep types + , (Unboxer, Boxer) ) +dataConArgUnpackProduct (Scaled arg_mult _) tc_args con = + assert (null (dataConExTyCoVars con)) $ + -- Note [Unpacking GADTs and existentials] + let rep_tys = map (scaleScaled arg_mult) $ dataConInstArgTys con tc_args + in ( rep_tys `zip` dataConRepStrictness con + , ( \ arg_id -> + do { rep_ids <- mapM (newLocal (fsLit "unbx")) rep_tys + ; let r_mult = idMult arg_id + ; let rep_ids' = map (scaleIdBy r_mult) rep_ids + ; let unbox_fn body + = mkSingleAltCase (Var arg_id) arg_id + (DataAlt con) rep_ids' body + ; return (rep_ids, unbox_fn) } + , Boxer $ \ subst -> + do { rep_ids <- mapM (newLocal (fsLit "bx") . TcType.substScaledTyUnchecked subst) rep_tys + ; return (rep_ids, Var (dataConWorkId con) + `mkTyApps` (substTysUnchecked subst tc_args) + `mkVarApps` rep_ids ) } ) ) + +dataConArgUnpackSum + :: Scaled Type + -> [Type] + -> [DataCon] + -> ( [(Scaled Type, StrictnessMark)] -- Rep types + , (Unboxer, Boxer) ) +dataConArgUnpackSum (Scaled arg_mult arg_ty) tc_args cons = + ( [ (sum_ty, MarkedStrict) ] -- The idea: Unpacked variant will + -- be one field only, and the type of the + -- field will be an unboxed sum. + , ( unboxer, boxer ) ) + where + !ubx_sum_arity = length cons + src_tys = map (\con -> map scaledThing $ dataConInstArgTys con tc_args) cons + sum_alt_tys = map mkUbxSumAltTy src_tys + sum_ty_unscaled = mkSumTy sum_alt_tys + sum_ty = Scaled arg_mult sum_ty_unscaled + newLocal' fs = newLocal fs . Scaled arg_mult + + -- See Note [UNPACK for sum types] + unboxer :: Unboxer + unboxer arg_id = do + con_arg_binders <- mapM (mapM (newLocal' (fsLit "unbx"))) src_tys + ubx_sum_bndr <- newLocal (fsLit "unbx") sum_ty + + let + mk_ubx_sum_alt :: Int -> DataCon -> [Var] -> CoreAlt + mk_ubx_sum_alt alt con [bndr] = Alt (DataAlt con) [bndr] + (mkCoreUnboxedSum ubx_sum_arity alt sum_alt_tys (Var bndr)) + + mk_ubx_sum_alt alt con bndrs = + let tuple = mkCoreUnboxedTuple (map Var bndrs) + in Alt (DataAlt con) bndrs (mkCoreUnboxedSum ubx_sum_arity alt sum_alt_tys tuple ) + + ubx_sum :: CoreExpr + ubx_sum = + let alts = zipWith3 mk_ubx_sum_alt [ 1 .. ] cons con_arg_binders + in Case (Var arg_id) arg_id (coreAltsType alts) alts + + unbox_fn :: CoreExpr -> CoreExpr + unbox_fn body = + mkSingleAltCase ubx_sum ubx_sum_bndr DEFAULT [] body + + return ([ubx_sum_bndr], unbox_fn) + + boxer :: Boxer + boxer = Boxer $ \ subst -> do + unboxed_field_id <- newLocal' (fsLit "bx") (TcType.substTy subst sum_ty_unscaled) + tuple_bndrs <- mapM (newLocal' (fsLit "bx") . TcType.substTy subst) sum_alt_tys + + let tc_args' = substTys subst tc_args + arg_ty' = substTy subst arg_ty + + con_arg_binders <- + mapM (mapM (newLocal' (fsLit "bx")) . map (TcType.substTy subst)) src_tys + + let mk_sum_alt :: Int -> DataCon -> Var -> [Var] -> CoreAlt + mk_sum_alt alt con _ [datacon_bndr] = + ( Alt (DataAlt (sumDataCon alt ubx_sum_arity)) [datacon_bndr] + (Var (dataConWorkId con) `mkTyApps` tc_args' + `mkVarApps` [datacon_bndr] )) + + mk_sum_alt alt con tuple_bndr datacon_bndrs = + ( Alt (DataAlt (sumDataCon alt ubx_sum_arity)) [tuple_bndr] ( + Case (Var tuple_bndr) tuple_bndr arg_ty' + [ Alt (DataAlt (tupleDataCon Unboxed (length datacon_bndrs))) datacon_bndrs + (Var (dataConWorkId con) `mkTyApps` tc_args' + `mkVarApps` datacon_bndrs ) ] )) + + return ( [unboxed_field_id], + Case (Var unboxed_field_id) unboxed_field_id arg_ty' + (zipWith4 mk_sum_alt [ 1 .. ] cons tuple_bndrs con_arg_binders) ) + +-- | Every alternative of an unboxed sum has exactly one field, and we use +-- unboxed tuples when we need more than one field. This generates an unboxed +-- tuple when necessary, to be used in unboxed sum alts. +mkUbxSumAltTy :: [Type] -> Type +mkUbxSumAltTy [ty] = ty +mkUbxSumAltTy tys = mkTupleTy Unboxed tys + +shouldUnpackTy :: BangOpts -> SrcUnpackedness -> FamInstEnvs -> Scaled Type -> Bool +-- True if we ought to unpack the UNPACK the argument type -- See Note [Recursive unboxing] -- We look "deeply" inside rather than relying on the DataCons -- we encounter on the way, because otherwise we might well -- end up relying on ourselves! -isUnpackableType bang_opts fam_envs ty - | Just data_con <- unpackable_type ty - = ok_con_args emptyNameSet data_con +shouldUnpackTy bang_opts prag fam_envs ty + | Just data_cons <- unpackable_type_datacons (scaledThing ty) + = all (ok_con_args emptyNameSet) data_cons && should_unpack data_cons | otherwise = False where + ok_con_args :: NameSet -> DataCon -> Bool ok_con_args dcs con | dc_name `elemNameSet` dcs = False @@ -1153,17 +1327,20 @@ isUnpackableType bang_opts fam_envs ty dc_name = getName con dcs' = dcs `extendNameSet` dc_name + ok_arg :: NameSet -> (Scaled Type, HsSrcBang) -> Bool ok_arg dcs (Scaled _ ty, bang) = not (attempt_unpack bang) || ok_ty dcs norm_ty where norm_ty = topNormaliseType fam_envs ty + ok_ty :: NameSet -> Type -> Bool ok_ty dcs ty - | Just data_con <- unpackable_type ty - = ok_con_args dcs data_con + | Just data_cons <- unpackable_type_datacons ty + = all (ok_con_args dcs) data_cons | otherwise = True -- NB True here, in contrast to False at top level + attempt_unpack :: HsSrcBang -> Bool attempt_unpack (HsSrcBang _ SrcUnpack NoSrcStrict) = bang_opt_strict_data bang_opts attempt_unpack (HsSrcBang _ SrcUnpack SrcStrict) @@ -1174,16 +1351,40 @@ isUnpackableType bang_opts fam_envs ty = bang_opt_strict_data bang_opts -- Be conservative attempt_unpack _ = False - unpackable_type :: Type -> Maybe DataCon - -- Works just on a single level - unpackable_type ty - | Just (tc, _) <- splitTyConApp_maybe ty - , Just data_con <- tyConSingleAlgDataCon_maybe tc - , null (dataConExTyCoVars data_con) - -- See Note [Unpacking GADTs and existentials] - = Just data_con - | otherwise - = Nothing + -- Determine whether we ought to unpack a field based on user annotations if present and heuristics if not. + should_unpack data_cons = + case prag of + SrcNoUnpack -> False -- {-# NOUNPACK #-} + SrcUnpack -> True -- {-# UNPACK #-} + NoSrcUnpack -- No explicit unpack pragma, so use heuristics + | (_:_:_) <- data_cons + -> False -- don't unpack sum types automatically, but they can be unpacked with an explicit source UNPACK. + | otherwise + -> bang_opt_unbox_strict bang_opts + || (bang_opt_unbox_small bang_opts + && rep_tys `lengthAtMost` 1) -- See Note [Unpack one-wide fields] + where (rep_tys, _) = dataConArgUnpack ty + + +-- Given a type already assumed to have been normalized by topNormaliseType, +-- unpackable_type_datacons ty = Just datacons +-- iff ty is of the form +-- T ty1 .. tyn +-- and T is an algebraic data type (not newtype), in which no data +-- constructors have existentials, and datacons is the list of data +-- constructors of T. +unpackable_type_datacons :: Type -> Maybe [DataCon] +unpackable_type_datacons ty + | Just (tc, _) <- splitTyConApp_maybe ty + , not (isNewTyCon tc) + -- Even though `ty` has been normalised, it could still + -- be a /recursive/ newtype, so we must check for that + , Just cons <- tyConDataCons_maybe tc + , not (null cons) + , all (null . dataConExTyCoVars) cons + = Just cons -- See Note [Unpacking GADTs and existentials] + | otherwise + = Nothing {- Note [Unpacking GADTs and existentials] ===================================== docs/users_guide/exts/pragmas.rst ===================================== @@ -845,8 +845,14 @@ flattening the pair. Multi-level unpacking is also supported: :: will store two unboxed ``Int#``\ s directly in the ``T`` constructor. The unpacker can see through newtypes, too. +Since 9.6.1, data types with multiple constructors can also be unpacked, effectively +transforming the field into an unboxed sum of the unpackings of each +constructor (see :extension:`UnboxedSums`). + See also the :ghc-flag:`-funbox-strict-fields` flag, which essentially has the -effect of adding ``{-# UNPACK #-}`` to every strict constructor field. +effect of adding ``{-# UNPACK #-}`` to every strict constructor field which is +of a single-constructor data type. Sum types won't be unpacked automatically +by this though, only with the explicit pragma. .. [1] In fact, :pragma:`UNPACK` has no effect without :ghc-flag:`-O`, for technical ===================================== testsuite/tests/unboxedsums/Makefile ===================================== @@ -0,0 +1,11 @@ +TOP=../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +.PHONY: unpack_sums_7 + +unpack_sums_7: + $(RM) -f unpack_sums_7.o unpack_sums_7.hi + '$(TEST_HC)' $(TEST_HC_OPTS) -c unpack_sums_7.hs -O -dsuppress-all -ddump-simpl | grep -q '\(# |_ #\)' + # This is a test to check for the presence of an unboxed sum in the core for a program using UNPACK + # on a sum type which is evidence that the field has been correctly unpacked. ===================================== testsuite/tests/unboxedsums/all.T ===================================== @@ -40,3 +40,18 @@ test('T22187',[only_ways(llvm_ways)],compile,['']) test('T22187_run',[only_ways(llvm_ways) ,unless(arch('x86_64'), skip)],compile_and_run,['']) +test('unpack_sums_1', normal, compile_and_run, ['-O']) +test('unpack_sums_2', normal, compile, ['-O']) +test('unpack_sums_3', normal, compile_and_run, ['-O']) +test('unpack_sums_4', normal, compile_and_run, ['-O']) +test('unpack_sums_5', normal, compile, ['-O']) +test('unpack_sums_6', normal, compile_and_run, ['-O']) +test('unpack_sums_7', [], makefile_test, []) +test('unpack_sums_8', normal, compile_and_run, [""]) +test('unpack_sums_9', normal, compile, [""]) + +# TODO: Need to run this in --slow mode only +# test('sum_api_annots', +# [only_ways(['normal']), +# extra_files([ "unboxedsums" + str(i) + ".hs" for i in range(1, 12) ])], +# makefile_test, []) ===================================== testsuite/tests/unboxedsums/unpack_sums_1.hs ===================================== @@ -0,0 +1,22 @@ +module Main where + +data T = T1 Int | T2 String + deriving (Show, Eq, Ord, Read) + +data T' = T' {-# UNPACK #-} !T + deriving (Show, Eq, Ord, Read) + +t1, t2 :: T +t1 = T1 123 +t2 = T2 "OK" +{-# NOINLINE t1 #-} +{-# NOINLINE t2 #-} + +t'1, t'2 :: T' +t'1 = T' t1 +t'2 = T' t2 + +main :: IO () +main = do + print t'1 + print t'2 ===================================== testsuite/tests/unboxedsums/unpack_sums_1.stdout ===================================== @@ -0,0 +1,2 @@ +T' (T1 123) +T' (T2 "OK") ===================================== testsuite/tests/unboxedsums/unpack_sums_2.hs ===================================== @@ -0,0 +1,9 @@ +module Lib where + +data Number = F {-# UNPACK #-} !Float | I {-# UNPACK #-} !Int + +-- This UNPACK was causing a panic: +-- ghc-stage1: panic! (the 'impossible' happened) +-- (GHC version 8.1.20160722 for x86_64-unknown-linux): +-- LocalReg's live-in to graph crG {_grh::F32, _gri::I64} +data T = T {-# UNPACK #-} !Number ===================================== testsuite/tests/unboxedsums/unpack_sums_3.hs ===================================== @@ -0,0 +1,14 @@ +-- Check that we can unpack a strict Maybe Int field. +import System.Exit + +data T = MkT {-# UNPACK #-} !(Maybe Int) + +xs = Nothing : [Just n | n <- [1..10]] + +ts = map MkT xs + +main = if xs == map (\(MkT m) -> m) ts + then return () + else do + putStrLn "Error in packing and unpacking!" + exitFailure ===================================== testsuite/tests/unboxedsums/unpack_sums_4.hs ===================================== @@ -0,0 +1,8 @@ +-- Check that nothing goes wrong with UNPACK in recursive case. +data T = MkT {-# UNPACK #-} !(Maybe T) + deriving Show + +t :: T +t = MkT (Just t) + +main = print $ take 100 (show t) ===================================== testsuite/tests/unboxedsums/unpack_sums_4.stdout ===================================== @@ -0,0 +1 @@ +"MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (MkT (Just (M" ===================================== testsuite/tests/unboxedsums/unpack_sums_5.hs ===================================== @@ -0,0 +1,11 @@ +module UnpackSumsFive where +-- Check that failure to unpack is warned about. + +data SMaybeT = NoT | JustT {-# UNPACK #-} !T + deriving Show + +data T = MkT {-# UNPACK #-} !SMaybeT + deriving Show + +t :: T +t = MkT (JustT (MkT (JustT (MkT NoT)))) ===================================== testsuite/tests/unboxedsums/unpack_sums_5.stderr ===================================== @@ -0,0 +1,10 @@ + +unpack_sums_5.hs:4:22: warning: + • Ignoring unusable UNPACK pragma on the first argument of ‘JustT’ + • In the definition of data constructor ‘JustT’ + In the data type declaration for ‘SMaybeT’ + +unpack_sums_5.hs:7:10: warning: + • Ignoring unusable UNPACK pragma on the first argument of ‘MkT’ + • In the definition of data constructor ‘MkT’ + In the data type declaration for ‘T’ ===================================== testsuite/tests/unboxedsums/unpack_sums_6.hs ===================================== @@ -0,0 +1,55 @@ +{-# LANGUAGE BangPatterns #-} +-- This perhaps overly simple test check if code involving +-- unbacked sums is faster than non-unpacked ones which at +-- least in this case we expect to be the case. +-- However this test isn't quite robust, should it fail in +-- the future we might want to redo it or mark it fragile. +import Data.Time.Clock + +import Data.Int +import System.Exit + +data A = ANothing | AJust {-# UNPACK #-} !Int64 +data B = BNothing | BJust {-# UNPACK #-} !A +data C = CNothing | CJust {-# UNPACK #-} !B +data D = DNothing | DJust {-# UNPACK #-} !C + +data Unlayered = Unlayered {-# UNPACK #-} !D + +data Layered = Layered !(Maybe (Maybe (Maybe (Maybe Int64)))) + +makeUnlayered :: Int64 -> [Unlayered] +makeUnlayered n = Unlayered . DJust . CJust . BJust . AJust <$> [1..n] + +makeLayered :: Int64 -> [Layered] +makeLayered n = Layered . Just . Just . Just . Just <$> [1..n] + +sumUnlayered :: [Unlayered] -> Int64 +sumUnlayered = go 0 + where + go !n [] = n + go !n (w:ws) = case w of + Unlayered (DJust (CJust (BJust (AJust i)))) -> go (n+i) ws + Unlayered _ -> go n ws + +sumLayered :: [Layered] -> Int64 +sumLayered = go 0 + where + go !n [] = n + go !n (w:ws) = case w of + Layered (Just (Just (Just (Just i)))) -> go (n+i) ws + Layered _ -> go n ws + +main :: IO () +main = do + let magnitude = 10000000 + unlayeredInts = makeUnlayered magnitude + layeredInts = makeLayered magnitude + now <- getCurrentTime + print $ sumUnlayered unlayeredInts + unlayeredTime <- getCurrentTime + print $ sumLayered layeredInts + layeredTime <- getCurrentTime + case (unlayeredTime `diffUTCTime` now) < (layeredTime `diffUTCTime` unlayeredTime) of + True -> exitSuccess + False -> exitFailure ===================================== testsuite/tests/unboxedsums/unpack_sums_6.stdout ===================================== @@ -0,0 +1,2 @@ +50000005000000 +50000005000000 ===================================== testsuite/tests/unboxedsums/unpack_sums_7.hs ===================================== @@ -0,0 +1,10 @@ +-- NB: Compiling this module throws an exception involving Weak# at the end of compilation. +-- This is unrelated to unpacked sums but we need to include the error in the expected output for the test to pass. + +module UnpackedSums7 where + +data T = MkT {-# UNPACK #-} !MI + +data MI = NoI | JI Int + +t = MkT (JI 5) ===================================== testsuite/tests/unboxedsums/unpack_sums_7.stderr ===================================== @@ -0,0 +1,2 @@ +Exception during Weak# finalization (ignored): : hFlush: resource vanished (Broken pipe) +Exception during Weak# finalization (ignored): : hFlush: resource vanished (Broken pipe) ===================================== testsuite/tests/unboxedsums/unpack_sums_8.hs ===================================== @@ -0,0 +1,29 @@ +{-# LANGUAGE UnboxedTuples #-} +{-# LANGUAGE UnboxedSums #-} + +module Main where + +data Void +data WithVoid = LV Void | RV +data EnumT = L | R + deriving Show + +data BoxEnum = BoxEnum {-# UNPACK #-} !EnumT + deriving Show + +l = BoxEnum L +r = BoxEnum R + +main = do + print l + print r + + +data BoxWithVoid = BoxWithVoid {-# UNPACK #-} !WithVoid +wv = BoxWithVoid (LV undefined) + +data BoxVoid = BoxVoid {-# UNPACK #-} Void +bv = BoxVoid undefined + +data BoxSum = BoxS {-# UNPACK #-} !(# Int | Char #) +bs = BoxS (# 1 | #) ===================================== testsuite/tests/unboxedsums/unpack_sums_8.stdout ===================================== @@ -0,0 +1,2 @@ +BoxEnum L +BoxEnum R ===================================== testsuite/tests/unboxedsums/unpack_sums_9.hs ===================================== @@ -0,0 +1,39 @@ + +module UnpackedSums8 where + +-- Unpack a sum of 100 ints in each constructor +data Unpackee + = U !Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + + | O Word Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + Int Int Int Int Int Int Int Int Int Int + +data Box = Box {-# UNPACK #-} !Unpackee + +b = Box $ U 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b7d5ccc4a022abfba3a6774639d30738a94ae85 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2b7d5ccc4a022abfba3a6774639d30738a94ae85 You're receiving 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 Nov 15 03:20:48 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 22:20:48 -0500 Subject: [Git][ghc/ghc][master] Expand on the need to clone local binders. Message-ID: <6373059094586_38f79f528c82077aa@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 2 changed files: - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Stg/Subst.hs Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -112,6 +112,17 @@ The goal of this pass is to prepare for code generation. and doing so would be tiresome because then we'd need to substitute in types and coercions. + We need to clone ids for two reasons: + + Things associated with labels in the final code must be truly unique in + order to avoid labels being shadowed in the final output. + + Even binders without info tables like function arguments or alternative + bound binders must be unique at least in their type/unique combination. + We only emit a single declaration for each binder when compiling to C + so if binders are not unique we would either get duplicate declarations + or misstyped variables. The later happend in #22402. + + We heavily use unique-keyed maps in the backend which can go wrong when + ids with the same unique are meant to represent the same variable. + 7. Give each dynamic CCall occurrence a fresh unique; this is rather like the cloning step above. ===================================== compiler/GHC/Stg/Subst.hs ===================================== @@ -12,6 +12,13 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Panic +-- TODO: This code might make folly of the work done in CorePrep where +-- we clone local ids in order to ensure *all* local binders are unique. +-- It's my understanding that here we use "the rapier"/uniqAway which makes up +-- uniques based on the ids in scope. Which can give the same unique to different +-- binders as long as they are in different scopes. A guarantee which isn't +-- strong enough for code generation in general. See Note [CorePrep Overview]. + -- | A renaming substitution from 'Id's to 'Id's. Like 'RnEnv2', but not -- maintaining pairs of substitutions. Like 'GHC.Core.Subst.Subst', but -- with the domain being 'Id's instead of entire 'CoreExpr'. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78f7ecb053340388236300e7e8d458a1a5a42344 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78f7ecb053340388236300e7e8d458a1a5a42344 You're receiving 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 Nov 15 03:21:38 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Mon, 14 Nov 2022 22:21:38 -0500 Subject: [Git][ghc/ghc][master] Fix :i Constraint printing "type Constraint = Constraint" Message-ID: <637305c2c37a3_38f79f5288c21134d@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 4 changed files: - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - testsuite/tests/ghci/should_run/T18594.script - testsuite/tests/ghci/should_run/T18594.stdout Changes: ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -44,7 +44,8 @@ module GHC.Iface.Syntax ( import GHC.Prelude -import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey ) +import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey, + constraintKindTyConKey ) import GHC.Types.Unique ( hasKey ) import GHC.Iface.Type import GHC.Iface.Recomp.Binary @@ -988,7 +989,8 @@ pprIfaceDecl ss (IfaceSynonym { ifName = tc -- See Note [Printing type abbreviations] in GHC.Iface.Type ppr_tau | tc `hasKey` liftedTypeKindTyConKey || - tc `hasKey` unrestrictedFunTyConKey + tc `hasKey` unrestrictedFunTyConKey || + tc `hasKey` constraintKindTyConKey = updSDocContext (\ctx -> ctx { sdocPrintTypeAbbreviations = False }) $ ppr tau | otherwise = ppr tau ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -846,7 +846,7 @@ Note [Printing type abbreviations] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Normally, we pretty-print `TYPE 'LiftedRep` as `Type` (or `*`) - `CONSTRAINT 'LiftedRep` as `Constraint` (or `*`) + `CONSTRAINT 'LiftedRep` as `Constraint` `FUN 'Many` as `(->)`. This way, error messages don't refer to representation polymorphism or linearity if it is not necessary. Normally we'd would represent @@ -856,14 +856,16 @@ command we specifically expand synonyms (see GHC.Tc.Module.tcRnExpr). So here in the pretty-printing we effectively collapse back Type and Constraint to their synonym forms. A bit confusing! -However, when printing the definition of Type or (->) with :info, +However, when printing the definition of Type, Constraint or (->) with :info, this would give confusing output: `type (->) = (->)` (#18594). Solution: detect when we are in :info and disable displaying the synonym with the SDoc option sdocPrintTypeAbbreviations. +If you are creating a similar synonym, make sure it is listed in pprIfaceDecl, +see reference to this Note. If there will be a need, in the future we could expose it as a flag --fprint-type-abbreviations or even two separate flags controlling -TYPE 'LiftedRep and FUN 'Many. +-fprint-type-abbreviations or even three separate flags controlling +TYPE 'LiftedRep, CONSTRAINT 'LiftedRep and FUN 'Many. -} -- | Do we want to suppress kind annotations on binders? ===================================== testsuite/tests/ghci/should_run/T18594.script ===================================== @@ -1,5 +1,6 @@ :m GHC.Types :i (->) +:i Constraint :set -XStarIsType :i Type :set -XNoStarIsType ===================================== testsuite/tests/ghci/should_run/T18594.stdout ===================================== @@ -7,6 +7,9 @@ instance Semigroup b => Semigroup (a -> b) -- Defined in ‘GHC.Base’ instance Applicative ((->) r) -- Defined in ‘GHC.Base’ instance Functor ((->) r) -- Defined in ‘GHC.Base’ instance Monad ((->) r) -- Defined in ‘GHC.Base’ +type Constraint :: * +type Constraint = CONSTRAINT LiftedRep + -- Defined in ‘GHC.Types’ type Type :: * type Type = TYPE LiftedRep -- Defined in ‘GHC.Types’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65ce43cc647109fb18c8703563cf25fc8cf103fc -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65ce43cc647109fb18c8703563cf25fc8cf103fc You're receiving 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 Nov 15 04:57:31 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Mon, 14 Nov 2022 23:57:31 -0500 Subject: [Git][ghc/ghc][wip/drop-touch] Drop dependence on `touch` Message-ID: <63731c3b74890_38f79f5287821355a@gitlab.mail> Ben Gamari pushed to branch wip/drop-touch at Glasgow Haskell Compiler / GHC Commits: c9282c41 by Ben Gamari at 2022-11-14T23:57:20-05:00 Drop dependence on `touch` This drops GHC's dependence on the `touch` program, instead implementing it within GHC. This eliminates an external dependency and means that we have one fewer program to keep track of in the `configure` script - - - - - 22 changed files: - compiler/GHC/Driver/Main.hs - compiler/GHC/Driver/Pipeline/Execute.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/Settings.hs - compiler/GHC/Settings/IO.hs - compiler/GHC/SysTools/Tasks.hs - + compiler/GHC/Utils/Touch.hs - compiler/ghc.cabal.in - hadrian/bindist/Makefile - hadrian/bindist/config.mk.in - hadrian/cfg/system.config.in - hadrian/src/Builder.hs - hadrian/src/Hadrian/Builder.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Packages.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Rules/Program.hs - hadrian/src/Settings/Default.hs - m4/fp_settings.m4 - − utils/touchy/Makefile - − utils/touchy/touchy.c - − utils/touchy/touchy.cabal Changes: ===================================== compiler/GHC/Driver/Main.hs ===================================== @@ -250,6 +250,7 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Logger import GHC.Utils.TmpFs +import GHC.Utils.Touch import GHC.Data.FastString import GHC.Data.Bag @@ -1263,7 +1264,7 @@ hscMaybeWriteIface logger dflags is_simple iface old_iface mod_location = do -- .hie files. let hie_file = ml_hie_file mod_location whenM (doesFileExist hie_file) $ - GHC.SysTools.touch logger dflags "Touching hie file" hie_file + GHC.Utils.Touch.touch hie_file else -- See Note [Strictness in ModIface] forceModIface iface ===================================== compiler/GHC/Driver/Pipeline/Execute.hs ===================================== @@ -75,6 +75,7 @@ import GHC.Linker.ExtraObj import GHC.Linker.Dynamic import Data.Version import GHC.Utils.Panic +import GHC.Utils.Touch import GHC.Unit.Module.Env import GHC.Driver.Env.KnotVars import GHC.Driver.Config.Finder @@ -522,7 +523,7 @@ runHscBackendPhase pipe_env hsc_env mod_name src_flavour location result = do -- In the case of hs-boot files, generate a dummy .o-boot -- stamp file for the benefit of Make - HsBootFile -> touchObjectFile logger dflags o_file + HsBootFile -> touchObjectFile o_file HsSrcFile -> panic "HscUpdate not relevant for HscSrcFile" return ([], iface, emptyHomeModInfoLinkable, o_file) @@ -1274,10 +1275,10 @@ generateMacros prefix name version = -touchObjectFile :: Logger -> DynFlags -> FilePath -> IO () -touchObjectFile logger dflags path = do +touchObjectFile :: FilePath -> IO () +touchObjectFile path = do createDirectoryIfMissing True $ takeDirectory path - GHC.SysTools.touch logger dflags "Touching object file" path + GHC.Utils.Touch.touch path -- | Find out path to @ghcversion.h@ file getGhcVersionPathName :: DynFlags -> UnitEnv -> IO FilePath ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -95,7 +95,6 @@ module GHC.Driver.Session ( sPgm_l, sPgm_lm, sPgm_dll, - sPgm_T, sPgm_windres, sPgm_ar, sPgm_ranlib, @@ -129,7 +128,7 @@ module GHC.Driver.Session ( ghcUsagePath, ghciUsagePath, topDir, versionedAppDir, versionedFilePath, extraGccViaCFlags, globalPackageDatabasePath, - pgm_L, pgm_P, pgm_F, pgm_c, pgm_cxx, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, + pgm_L, pgm_P, pgm_F, pgm_c, pgm_cxx, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_windres, pgm_ar, pgm_otool, pgm_install_name_tool, pgm_ranlib, pgm_lo, pgm_lc, pgm_lcc, pgm_i, opt_L, opt_P, opt_F, opt_c, opt_cxx, opt_a, opt_l, opt_lm, opt_i, @@ -824,8 +823,6 @@ pgm_lm :: DynFlags -> Maybe (String,[Option]) pgm_lm dflags = toolSettings_pgm_lm $ toolSettings dflags pgm_dll :: DynFlags -> (String,[Option]) pgm_dll dflags = toolSettings_pgm_dll $ toolSettings dflags -pgm_T :: DynFlags -> String -pgm_T dflags = toolSettings_pgm_T $ toolSettings dflags pgm_windres :: DynFlags -> String pgm_windres dflags = toolSettings_pgm_windres $ toolSettings dflags pgm_lcc :: DynFlags -> (String,[Option]) ===================================== compiler/GHC/Settings.hs ===================================== @@ -32,7 +32,6 @@ module GHC.Settings , sPgm_l , sPgm_lm , sPgm_dll - , sPgm_T , sPgm_windres , sPgm_ar , sPgm_otool @@ -105,7 +104,6 @@ data ToolSettings = ToolSettings -- merging, hence the 'Maybe'. See Note [Object merging] in -- "GHC.Driver.Pipeline.Execute" for details. , toolSettings_pgm_dll :: (String, [Option]) - , toolSettings_pgm_T :: String , toolSettings_pgm_windres :: String , toolSettings_pgm_ar :: String , toolSettings_pgm_otool :: String @@ -216,8 +214,6 @@ sPgm_lm :: Settings -> Maybe (String, [Option]) sPgm_lm = toolSettings_pgm_lm . sToolSettings sPgm_dll :: Settings -> (String, [Option]) sPgm_dll = toolSettings_pgm_dll . sToolSettings -sPgm_T :: Settings -> String -sPgm_T = toolSettings_pgm_T . sToolSettings sPgm_windres :: Settings -> String sPgm_windres = toolSettings_pgm_windres . sToolSettings sPgm_ar :: Settings -> String ===================================== compiler/GHC/Settings/IO.hs ===================================== @@ -112,8 +112,6 @@ initSettings top_dir = do install_name_tool_path <- getToolSetting "install_name_tool command" ranlib_path <- getToolSetting "ranlib command" - touch_path <- getToolSetting "touch command" - mkdll_prog <- getToolSetting "dllwrap command" let mkdll_args = [] @@ -177,7 +175,6 @@ initSettings top_dir = do , toolSettings_pgm_l = (ld_prog, ld_args) , toolSettings_pgm_lm = ld_r , toolSettings_pgm_dll = (mkdll_prog,mkdll_args) - , toolSettings_pgm_T = touch_path , toolSettings_pgm_windres = windres_path , toolSettings_pgm_ar = ar_path , toolSettings_pgm_otool = otool_path ===================================== compiler/GHC/SysTools/Tasks.hs ===================================== @@ -376,6 +376,3 @@ runWindres logger dflags args = traceSystoolCommand logger "windres" $ do mb_env <- getGccEnv cc_args runSomethingFiltered logger id "Windres" windres (opts ++ args) Nothing mb_env -touch :: Logger -> DynFlags -> String -> String -> IO () -touch logger dflags purpose arg = traceSystoolCommand logger "touch" $ - runSomething logger purpose (pgm_T dflags) [FileOption "" arg] ===================================== compiler/GHC/Utils/Touch.hs ===================================== @@ -0,0 +1,29 @@ +{-# LANGUAGE CPP #-} + +module GHC.Utils.Touch (touch) where + +import GHC.Prelude + +#if defined(mingw32_HOST_OS) +import System.Win32.File +import System.Win32.Time +#else +import System.Posix.Files +import System.Posix.IO +#endif + +-- | Set the mtime of the given file to the current time. +touch :: FilePath -> IO () +touch file = do +#if defined(mingw32_HOST_OS) + hdl <- createFile file sTANDARD_RIGHTS_WRITE fILE_SHARE_NONE Nothing cREATE_NEW fILE_ATTRIBUTE_NORMAL Nothing + t <- getSystemTimeAsFileTime + setFileTime hdl Nothing (Just t) (Just t) + closeHandle hdl +#else + let oflags = defaultFileFlags { noctty = True } + fd <- openFd file WriteOnly (Just 0o666) oflags + touchFd fd + closeFd fd +#endif + ===================================== compiler/ghc.cabal.in ===================================== @@ -805,6 +805,7 @@ Library GHC.Utils.Ppr GHC.Utils.Ppr.Colour GHC.Utils.TmpFs + GHC.Utils.Touch GHC.Utils.Trace Language.Haskell.Syntax ===================================== hadrian/bindist/Makefile ===================================== @@ -102,7 +102,6 @@ lib/settings : @echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@ @echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@ @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ - @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("dllwrap command", "$(SettingsDllWrapCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ @echo ',("unlit command", "$$topdir/bin/unlit")' >> $@ ===================================== hadrian/bindist/config.mk.in ===================================== @@ -273,7 +273,6 @@ SettingsRanlibCommand = @SettingsRanlibCommand@ SettingsDllWrapCommand = @SettingsDllWrapCommand@ SettingsWindresCommand = @SettingsWindresCommand@ SettingsLibtoolCommand = @SettingsLibtoolCommand@ -SettingsTouchCommand = @SettingsTouchCommand@ SettingsClangCommand = @SettingsClangCommand@ SettingsLlcCommand = @SettingsLlcCommand@ SettingsOptCommand = @SettingsOptCommand@ ===================================== hadrian/cfg/system.config.in ===================================== @@ -159,7 +159,6 @@ settings-otool-command = @SettingsOtoolCommand@ settings-install_name_tool-command = @SettingsInstallNameToolCommand@ settings-dll-wrap-command = @SettingsDllWrapCommand@ settings-windres-command = @SettingsWindresCommand@ -settings-touch-command = @SettingsTouchCommand@ settings-clang-command = @SettingsClangCommand@ settings-llc-command = @SettingsLlcCommand@ settings-opt-command = @SettingsOptCommand@ ===================================== hadrian/src/Builder.hs ===================================== @@ -235,7 +235,6 @@ instance H.Builder Builder where pure [] Ghc _ stage -> do root <- buildRoot - touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit -- GHC from the previous stage is used to build artifacts in the @@ -244,7 +243,6 @@ instance H.Builder Builder where return $ [ unlitPath ] ++ ghcdeps - ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that -- we have in inplace/mingw initially, and then at ===================================== hadrian/src/Hadrian/Builder.hs ===================================== @@ -49,8 +49,8 @@ class ShakeValue b => Builder b where -- capture the @stdout@ result and return it. askBuilderWith :: b -> BuildInfo -> Action String - -- | Runtime dependencies of a builder. For example, on Windows GHC requires - -- the utility @touchy.exe@ to be available on a specific path. + -- | Runtime dependencies of a builder. For example, GHC requires the + -- utility @unlit@ to be available on a specific path. runtimeDependencies :: b -> Action [FilePath] runtimeDependencies _ = return [] ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -123,7 +123,6 @@ data SettingsFileSetting | SettingsFileSetting_InstallNameToolCommand | SettingsFileSetting_DllWrapCommand | SettingsFileSetting_WindresCommand - | SettingsFileSetting_TouchCommand | SettingsFileSetting_ClangCommand | SettingsFileSetting_LlcCommand | SettingsFileSetting_OptCommand @@ -220,7 +219,6 @@ settingsFileSetting key = lookupSystemConfig $ case key of SettingsFileSetting_InstallNameToolCommand -> "settings-install_name_tool-command" SettingsFileSetting_DllWrapCommand -> "settings-dll-wrap-command" SettingsFileSetting_WindresCommand -> "settings-windres-command" - SettingsFileSetting_TouchCommand -> "settings-touch-command" SettingsFileSetting_ClangCommand -> "settings-clang-command" SettingsFileSetting_LlcCommand -> "settings-llc-command" SettingsFileSetting_OptCommand -> "settings-opt-command" ===================================== hadrian/src/Packages.hs ===================================== @@ -8,7 +8,7 @@ module Packages ( ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, libffi, libiserv, mtl, parsec, pretty, primitive, process, remoteIserv, rts, - runGhc, stm, templateHaskell, terminfo, text, time, timeout, touchy, + runGhc, stm, templateHaskell, terminfo, text, time, timeout, transformers, unlit, unix, win32, xhtml, lintersCommon, lintNotes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace, ghcPackages, isGhcPackage, @@ -40,7 +40,7 @@ ghcPackages = , ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs , hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, libffi, libiserv, mtl , parsec, pretty, process, rts, runGhc, stm, templateHaskell - , terminfo, text, time, touchy, transformers, unlit, unix, win32, xhtml + , terminfo, text, time, transformers, unlit, unix, win32, xhtml , timeout , lintersCommon , lintNotes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace ] @@ -56,7 +56,7 @@ array, base, binary, bytestring, cabalSyntax, cabal, checkPpr, checkExact, count ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, remoteIserv, libffi, libiserv, mtl, parsec, pretty, primitive, process, rts, runGhc, stm, templateHaskell, - terminfo, text, time, touchy, transformers, unlit, unix, win32, xhtml, + terminfo, text, time, transformers, unlit, unix, win32, xhtml, timeout, lintersCommon, lintNotes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace :: Package @@ -117,7 +117,6 @@ terminfo = lib "terminfo" text = lib "text" time = lib "time" timeout = util "timeout" `setPath` "testsuite/timeout" -touchy = util "touchy" transformers = lib "transformers" unlit = util "unlit" unix = lib "unix" @@ -192,12 +191,12 @@ programName Context {..} = do -- | The 'FilePath' to a program executable in a given 'Context'. programPath :: Context -> Action FilePath programPath context at Context {..} = do - -- TODO: The @touchy@ utility lives in the @lib/bin@ directory instead of - -- @bin@, which is likely just a historical accident that should be fixed. - -- See: https://github.com/snowleopard/hadrian/issues/570 - -- Likewise for @iserv@ and @unlit at . + -- TODO: The @iserv@ and @unlit@ utilities live in the @lib/bin@ directory + -- instead of @bin@, which is likely just a historical accident that should + -- be fixed. See: + -- https://github.com/snowleopard/hadrian/issues/570 name <- programName context - path <- if package `elem` [iserv, touchy, unlit] + path <- if package `elem` [iserv, unlit] then stageLibPath stage <&> (-/- "bin") else stageBinPath stage return $ path -/- name <.> exe @@ -210,7 +209,7 @@ timeoutPath = "testsuite/timeout/install-inplace/bin/timeout" <.> exe -- TODO: Can we extract this information from Cabal files? -- | Some program packages should not be linked with Haskell main function. nonHsMainPackage :: Package -> Bool -nonHsMainPackage = (`elem` [hp2ps, iserv, touchy, unlit, ghciWrapper]) +nonHsMainPackage = (`elem` [hp2ps, iserv, unlit, ghciWrapper]) -- TODO: Combine this with 'programName'. -- | Path to the @autogen@ directory generated by 'buildAutogenFiles'. ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -325,7 +325,6 @@ generateSettings = do , ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand) , ("otool command", expr $ settingsFileSetting SettingsFileSetting_OtoolCommand) , ("install_name_tool command", expr $ settingsFileSetting SettingsFileSetting_InstallNameToolCommand) - , ("touch command", expr $ settingsFileSetting SettingsFileSetting_TouchCommand) , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand) , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand) , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) ===================================== hadrian/src/Rules/Program.hs ===================================== @@ -105,7 +105,7 @@ buildProgram bin ctx@(Context{..}) rs = do (True, s) | s > stage0InTree -> do srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin")) copyFile (srcDir -/- takeFileName bin) bin - (False, s) | s > stage0InTree && (package `elem` [touchy, unlit]) -> do + (False, s) | s > stage0InTree && (package `elem` [unlit]) -> do srcDir <- stageLibPath stage0InTree <&> (-/- "bin") copyFile (srcDir -/- takeFileName bin) bin _ -> buildBinary rs bin ctx ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -104,7 +104,6 @@ stage0Packages = do ] ++ [ terminfo | not windowsHost, not cross ] ++ [ timeout | windowsHost ] - ++ [ touchy | windowsHost ] ++ [ hp2ps | cross ] -- | Packages built in 'Stage1' by default. You can change this in "UserSettings". @@ -146,9 +145,8 @@ stage1Packages = do , runGhc ] , when (winTarget && not cross) - [ touchy - -- See Note [Hadrian's ghci-wrapper package] - , ghciWrapper + [ -- See Note [Hadrian's ghci-wrapper package] + ghciWrapper ] ] ===================================== m4/fp_settings.m4 ===================================== @@ -25,7 +25,6 @@ AC_DEFUN([FP_SETTINGS], SettingsRanlibCommand="${mingw_bin_prefix}llvm-ranlib.exe" SettingsDllWrapCommand="${mingw_bin_prefix}llvm-dllwrap.exe" SettingsWindresCommand="${mingw_bin_prefix}llvm-windres.exe" - SettingsTouchCommand='$$topdir/bin/touchy.exe' else # This case handles the "normal" platforms (e.g. not Windows) where we @@ -56,12 +55,6 @@ AC_DEFUN([FP_SETTINGS], SettingsWindresCommand="$WindresCmd" fi - if test "$HostOS" = "mingw32"; then - SettingsTouchCommand='$$topdir/bin/touchy.exe' - else - SettingsTouchCommand='touch' - fi - if test "$EnableDistroToolchain" = "YES"; then # If the user specified --enable-distro-toolchain then we just use the # executable names, not paths. @@ -123,7 +116,6 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsInstallNameToolCommand) AC_SUBST(SettingsDllWrapCommand) AC_SUBST(SettingsWindresCommand) - AC_SUBST(SettingsTouchCommand) AC_SUBST(SettingsClangCommand) AC_SUBST(SettingsLlcCommand) AC_SUBST(SettingsOptCommand) ===================================== utils/touchy/Makefile deleted ===================================== @@ -1,37 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2009 The University of Glasgow -# -# This file is part of the GHC build system. -# -# To understand how the build system works and how to modify it, see -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -# -# Substitute for 'touch' on win32 platforms (without an Unix toolset installed). -# -TOP=../.. -include $(TOP)/mk/boilerplate.mk - -C_SRCS=touchy.c -C_PROG=touchy -SRC_CC_OPTS += -O - -# -# Install touchy in lib/.* -# -INSTALL_LIBEXECS += $(C_PROG) - -include $(TOP)/mk/target.mk - -# Get it over with! -boot :: all - -binary-dist: - $(INSTALL_DIR) $(BIN_DIST_DIR)/utils/touchy - $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/utils/touchy/ - $(INSTALL_PROGRAM) $(C_PROG) $(BIN_DIST_DIR)/utils/touchy/ - ===================================== utils/touchy/touchy.c deleted ===================================== @@ -1,123 +0,0 @@ -/* - * Simple 'touch' program for Windows - * - */ -#if !defined(_WIN32) -#error "Win32-only, the platform you're using is supposed to have 'touch' already." -#else -#include -#include -#include -#include -#include -#include -#include - -/* -touch is used by GHC both during building and during compilation of -Haskell files. Unfortunately this means we need a 'touch' like program -in the GHC bindist. Since touch is not standard on Windows and msys2 -doesn't include a mingw-w64 build of coreutils we need touchy for now. - -With Windows 7 in a virtual box VM on OS X, some very odd things happen -with dates and time stamps when SSHing into cygwin. e.g. here the -"Change" time is in the past: - -$ date; touch foo; stat foo -Fri Dec 2 16:58:07 GMTST 2011 - File: `foo' - Size: 0 Blocks: 0 IO Block: 65536 regular -empty file -Device: 540aba0bh/1409989131d Inode: 562949953592977 Links: 1 -Access: (0644/-rw-r--r--) Uid: ( 1000/ ian) Gid: ( 513/ None) -Access: 2011-12-02 16:58:07.414457900 +0000 -Modify: 2011-12-02 16:58:07.414457900 +0000 -Change: 2011-12-02 16:58:03.495141800 +0000 - Birth: 2011-12-02 16:57:57.731469900 +0000 - -And if we copy such a file, then the copy is older (as determined by the -"Modify" time) than the original: - -$ date; touch foo; stat foo; cp foo bar; stat bar -Fri Dec 2 16:59:10 GMTST 2011 - File: `foo' - Size: 0 Blocks: 0 IO Block: 65536 regular -empty file -Device: 540aba0bh/1409989131d Inode: 1407374883725128 Links: 1 -Access: (0644/-rw-r--r--) Uid: ( 1000/ ian) Gid: ( 513/ None) -Access: 2011-12-02 16:59:10.118457900 +0000 -Modify: 2011-12-02 16:59:10.118457900 +0000 -Change: 2011-12-02 16:59:06.189477700 +0000 - Birth: 2011-12-02 16:57:57.731469900 +0000 - File: `bar' - Size: 0 Blocks: 0 IO Block: 65536 regular -empty file -Device: 540aba0bh/1409989131d Inode: 281474976882512 Links: 1 -Access: (0644/-rw-r--r--) Uid: ( 1000/ ian) Gid: ( 513/ None) -Access: 2011-12-02 16:59:06.394555800 +0000 -Modify: 2011-12-02 16:59:06.394555800 +0000 -Change: 2011-12-02 16:59:06.395532400 +0000 - Birth: 2011-12-02 16:58:40.921899600 +0000 - -This means that make thinks that things are out of date when it -shouldn't, so reinvokes itself repeatedly until the MAKE_RESTARTS -infinite-recursion test triggers. - -The touchy program, like most other programs, creates files with both -Modify and Change in the past, which is still a little odd, but is -consistent, so doesn't break make. - -We used to use _utime(argv[i],NULL)) to set the file modification times, -but after a BST -> GMT change this started giving files a modification -time an hour in the future: - -$ date; utils/touchy/dist/build/tmp/touchy testfile; stat testfile -Tue, Oct 30, 2012 11:33:06 PM - File: `testfile' - Size: 0 Blocks: 0 IO Block: 65536 regular empty file -Device: 540aba0bh/1409989131d Inode: 9851624184986293 Links: 1 -Access: (0755/-rwxr-xr-x) Uid: ( 1000/ ian) Gid: ( 513/ None) -Access: 2012-10-31 00:33:06.000000000 +0000 -Modify: 2012-10-31 00:33:06.000000000 +0000 -Change: 2012-10-30 23:33:06.769118900 +0000 - Birth: 2012-10-30 23:33:06.769118900 +0000 - -so now we use the Win32 functions GetSystemTimeAsFileTime and SetFileTime. -*/ - -int -main(int argc, char** argv) -{ - int i; - FILETIME ft; - BOOL b; - HANDLE hFile; - - if (argc == 1) { - fprintf(stderr, "Usage: %s \n", argv[0]); - return 1; - } - - for (i = 1; i < argc; i++) { - hFile = CreateFile(argv[i], GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile == INVALID_HANDLE_VALUE) { - fprintf(stderr, "Unable to open %s\n", argv[i]); - exit(1); - } - GetSystemTimeAsFileTime(&ft); - b = SetFileTime(hFile, (LPFILETIME) NULL, (LPFILETIME) NULL, &ft); - if (b == 0) { - fprintf(stderr, "Unable to change mod. time for %s\n", argv[i]); - exit(1); - } - b = CloseHandle(hFile); - if (b == 0) { - fprintf(stderr, "Closing failed for %s\n", argv[i]); - exit(1); - } - } - - return 0; -} -#endif ===================================== utils/touchy/touchy.cabal deleted ===================================== @@ -1,15 +0,0 @@ -cabal-version: 2.2 -Name: touchy -Version: 0.1 -Copyright: XXX -License: BSD-3-Clause -Author: XXX -Maintainer: XXX -Synopsis: @touch@ for windows -Description: XXX -Category: Development -build-type: Simple - -Executable touchy - Default-Language: Haskell2010 - Main-Is: touchy.c View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9282c41aed71e7ffdb3b760c14a8decd0703ca1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9282c41aed71e7ffdb3b760c14a8decd0703ca1 You're receiving 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 Nov 15 09:00:43 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 15 Nov 2022 04:00:43 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] 2 commits: Fix CPP Message-ID: <6373553b9a9b2_38f79f5294023383c@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 54221115 by Sylvain Henry at 2022-11-15T09:26:17+01:00 Fix CPP - - - - - 52f4ee8d by Sylvain Henry at 2022-11-15T09:59:19+01:00 Fix after Constraint-vs-Type patch - - - - - 8 changed files: - compiler/GHC/HsToCore/Foreign/JavaScript.hs - compiler/GHC/StgToJS/Expr.hs - libraries/base/GHC/Conc/Windows.hs - libraries/base/GHC/Event.hs - libraries/base/GHC/Event/Thread.hs - libraries/base/GHC/Event/TimerManager.hs - libraries/base/GHC/JS/Prim.hs - libraries/base/System/Posix/Internals.hs Changes: ===================================== compiler/GHC/HsToCore/Foreign/JavaScript.hs ===================================== @@ -291,7 +291,7 @@ dsJsFExportDynamic id co0 cconv = do stable_ptr_ty = mkTyConApp stable_ptr_tycon [arg_ty] export_ty = mkVisFunTyMany stable_ptr_ty arg_ty bindIOId <- dsLookupGlobalId bindIOName - stbl_value <- newSysLocalDs Many stable_ptr_ty + stbl_value <- newSysLocalDs ManyTy stable_ptr_ty (h_code, c_code, typestring, args_size) <- dsJsFExport id (mkRepReflCo export_ty) fe_nm cconv True let {- @@ -366,7 +366,7 @@ dsJsCall fn_id co (CCall (CCallSpec target cconv safety)) _mDeclHeader = do tvs = map binderVar tv_bndrs the_ccall_app = mkFCall ccall_uniq fcall val_args ccall_result_ty work_rhs = mkLams tvs (mkLams work_arg_ids the_ccall_app) - work_id = mkSysLocal (fsLit "$wccall") work_uniq Many worker_ty + work_id = mkSysLocal (fsLit "$wccall") work_uniq ManyTy worker_ty -- Build the wrapper work_app = mkApps (mkVarApps (Var work_id) tvs) val_args @@ -434,8 +434,8 @@ unboxJsArg arg -- Data types with a single constructor, which has a single, primitive-typed arg -- This deals with Int, Float etc; also Ptr, ForeignPtr | is_product_type && data_con_arity == 1 - = do case_bndr <- newSysLocalDs Many arg_ty - prim_arg <- newSysLocalDs Many (scaledThing data_con_arg_ty1) + = do case_bndr <- newSysLocalDs ManyTy arg_ty + prim_arg <- newSysLocalDs ManyTy (scaledThing data_con_arg_ty1) return (Var prim_arg, \ body -> Case arg case_bndr (exprType body) [Alt (DataAlt data_con) [prim_arg] body] ) @@ -449,7 +449,7 @@ unboxJsArg arg isJust maybe_arg3_tycon && (arg3_tycon == byteArrayPrimTyCon || arg3_tycon == mutableByteArrayPrimTyCon) - = do case_bndr <- newSysLocalDs Many arg_ty + = do case_bndr <- newSysLocalDs ManyTy arg_ty vars@[_l_var, _r_var, arr_cts_var] <- newSysLocalsDs data_con_arg_tys return (Var arr_cts_var, \ body -> Case arg case_bndr (exprType body) [Alt (DataAlt data_con) vars body] @@ -497,16 +497,11 @@ boxJsResult result_ty -- The result is IO t, so wrap the result in an IO constructor = do { res <- jsResultWrapper io_res_ty ; let return_result state ans - = mkCoreUbxTup - [realWorldStatePrimTy, io_res_ty] - [state, ans] -{- = mkConApp (tupleDataCon Unboxed 2) - (map Type [realWorldStatePrimTy, io_res_ty] - ++ [state, ans]) -} + = mkCoreUnboxedTuple [state, ans] ; (ccall_res_ty, the_alt) <- mk_alt return_result res - ; state_id <- newSysLocalDs Many realWorldStatePrimTy + ; state_id <- newSysLocalDs ManyTy realWorldStatePrimTy ; let io_data_con = head (tyConDataCons io_tycon) toIOCon = dataConWrapId io_data_con @@ -541,7 +536,7 @@ mk_alt :: (Expr Var -> Expr Var -> Expr Var) -> DsM (Type, CoreAlt) mk_alt return_result (Nothing, wrap_result) = do -- The ccall returns () - state_id <- newSysLocalDs Many realWorldStatePrimTy + state_id <- newSysLocalDs ManyTy realWorldStatePrimTy let the_rhs = return_result (Var state_id) (wrap_result $ panic "jsBoxResult") @@ -555,11 +550,10 @@ mk_alt return_result (Just prim_res_ty, wrap_result) let Just ls = fmap dropRuntimeRepArgs (tyConAppArgs_maybe prim_res_ty) arity = 1 + length ls - args_ids {-@(result_id:as)-} <- mapM (newSysLocalDs Many) ls - state_id <- newSysLocalDs Many realWorldStatePrimTy + args_ids <- mapM (newSysLocalDs ManyTy) ls + state_id <- newSysLocalDs ManyTy realWorldStatePrimTy let - result_tup = -- mkCoreConApps (tupleDataCon Unboxed (length ls)) (map Type ls ++ map Var args_ids) - mkCoreUbxTup ls (map Var args_ids) + result_tup = mkCoreUnboxedTuple (map Var args_ids) the_rhs = return_result (Var state_id) (wrap_result result_tup) ccall_res_ty = mkTupleTy Unboxed (realWorldStatePrimTy : ls) @@ -569,8 +563,8 @@ mk_alt return_result (Just prim_res_ty, wrap_result) return (ccall_res_ty, the_alt) | otherwise = do - result_id <- newSysLocalDs Many prim_res_ty - state_id <- newSysLocalDs Many realWorldStatePrimTy + result_id <- newSysLocalDs ManyTy prim_res_ty + state_id <- newSysLocalDs ManyTy realWorldStatePrimTy let the_rhs = return_result (Var state_id) (wrap_result (Var result_id)) @@ -597,14 +591,13 @@ jsResultWrapper result_ty , isUnboxedTupleTyCon tc {- && False -} = do let args' = dropRuntimeRepArgs args (tys, wrappers) <- unzip <$> mapM jsResultWrapper args' - matched <- mapM (mapM (newSysLocalDs Many)) tys + matched <- mapM (mapM (newSysLocalDs ManyTy)) tys let tys' = catMaybes tys -- arity = length args' -- resCon = tupleDataCon Unboxed (length args) err = panic "jsResultWrapper: used Id with result type Nothing" resWrap :: CoreExpr - resWrap = mkCoreUbxTup args' (zipWith (\w -> w . Var . fromMaybe err) wrappers matched) - -- mkCoreConApps resCon (map Type args ++ zipWith (\w -> w . Var . fromMaybe err) wrappers matched) + resWrap = mkCoreUnboxedTuple (zipWith (\w -> w . Var . fromMaybe err) wrappers matched) return $ if null tys' then (Nothing, \_ -> resWrap) @@ -629,7 +622,7 @@ jsResultWrapper result_ty let args' = dropRuntimeRepArgs args innerTy = mkTupleTy Unboxed args' (inner_res, w) <- jsResultWrapper innerTy - matched <- mapM (newSysLocalDs Many) args' + matched <- mapM (newSysLocalDs ManyTy) args' let inner e = mkWildCase (w e) (unrestricted innerTy) result_ty [ Alt (DataAlt (tupleDataCon Unboxed (length args'))) matched ===================================== compiler/GHC/StgToJS/Expr.hs ===================================== @@ -367,7 +367,7 @@ resultSize args i = result trim_args t 0 = typePrimRep t trim_args t n - | Just (_mult, arg, res) <- splitFunTy_maybe t + | Just (_af, _mult, arg, res) <- splitFunTy_maybe t , nargs <- length (typePrimRepArgs arg) , assert (n >= nargs) True = trim_args (unwrapType res) (n - nargs) ===================================== libraries/base/GHC/Conc/Windows.hs ===================================== @@ -19,7 +19,7 @@ -- #not-home module GHC.Conc.Windows -#ifdef js_HOST_ARCH +#if defined(js_HOST_ARCH) () where #else ( ensureIOManagerIsRunning ===================================== libraries/base/GHC/Event.hs ===================================== @@ -11,7 +11,7 @@ -- ---------------------------------------------------------------------------- module GHC.Event -#ifdef js_HOST_ARCH +#if defined(js_HOST_ARCH) ( ) where #else ( -- * Types ===================================== libraries/base/GHC/Event/Thread.hs ===================================== @@ -1,10 +1,11 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE BangPatterns, NoImplicitPrelude #-} -{-# LANGUAGE CPP #-} + +#include module GHC.Event.Thread -#ifdef js_HOST_ARCH +#if defined(js_HOST_ARCH) ( ) where #else ( getSystemEventManager @@ -21,7 +22,6 @@ module GHC.Event.Thread , blockedOnBadFD -- used by RTS ) where -#include -- TODO: Use new Windows I/O manager import Control.Exception (finally, SomeException, toException) ===================================== libraries/base/GHC/Event/TimerManager.hs ===================================== @@ -7,7 +7,7 @@ -- TODO: use the new Windows IO manager module GHC.Event.TimerManager -#ifdef js_HOST_ARCH +#if defined(js_HOST_ARCH) () where #else ( -- * Types ===================================== libraries/base/GHC/JS/Prim.hs ===================================== @@ -1,14 +1,16 @@ -{-# LANGUAGE MagicHash, DeriveDataTypeable, ScopedTypeVariables, CPP #-} -{-# LANGUAGE JavaScriptFFI, - GHCForeignImportPrim, - UnliftedFFITypes, - UnboxedTuples - #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE MagicHash #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE JavaScriptFFI #-} +{-# LANGUAGE GHCForeignImportPrim #-} +{-# LANGUAGE UnliftedFFITypes #-} +{-# LANGUAGE UnboxedTuples #-} module GHC.JS.Prim ( JSVal(..), JSVal# , JSException(..) , WouldBlockException(..) -#ifdef js_HOST_ARCH +#if defined(js_HOST_ARCH) , toIO , resolve , resolveIO @@ -52,7 +54,7 @@ import GHC.IO argument or result. -} -#ifdef js_HOST_ARCH +#if defined(js_HOST_ARCH) data JSVal = JSVal ByteArray# type JSVal# = ByteArray# #else @@ -73,8 +75,7 @@ instance Ex.Exception JSException instance Show JSException where show (JSException _ xs) = "JavaScript exception: " ++ xs --- FIXME: Luite (2022,05): appropriate CPP conditionals -#ifdef js_HOST_ARCH +#if defined(js_HOST_ARCH) {-# NOINLINE toIO #-} toIO :: Exts.Any -> IO Exts.Any ===================================== libraries/base/System/Posix/Internals.hs ===================================== @@ -445,7 +445,7 @@ foreign import ccall unsafe "HsBase.h __hscore_lstat" #endif -#ifdef js_HOST_ARCH +#if defined(js_HOST_ARCH) foreign import javascript unsafe "(() => { return rts_isThreaded; })" rtsIsThreaded_ :: Int foreign import javascript interruptible "(($1_1, $2_2, $2, $c) => { return h$base_access($1_1,$2_2,$2,$c); })" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed531a5c3cebc77544e569076e53a8706f84f47a...52f4ee8da6b65905e6e20be123997f06a8f80b85 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ed531a5c3cebc77544e569076e53a8706f84f47a...52f4ee8da6b65905e6e20be123997f06a8f80b85 You're receiving 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 Nov 15 09:24:01 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 15 Nov 2022 04:24:01 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] 2 commits: Fix hlint Message-ID: <63735ab132493_38f79f52904252029@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: b26ec09b by Sylvain Henry at 2022-11-15T10:25:07+01:00 Fix hlint - - - - - fb6b71d1 by Sylvain Henry at 2022-11-15T10:27:45+01:00 Update ci - - - - - 3 changed files: - .gitlab/jobs.yaml - compiler/GHC/StgToJS/Monad.hs - compiler/GHC/StgToJS/Stack.hs Changes: ===================================== .gitlab/jobs.yaml ===================================== @@ -1328,7 +1328,7 @@ "XZ_OPT": "-9" } }, - "nightly-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release": { + "nightly-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -1338,7 +1338,7 @@ "artifacts": { "expire_in": "8 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate.tar.xz", "junit.xml" ], "reports": { @@ -1380,12 +1380,12 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate", + "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", "CROSS_TARGET": "js-unknown-ghcjs", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate", "XZ_OPT": "-9" } }, @@ -3871,7 +3871,7 @@ "TEST_ENV": "x86_64-linux-deb11-cross_aarch64-linux-gnu-validate" } }, - "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release": { + "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate": { "after_script": [ ".gitlab/ci.sh save_cache", ".gitlab/ci.sh clean", @@ -3881,7 +3881,7 @@ "artifacts": { "expire_in": "2 weeks", "paths": [ - "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release.tar.xz", + "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate.tar.xz", "junit.xml" ], "reports": { @@ -3923,12 +3923,12 @@ ], "variables": { "BIGNUM_BACKEND": "native", - "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release", - "BUILD_FLAVOUR": "release", + "BIN_DIST_NAME": "ghc-x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate", + "BUILD_FLAVOUR": "validate", "CONFIGURE_ARGS": "--with-intree-gmp", "CONFIGURE_WRAPPER": "emconfigure", "CROSS_TARGET": "js-unknown-ghcjs", - "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-release" + "TEST_ENV": "x86_64-linux-deb11-int_native-cross_js-unknown-ghcjs-validate" } }, "x86_64-linux-deb11-validate": { ===================================== compiler/GHC/StgToJS/Monad.hs ===================================== @@ -1,5 +1,4 @@ {-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TupleSections #-} {-# LANGUAGE LambdaCase #-} -- | JS codegen state monad ===================================== compiler/GHC/StgToJS/Stack.hs ===================================== @@ -220,7 +220,6 @@ pushN = listArray (1,32) $ map (TxtI . mkFastString . ("h$p"++) . show) [(1::Int -- functions. pushN' :: Array Int JExpr pushN' = fmap (ValExpr . JVar) pushN - where -- | Partial Push functions. Like 'pushN' except these push functions skip -- slots. For example, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/52f4ee8da6b65905e6e20be123997f06a8f80b85...fb6b71d1771df4e4ffd54a63ffaa0df2812a91ff -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/52f4ee8da6b65905e6e20be123997f06a8f80b85...fb6b71d1771df4e4ffd54a63ffaa0df2812a91ff You're receiving 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 Nov 15 10:16:36 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 15 Nov 2022 05:16:36 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] 2 commits: Revert useless change Message-ID: <63736704ee428_38f79f529402647dc@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: d09671ed by Sylvain Henry at 2022-11-15T11:09:42+01:00 Revert useless change - - - - - 5267d295 by Sylvain Henry at 2022-11-15T11:20:17+01:00 Always bundle libffi headers - - - - - 2 changed files: - hadrian/src/Rules/Generate.hs - hadrian/src/Way/Type.hs Changes: ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -42,7 +42,6 @@ rtsDependencies = do stage <- getStage rtsPath <- expr (rtsBuildPath stage) jsTarget <- expr isJsTarget - useSystemFfi <- expr (flag UseSystemFfi) let -- headers common to native and JS RTS common_headers = @@ -54,7 +53,7 @@ rtsDependencies = do [ "rts" -/- "EventTypes.h" , "rts" -/- "EventLogConstants.h" ] - ++ (if useSystemFfi then [] else libffiHeaderFiles) + ++ libffiHeaderFiles headers | jsTarget = common_headers | otherwise = common_headers ++ native_headers ===================================== hadrian/src/Way/Type.hs ===================================== @@ -1,5 +1,5 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE DerivingStrategies #-} module Way.Type where import Data.IntSet (IntSet) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb6b71d1771df4e4ffd54a63ffaa0df2812a91ff...5267d295ec83591994b258a1f8fd13eb3fb5eae7 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fb6b71d1771df4e4ffd54a63ffaa0df2812a91ff...5267d295ec83591994b258a1f8fd13eb3fb5eae7 You're receiving 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 Nov 15 11:00:10 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 15 Nov 2022 06:00:10 -0500 Subject: [Git][ghc/ghc][wip/T18927] More changes, committing so that we see a segfault Message-ID: <6373713a57b41_38f79f528a02935f8@gitlab.mail> Sebastian Graf pushed to branch wip/T18927 at Glasgow Haskell Compiler / GHC Commits: 07a4f966 by Sebastian Graf at 2022-11-15T11:32:26+01:00 More changes, committing so that we see a segfault - - - - - 5 changed files: - compiler/GHC/Core/Opt/DmdAnal.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Data/SArr.hs - compiler/GHC/Types/Demand.hs Changes: ===================================== compiler/GHC/Core/Opt/DmdAnal.hs ===================================== @@ -40,10 +40,11 @@ import GHC.Utils.Misc import GHC.Utils.Panic import GHC.Utils.Panic.Plain import GHC.Data.Maybe ( isJust ) +import GHC.Data.SArr (SArr, Slice) +import qualified GHC.Data.SArr as SArr import GHC.Builtin.PrimOps import GHC.Builtin.Types.Prim ( realWorldStatePrimTy ) import GHC.Types.Unique.Set -import GHC.Exts ( IsList(..) ) import GHC.Utils.Trace _ = pprTrace -- Tired of commenting out the import all the time @@ -445,8 +446,8 @@ dmdAnal' env dmd (Case scrut case_bndr ty [Alt alt bndrs rhs]) | DataAlt _ <- alt -- See Note [Demand on the scrutinee of a product case] -- See Note [Demand on case-alternative binders] - , (!scrut_sd, fld_dmds') <- addCaseBndrDmd case_bndr_sd (fromList fld_dmds) - , let !bndrs' = setBndrsDemandInfo bndrs fld_dmds' + , (!scrut_sd, fld_dmds') <- addCaseBndrDmd case_bndr_sd (SArr.fromList fld_dmds) + , let !bndrs' = setBndrsDemandInfo bndrs (SArr.slice fld_dmds') = (bndrs', scrut_sd) | otherwise -- __DEFAULT and literal alts. Simply add demands and discard the @@ -560,26 +561,26 @@ dmdAnalSumAlt env dmd case_bndr (Alt con bndrs rhs) -- See Note [Demand on case-alternative binders] -- we can't use the scrut_sd, because it says 'Prod' and we'll use -- topSubDmd anyway for scrutinees of sum types. - (!_scrut_sd, dmds') = addCaseBndrDmd case_bndr_sd dmds + (!_scrut_sd, dmds') = addCaseBndrDmd case_bndr_sd (SArr.fromList dmds) -- Do not put a thunk into the Alt - !new_ids = setBndrsDemandInfo bndrs dmds' + !new_ids = setBndrsDemandInfo bndrs (SArr.slice dmds') = WithDmdType alt_ty (Alt con new_ids rhs') -- Precondition: The SubDemand is not a Call -- See Note [Demand on the scrutinee of a product case] -- and Note [Demand on case-alternative binders] addCaseBndrDmd :: SubDemand -- On the case binder - -> [Demand] -- On the fields of the constructor - -> (SubDemand, [Demand]) + -> SArr Demand -- On the fields of the constructor + -> (SubDemand, SArr Demand) -- SubDemand on the case binder incl. field demands -- and final demands for the components of the constructor addCaseBndrDmd case_sd fld_dmds | Just (_, ds) <- viewProd (length fld_dmds) scrut_sd - = (scrut_sd, toList ds) + = (scrut_sd, ds) | otherwise = pprPanic "was a call demand" (ppr case_sd $$ ppr fld_dmds) -- See the Precondition where - scrut_sd = case_sd `plusSubDmd` mkProd Unboxed (fromList fld_dmds) + scrut_sd = case_sd `plusSubDmd` mkProd Unboxed fld_dmds {- Note [Analysing with absent demand] @@ -1344,10 +1345,10 @@ conservative thing and refrain from strictifying a dfun's argument dictionaries. -} -setBndrsDemandInfo :: HasCallStack => [Var] -> [Demand] -> [Var] +setBndrsDemandInfo :: HasCallStack => [Var] -> Slice Demand -> [Var] setBndrsDemandInfo (b:bs) ds | isTyVar b = b : setBndrsDemandInfo bs ds -setBndrsDemandInfo (b:bs) (d:ds) = +setBndrsDemandInfo (b:bs) (d SArr.:<| ds) = let !new_info = setIdDemandInfo b d !vars = setBndrsDemandInfo bs ds in new_info : vars ===================================== compiler/GHC/Core/Opt/SpecConstr.hs ===================================== @@ -57,6 +57,7 @@ import GHC.Types.Unique.FM import GHC.Data.Maybe ( orElse, catMaybes, isJust, isNothing ) import GHC.Data.Pair +import qualified GHC.Data.SArr as SArr import GHC.Data.FastString import GHC.Utils.Misc @@ -69,7 +70,7 @@ import GHC.Utils.Trace import GHC.Builtin.Names ( specTyConKey ) -import GHC.Exts( SpecConstrAnnotation(..), IsList(..) ) +import GHC.Exts( SpecConstrAnnotation(..) ) import GHC.Serialized ( deserializeWithData ) import Control.Monad ( zipWithM ) @@ -1836,19 +1837,19 @@ calcSpecInfo fn (CP { cp_qvars = qvars, cp_args = pats }) extra_bndrs set_dmds (v:vs) ds@(d:ds') | isTyVar v = v : set_dmds vs ds | otherwise = setIdDemandInfo v d : set_dmds vs ds' - dmd_env = go emptyVarEnv fn_dmds val_pats + dmd_env = go emptyVarEnv (SArr.slice $ SArr.fromList fn_dmds) val_pats - go :: DmdEnv -> [Demand] -> [CoreExpr] -> DmdEnv + go :: DmdEnv -> SArr.Slice Demand -> [CoreExpr] -> DmdEnv -- We've filtered out all the type patterns already - go env (d:ds) (pat : pats) = go (go_one env d pat) ds pats - go env _ _ = env + go env (d SArr.:<| ds) (pat : pats) = go (go_one env d pat) ds pats + go env _ _ = env go_one :: DmdEnv -> Demand -> CoreExpr -> DmdEnv go_one env d (Var v) = extendVarEnv_C plusDmd env v d go_one env (_n :* cd) e -- NB: _n does not have to be strict | (Var _, args) <- collectArgs e , Just (_b, ds) <- viewProd (length args) cd -- TODO: We may want to look at boxity _b, though... - = go env (toList ds) args + = go env (SArr.slice ds) args go_one env _ _ = env ===================================== compiler/GHC/Core/Opt/WorkWrap/Utils.hs ===================================== @@ -51,6 +51,8 @@ import GHC.Data.FastString import GHC.Data.Maybe import GHC.Data.OrdList import GHC.Data.List.SetOps +import GHC.Data.SArr (SArr) +import qualified GHC.Data.SArr as SArr import GHC.Builtin.Types ( tupleDataCon ) @@ -554,7 +556,7 @@ data UnboxingDecision s -- ^ We ran out of strictness info. Leave untouched. | DropAbsent -- ^ The argument/field was absent. Drop it. - | Unbox !DataConPatContext [s] + | Unbox !DataConPatContext !(SArr s) -- ^ The argument is used strictly or the returned product was constructed, so -- unbox it. -- The 'DataConPatContext' carries the bits necessary for @@ -581,7 +583,7 @@ wantToUnboxArg fam_envs ty (n :* sd) , Just (Unboxed, ds) <- viewProd arity sd -- See Note [Boxity Analysis] -- NB: No strictness or evaluatedness checks here. That is done by -- 'finaliseBoxity'! - = Unbox (DataConPatContext dc tc_args co) (toList ds) + = Unbox (DataConPatContext dc tc_args co) ds | otherwise = StopUnboxing @@ -605,7 +607,7 @@ wantToUnboxResult fam_envs ty cpr -- Deactivates CPR worker/wrapper splits on constructors with non-linear -- arguments, for the moment, because they require unboxed tuple with variable -- multiplicity fields. - = Unbox (DataConPatContext dc tc_args co) arg_cprs + = Unbox (DataConPatContext dc tc_args co) (SArr.fromList arg_cprs) | otherwise = StopUnboxing @@ -965,7 +967,7 @@ mkWWstr_one opts arg = unbox_one_arg :: WwOpts -> Var - -> [Demand] + -> SArr Demand -> DataConPatContext -> UniqSM (Bool, [Var], CoreExpr -> CoreExpr, CoreExpr) unbox_one_arg opts arg_var ds @@ -975,7 +977,7 @@ unbox_one_arg opts arg_var ds ; let ex_name_fss = map getOccFS $ dataConExTyCoVars dc (ex_tvs', arg_ids) = dataConRepFSInstPat (ex_name_fss ++ repeat ww_prefix) pat_bndrs_uniqs (idMult arg_var) dc tc_args - arg_ids' = zipWithEqual "unbox_one_arg" setIdDemandInfo arg_ids ds + arg_ids' = zipWithEqual "unbox_one_arg" (flip setIdDemandInfo) (toList ds) arg_ids unbox_fn = mkUnpackCase (Var arg_var) co (idMult arg_var) dc (ex_tvs' ++ arg_ids') ; (_, worker_args, wrap_fn, wrap_args) <- mkWWstr opts (ex_tvs' ++ arg_ids') @@ -1284,7 +1286,7 @@ findTypeShape fam_envs ty -- don't matter. -- We really do encounter existentials here, see -- Note [Which types are unboxed?] for an example. - = TsProd (map (go rec_tc) (dubiousDataConInstArgTys con tc_args)) + = TsProd (fromList $ map (go rec_tc) (dubiousDataConInstArgTys con tc_args)) | Just (ty', _) <- instNewTyCon_maybe tc tc_args , Just rec_tc <- checkRecTc rec_tc tc @@ -1449,7 +1451,7 @@ finaliseBoxity env in_inl_fun ty dmd = go NotMarkedStrict ty dmd -- See Note [Do not unbox class dictionaries] , in_inl_fun == NotInsideInlineableFun || not (isClassPred ty) -- See Note [mkWWstr and unsafeCoerce] - , ds `lengthIs` dataConRepArity dc + , length ds == dataConRepArity dc , let arg_tys = dubiousDataConInstArgTys dc tc_args -> -- pprTrace "finaliseBoxity:Unbox" (ppr ty $$ ppr dmd $$ ppr ds) $ n :* (mkProd Unboxed $! zip_go_with_marks dc arg_tys ds) @@ -1458,9 +1460,9 @@ finaliseBoxity env in_inl_fun ty dmd = go NotMarkedStrict ty dmd -- See Note [Unboxing evaluated arguments] zip_go_with_marks dc arg_tys ds = case dataConWrapId_maybe dc of - Nothing -> fromList $ strictZipWith (go NotMarkedStrict) arg_tys ds + Nothing -> SArr.zipWith (go NotMarkedStrict) (fromList arg_tys) ds -- Shortcut when DataCon worker=wrapper - Just _ -> fromList $ strictZipWith3 go (dataConRepStrictness dc) arg_tys ds + Just _ -> SArr.zipWith3 go (fromList $ dataConRepStrictness dc) (fromList arg_tys) ds {- ************************************************************************ @@ -1541,7 +1543,7 @@ mkWWcpr_one :: WwOpts -> Id -> Cpr -> UniqSM CprWwResultOne mkWWcpr_one opts res_bndr cpr | assert (not (isTyVar res_bndr) ) True , Unbox dcpc arg_cprs <- wantToUnboxResult (wo_fam_envs opts) (idType res_bndr) cpr - = unbox_one_result opts res_bndr arg_cprs dcpc + = unbox_one_result opts res_bndr (SArr.toList arg_cprs) dcpc | otherwise = return (False, unitOL res_bndr, varToCoreExpr res_bndr, nop_fn) ===================================== compiler/GHC/Data/SArr.hs ===================================== @@ -1,4 +1,5 @@ {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-} +{-# OPTIONS_GHC -ddump-simpl -ddump-to-file #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE RankNTypes #-} @@ -16,20 +17,24 @@ module GHC.Data.SArr ( -- * Indexing get, unsafeGet, (!), -- * Construction - take, drop, replicate, + fromList, toList, take, drop, replicate, -- * Slicing Slice(Empty,(:<|),(:|>)), slice, toSArr, takeS, dropS, -- * Other operations - all, map, zipWith + all, map, zipWith, zipWith3 ) where -import Prelude hiding (replicate, drop, take, head, init, map, all, zipWith) +import Prelude hiding (replicate, drop, take, head, init, map, all, zipWith, zipWith3) import qualified Prelude import qualified Data.List as List import qualified GHC.Exts as Exts +import qualified GHC.Utils.Binary as Binary import GHC.ST -import GHC.Stack +import GHC.Utils.Misc +import GHC.Utils.Outputable + +import Data.Maybe -- | A general-purpose array type that is strict in its elements and the -- combinators of which enjoy list fusion. @@ -63,7 +68,7 @@ instance Show a => Show (SArr a) where showsPrec p arr = showParen (p >= 10) $ showString "fromList " . shows (toList arr) -die :: String -> String -> a +die :: HasDebugCallStack => String -> String -> a die fun problem = error (fun ++ ": " ++ problem) {-# NOINLINE die #-} @@ -117,7 +122,7 @@ createSmallArrayN (Exts.I# n) x f = runST $ ST $ \s -> {-# INLINE createSmallArrayN #-} createSmallArray - :: a + :: HasDebugCallStack => a -> (forall s. Exts.SmallMutableArray# s a -> USTL s (Exts.SmallMutableArray# s a)) -> SArr a createSmallArray x f = runST $ ST $ \s -> @@ -128,6 +133,7 @@ createSmallArray x f = runST $ ST $ \s -> !s3 = Exts.shrinkSmallMutableArray# sma' n s2 !(# s4, sa #) = Exts.unsafeFreezeSmallArray# sma' s3 -- !_ = trace ("create: " ++ show (Exts.I# n) ++ show (Exts.I# m)) () + !() = foldr seq () (SArr sa) in (# s4, SArr sa #) {-# INLINE createSmallArray #-} @@ -163,11 +169,11 @@ ifoldrUST f b as s = ifoldr c z as b s z = Exts.oneShot $ \(Exts.I# i) -> Exts.oneShot $ \b s -> (# s, b, i #) {-# INLINE ifoldrUST #-} -dieFromList :: a +dieFromList :: HasDebugCallStack => a dieFromList = die "fromList" "uninitialized element" {-# NOINLINE dieFromList #-} -fromList :: [a] -> SArr a +fromList :: HasDebugCallStack => [a] -> SArr a fromList l = createSmallArray dieFromList $ Exts.oneShot $ \sma -> ifoldrUST (\(Exts.I# i) a sma' s -> a `seq` writeResize i a sma' s) sma l @@ -175,11 +181,11 @@ fromList l = -- we need [2], otherwise FB's (and their builds) will be rewritten back to -- list producing functions and we can't fuse away the ifoldr -dieWriteResize :: a +dieWriteResize :: HasDebugCallStack => a dieWriteResize = die "writeResize" "uninitialized element" {-# NOINLINE dieWriteResize #-} -writeResize :: Exts.Int# -> a -> Exts.SmallMutableArray# s a -> UST s (Exts.SmallMutableArray# s a) +writeResize :: HasDebugCallStack => Exts.Int# -> a -> Exts.SmallMutableArray# s a -> UST s (Exts.SmallMutableArray# s a) writeResize i a sma s = let !(# s1, n #) = Exts.getSizeofSmallMutableArray# sma s -- TODO: cache this !(# s2, sma' #) @@ -190,19 +196,19 @@ writeResize i a sma s = in (# s3, sma' #) {-# NOINLINE writeResize #-} -dieFromListN :: HasCallStack => a +dieFromListN :: HasDebugCallStack => a dieFromListN = die "fromListN" "uninitialized element" {-# NOINLINE dieFromListN #-} -fromListN :: HasCallStack => Int -> [a] -> SArr a +fromListN :: HasDebugCallStack => Int -> [a] -> SArr a fromListN n l = createSmallArrayN n dieFromListN $ Exts.oneShot $ \sma s -> case ifoldrUST (\(Exts.I# i) a _sma s -> a `seq` (# Exts.writeSmallArray# sma i a s, sma #)) sma l s of (# s', _sma, _n #) -> (# s', sma #) {-# INLINE [2] fromListN #-} -toList :: SArr a -> [a] -toList arr = Prelude.map (\i -> unsafeGet i arr) [0..length arr-1] +toList :: HasDebugCallStack => SArr a -> [a] +toList arr = Prelude.map (\i -> fromJust $ get i arr) [0..length arr-1] {-# INLINE [2] toList #-} len :: SArr a -> Int @@ -213,14 +219,19 @@ all :: (a -> Bool) -> SArr a -> Bool all cond = List.all cond . toList {-# INLINE [2] all #-} -map :: (a -> b) -> SArr a -> SArr b -map f a = fromList $ Prelude.map f (toList a) +map :: HasDebugCallStack => (a -> b) -> SArr a -> SArr b +map f = fromList . Prelude.map f . toList {-# INLINE [2] map #-} zipWith :: (a -> b -> c) -> SArr a -> SArr b -> SArr c zipWith f a b = fromListN (min (len a) (len b)) $ Prelude.zipWith f (toList a) (toList b) {-# INLINE [2] zipWith #-} +zipWith3 :: HasDebugCallStack => (a -> b -> c -> d) -> SArr a -> SArr b -> SArr c -> SArr d +zipWith3 f a b c = fromListN (len a `min` len b `min` len c) $ + Prelude.zipWith3 f (toList a) (toList b) (toList c) +{-# INLINE [2] zipWith3 #-} + instance Eq a => Eq (SArr a) where a1 == a2 = len a1 == len a2 && and (Prelude.map (\i -> a1 ! i == a2 ! i) [0..len a1]) @@ -238,9 +249,9 @@ fromListA l = {-# RULES "toList/fromList" forall xs. toList (fromList xs) = xs -"toList/fromListN" forall n xs. toList (fromListN n xs) = xs +"toList/fromListN" forall n xs. toList (fromListN n xs) = List.take n xs "fromList/toList" forall arr. fromList (toList arr) = arr -"fromListN/toList" forall n arr. fromListN n (toList arr) = arr +-- "fromListN/toList" forall n arr. fromListN n (toList arr) = arr -- Unsafe: What if n != len arr? We need the copy here "len/fromListN" forall n arr. len (fromListN n arr) = n #-} @@ -383,3 +394,10 @@ pattern a :<| rest <- (head -> Just (a, rest)) pattern (:|>) :: Slice a -> a -> Slice a pattern rest :|> a <- (init -> Just (rest, a)) {-# COMPLETE Empty, (:|>) #-} + +instance Binary.Binary a => Binary.Binary (SArr a) where + put_ bh a = Binary.put_ bh (toList a) + get bh = fromList <$> Binary.get bh + +instance Outputable a => Outputable (SArr a) where + ppr = ppr . toList ===================================== compiler/GHC/Types/Demand.hs ===================================== @@ -93,8 +93,6 @@ import GHC.Data.Maybe ( orElse ) import GHC.Data.SArr ( SArr, Slice(..), slice ) import qualified GHC.Data.SArr as SArr -import GHC.Exts ( IsList(..) ) - import GHC.Core.Type ( Type ) import GHC.Core.TyCon ( isNewTyCon, isClassTyCon ) import GHC.Core.DataCon ( splitDataProductType_maybe ) @@ -737,9 +735,9 @@ mkProd :: Boxity -> SArr Demand -> SubDemand mkProd b ds | SArr.all (== AbsDmd) ds = Poly b C_00 | SArr.all (== BotDmd) ds = Poly b C_10 - | dmd@(n :* Poly Boxed m):<|_ <- slice ds -- don't rewrite P(L!L) - , n == m -- don't rewrite P(1L) - , SArr.all (== dmd) ds -- don't rewrite P(L,A) + | dmd@(n :* Poly Boxed m) :<| _ <- slice ds -- don't rewrite P(L!L) + , n == m -- don't rewrite P(1L) + , SArr.all (== dmd) ds -- don't rewrite P(L,A) = Poly b n | otherwise = Prod b ds @@ -944,7 +942,7 @@ strictifyDictDmd :: Type -> Demand -> Demand strictifyDictDmd ty (n :* Prod b ds) | not (isAbs n) , Just field_tys <- as_non_newtype_dict ty - = C_1N :* mkProd b (SArr.zipWith strictifyDictDmd (fromList field_tys) ds) + = C_1N :* mkProd b (SArr.zipWith strictifyDictDmd (SArr.fromList field_tys) ds) -- main idea: ensure it's strict where -- | Return a TyCon and a list of field types if the given @@ -1954,7 +1952,7 @@ dmdTransformSig (DmdSig dmd_ty@(DmdType _ arg_ds _)) sd -- demands into the constructor arguments. dmdTransformDataConSig :: Arity -> DmdTransformer dmdTransformDataConSig arity sd = case go arity sd of - Just dmds -> DmdType emptyDmdEnv (toList dmds) topDiv + Just dmds -> DmdType emptyDmdEnv (SArr.toList dmds) topDiv Nothing -> nopDmdType -- Not saturated where go 0 sd = snd <$> viewProd arity sd @@ -2154,7 +2152,7 @@ kill_usage_sd _ sd = sd data TypeShape -- See Note [Trimming a demand to a type] -- in GHC.Core.Opt.DmdAnal = TsFun TypeShape - | TsProd [TypeShape] + | TsProd (SArr TypeShape) | TsUnk trimToType :: Demand -> TypeShape -> Demand @@ -2165,8 +2163,7 @@ trimToType (n :* sd) ts = n :* go sd ts where go (Prod b ds) (TsProd tss) - | length ds == length tss' = mkProd b (SArr.zipWith trimToType ds tss') where - tss' = fromList tss + | length ds == length tss = mkProd b (SArr.zipWith trimToType ds tss) where go (Call n sd) (TsFun ts) = mkCall n (go sd ts) go sd at Poly{} _ = sd go _ _ = topSubDmd @@ -2178,7 +2175,7 @@ trimBoxity BotDmd = BotDmd trimBoxity (n :* sd) = n :* go sd where go (Poly _ n) = Poly Boxed n - go (Prod _ ds) = mkProd Boxed (SArr.map trimBoxity ds) + go (Prod _ ds) | !_ <- foldr seq () ds = pprTrace "test" empty $ pprTrace "trimBoxity" (ppr ds $$ ppr (SArr.map trimBoxity ds)) $ Prod Boxed (SArr.map trimBoxity ds) go (Call n sd) = mkCall n $ go sd {- @@ -2336,7 +2333,7 @@ instance Outputable DmdSig where instance Outputable TypeShape where ppr TsUnk = text "TsUnk" ppr (TsFun ts) = text "TsFun" <> parens (ppr ts) - ppr (TsProd tss) = parens (hsep $ punctuate comma $ map ppr tss) + ppr (TsProd tss) = parens (hsep $ punctuate comma $ map ppr $ SArr.toList tss) instance Binary Card where put_ bh C_00 = putByte bh 0 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07a4f966a58d35fae29431448af7accc2b969a10 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/07a4f966a58d35fae29431448af7accc2b969a10 You're receiving 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 Nov 15 13:04:13 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 15 Nov 2022 08:04:13 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] 2 commits: Revert "Always bundle libffi headers" Message-ID: <63738e4ded7a0_38f79f528c83255b4@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 494c6c73 by Sylvain Henry at 2022-11-15T14:06:40+01:00 Revert "Always bundle libffi headers" This reverts commit 5267d295ec83591994b258a1f8fd13eb3fb5eae7. - - - - - 10076a62 by Sylvain Henry at 2022-11-15T14:07:48+01:00 Don't always bundle ffi.h - - - - - 2 changed files: - hadrian/src/Rules/Generate.hs - rts/rts.cabal.in Changes: ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -42,6 +42,7 @@ rtsDependencies = do stage <- getStage rtsPath <- expr (rtsBuildPath stage) jsTarget <- expr isJsTarget + useSystemFfi <- expr (flag UseSystemFfi) let -- headers common to native and JS RTS common_headers = @@ -53,7 +54,7 @@ rtsDependencies = do [ "rts" -/- "EventTypes.h" , "rts" -/- "EventLogConstants.h" ] - ++ libffiHeaderFiles + ++ (if useSystemFfi then [] else libffiHeaderFiles) headers | jsTarget = common_headers | otherwise = common_headers ++ native_headers ===================================== rts/rts.cabal.in ===================================== @@ -117,9 +117,10 @@ library extra-bundled-libraries: Cffi-6 else extra-bundled-libraries: Cffi - install-includes: ffi.h ffitarget.h - -- ^ see Note [Packaging libffi headers] in - -- GHC.Driver.CodeOutput. + + install-includes: ffi.h ffitarget.h + -- ^ see Note [Packaging libffi headers] in + -- GHC.Driver.CodeOutput. -- Here we declare several flavours to be available when passing the -- suitable (combination of) flag(s) when configuring the RTS from hadrian, View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5267d295ec83591994b258a1f8fd13eb3fb5eae7...10076a6237b48107166d4136b8e09d78028651af -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5267d295ec83591994b258a1f8fd13eb3fb5eae7...10076a6237b48107166d4136b8e09d78028651af You're receiving 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 Nov 15 13:13:17 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 15 Nov 2022 08:13:17 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Try to fix configure fox installed bindists Message-ID: <6373906d83224_38f79f528dc328818@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 3d383e07 by Sylvain Henry at 2022-11-15T14:16:54+01:00 Try to fix configure fox installed bindists - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -564,7 +564,12 @@ function install_bindist() { args+=( "--target=$CROSS_TARGET" "--host=$CROSS_TARGET" ) fi - run ./configure \ + case "${CONFIGURE_WRAPPER:-}" in + emconfigure) source emsdk/emsdk_env.sh ;; + *) ;; + esac + + run ${CONFIGURE_WRAPPER:-} ./configure \ --prefix="$instdir" \ "${args[@]+"${args[@]}"}" make_install_destdir "$TOP"/destdir "$instdir" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d383e075a40c603068fd4a14600d4d29ea04780 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3d383e075a40c603068fd4a14600d4d29ea04780 You're receiving 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 Nov 15 13:21:49 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 15 Nov 2022 08:21:49 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 122 commits: gen-dll: Drop it Message-ID: <6373926d75342_38f79f528b4334477@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - e9362957 by Ben Gamari at 2022-11-14T20:34:22-05:00 Introduce blockConcat - - - - - 52b8b01f by Ben Gamari at 2022-11-14T20:34:22-05:00 cmm: Introduce MemoryOrderings - - - - - b5eedf66 by Ben Gamari at 2022-11-14T20:34:22-05:00 llvm: Respect memory specified orderings - - - - - 68ae2f1c by Ben Gamari at 2022-11-14T20:34:23-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - ed28ed00 by Ben Gamari at 2022-11-14T20:34:23-05:00 cmm/Parser: Reduce some repetition - - - - - 48fc85f1 by Ben Gamari at 2022-11-14T20:34:23-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 649113e2 by Ben Gamari at 2022-11-14T20:34:23-05:00 cmm/Parser: Atomic load syntax - - - - - df3b365d by Ben Gamari at 2022-11-14T20:34:23-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - ffff032d by Ben Gamari at 2022-11-14T20:34:23-05:00 rts/Messages: Refactor - - - - - 848edcda by Ben Gamari at 2022-11-14T20:34:23-05:00 Ordering fixes - - - - - 7ff2022d by Ben Gamari at 2022-11-14T20:34:23-05:00 eventlog: Silence spurious data race - - - - - 7e096c99 by Ben Gamari at 2022-11-14T20:34:23-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 4069d152 by Ben Gamari at 2022-11-14T20:34:23-05:00 unlockClosure - - - - - 6bbaec5b by Ben Gamari at 2022-11-14T20:34:23-05:00 Introduce and use GET_INFO_ACQUIRE - - - - - 29cd85b4 by Ben Gamari at 2022-11-14T20:34:23-05:00 Fences - - - - - f36b0876 by Ben Gamari at 2022-11-14T20:34:23-05:00 LOAD_INFO - - - - - bf64a7ea by Ben Gamari at 2022-11-14T20:34:23-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - f7bdce09 by Ben Gamari at 2022-11-14T20:34:23-05:00 Improve heap memory barrier note - - - - - b9f1cfe9 by Ben Gamari at 2022-11-14T20:34:23-05:00 load_acquire_w - - - - - ea78732e by Ben Gamari at 2022-11-14T20:34:23-05:00 rts: Introduce getNumCapabilities - - - - - 1a0d5c28 by Ben Gamari at 2022-11-14T20:34:23-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - 9715ae73 by Ben Gamari at 2022-11-14T20:34:23-05:00 rts: Mark accesses to Capability.context_switch as relaxed Also Capability.interrupt. - - - - - 1a59218f by Ben Gamari at 2022-11-14T20:34:23-05:00 Note - - - - - d36a5500 by Ben Gamari at 2022-11-14T20:34:23-05:00 GET_INFO_ACQUIRE - - - - - 78402958 by Ben Gamari at 2022-11-14T20:34:23-05:00 fences - - - - - 88077b46 by Ben Gamari at 2022-11-14T20:34:23-05:00 fence - - - - - b80de180 by Ben Gamari at 2022-11-14T20:34:23-05:00 nonmoving: Silence benign data race warning from TSAN - - - - - b32f076a by Ben Gamari at 2022-11-14T20:34:23-05:00 Note - - - - - 05ebcd30 by Ben Gamari at 2022-11-14T20:34:23-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - d40c174a by Ben Gamari at 2022-11-14T20:34:24-05:00 fences - - - - - 05542ca8 by Ben Gamari at 2022-11-14T20:34:24-05:00 nonmoving: Fix segment list races - - - - - 488d5be9 by Ben Gamari at 2022-11-14T20:34:24-05:00 nonmoving: Use atomic when looking at bd->gen - - - - - b3f7d5b4 by Ben Gamari at 2022-11-14T20:34:24-05:00 nonmoving: Eliminate race in bump_static_flag - - - - - 6f37216e by Ben Gamari at 2022-11-14T20:34:24-05:00 Note - - - - - 4ad1ea38 by Ben Gamari at 2022-11-14T20:34:24-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - 53765fb3 by Ben Gamari at 2022-11-14T20:35:28-05:00 rts/Timer: Always use atomic operations As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded. - - - - - 354b7fbb by Ben Gamari at 2022-11-14T20:35:30-05:00 rts: Encapsulate recent_activity access - - - - - 15d21bbe by Ben Gamari at 2022-11-14T20:35:30-05:00 Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - ea042bef by Ben Gamari at 2022-11-14T20:35:30-05:00 n_capabilities - - - - - 0c4a66a5 by Ben Gamari at 2022-11-14T20:35:30-05:00 Updates - - - - - 5bc2a2dc by Ben Gamari at 2022-11-14T20:35:30-05:00 Note - - - - - f5cfe12e by Ben Gamari at 2022-11-14T20:35:30-05:00 nonmoving: Collection running - - - - - a8ba172c by Ben Gamari at 2022-11-14T20:35:30-05:00 Mark epoch - - - - - b9ccdd6c by Ben Gamari at 2022-11-14T20:35:30-05:00 Segment state - - - - - f978901f by Ben Gamari at 2022-11-14T20:35:30-05:00 capabilities - - - - - f52863c5 by Ben Gamari at 2022-11-14T20:35:30-05:00 rts: Encapsulate sched_state - - - - - 9b2fca48 by Ben Gamari at 2022-11-14T20:35:30-05:00 rts/Proftimer: Encapsulate - - - - - f7a3a8e5 by Ben Gamari at 2022-11-14T20:35:30-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - cb5a35cf by Ben Gamari at 2022-11-14T20:35:30-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex. - - - - - 81f3263d by Ben Gamari at 2022-11-14T20:35:30-05:00 nonmoving: link_field - - - - - eb2d49c5 by Ben Gamari at 2022-11-14T20:35:31-05:00 PrimOps: Fix benign MutVar race - - - - - 220a491c by Ben Gamari at 2022-11-14T20:35:31-05:00 rts: Style fix - - - - - daf2511f by Ben Gamari at 2022-11-15T08:21:20-05:00 ordering - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - compiler/GHC/Builtin/Names.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/Expr.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - + compiler/GHC/Cmm/Reducibility.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs - compiler/GHC/CmmToAsm/BlockLayout.hs - compiler/GHC/CmmToAsm/PPC/CodeGen.hs - compiler/GHC/CmmToAsm/PPC/Ppr.hs - compiler/GHC/CmmToAsm/PPC/Regs.hs - compiler/GHC/CmmToAsm/Reg/Graph/TrivColorable.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ed4a5128b29d82d4e1f0ce12a38f61b5e60d258...daf2511f2b25790a5b47e9c242c039885a61ed6f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4ed4a5128b29d82d4e1f0ce12a38f61b5e60d258...daf2511f2b25790a5b47e9c242c039885a61ed6f You're receiving 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 Nov 15 13:59:28 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 15 Nov 2022 08:59:28 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 58 commits: rts: Check for program_invocation_short_name via autoconf Message-ID: <63739b40ea64c_38f79f528a03354ca@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 91859dd9 by Ben Gamari at 2022-11-15T08:50:04-05:00 Introduce blockConcat - - - - - 0476cf7a by Ben Gamari at 2022-11-15T08:50:54-05:00 cmm: Introduce MemoryOrderings - - - - - 1b018976 by Ben Gamari at 2022-11-15T08:50:54-05:00 llvm: Respect memory specified orderings - - - - - f72f0880 by Ben Gamari at 2022-11-15T08:50:54-05:00 Codegen/x86: Eliminate barrier for relaxed accesses - - - - - f36b4362 by Ben Gamari at 2022-11-15T08:50:54-05:00 cmm/Parser: Reduce some repetition - - - - - 86dd0a19 by Ben Gamari at 2022-11-15T08:50:54-05:00 cmm/Parser: Add syntax for ordered loads and stores - - - - - 13c0cac6 by Ben Gamari at 2022-11-15T08:50:54-05:00 cmm/Parser: Atomic load syntax - - - - - 5c35709f by Ben Gamari at 2022-11-15T08:50:54-05:00 codeGen: Introduce ThreadSanitizer instrumentation This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN. - - - - - c014f114 by Ben Gamari at 2022-11-15T08:50:54-05:00 rts/Messages: Refactor - - - - - 1f21f189 by Ben Gamari at 2022-11-15T08:57:22-05:00 rts/ThreadPaused: Ordering fixes - - - - - 498eff4d by Ben Gamari at 2022-11-15T08:57:34-05:00 eventlog: Silence spurious data race - - - - - e3beb8a8 by Ben Gamari at 2022-11-15T08:57:34-05:00 Introduce SET_INFO_RELEASE for Cmm - - - - - 056e23d3 by Ben Gamari at 2022-11-15T08:57:34-05:00 unlockClosure - - - - - 954bf147 by Ben Gamari at 2022-11-15T08:57:34-05:00 Introduce and use GET_INFO_ACQUIRE - - - - - 40821e0d by Ben Gamari at 2022-11-15T08:57:34-05:00 Fences - - - - - c925fd28 by Ben Gamari at 2022-11-15T08:57:34-05:00 LOAD_INFO - - - - - 4d3f74dd by Ben Gamari at 2022-11-15T08:57:34-05:00 rts/stm: Fix memory ordering in readTVarIO# See #22421. - - - - - 025cb62e by Ben Gamari at 2022-11-15T08:57:34-05:00 Improve heap memory barrier Note Also introduce MUT_FIELD marker in Closures.h to document mutable fields. - - - - - 036b9b45 by Ben Gamari at 2022-11-15T08:57:34-05:00 load_acquire_w - - - - - aaafd3e1 by Ben Gamari at 2022-11-15T08:57:34-05:00 rts: Introduce getNumCapabilities And ensure accesses to n_capabilities are atomic (although with relaxed ordering). This is necessary as RTS API callers may concurrently call into the RTS without holding a capability. - - - - - 03d01785 by Ben Gamari at 2022-11-15T08:57:34-05:00 ghc: Fix data race in dump file handling Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer. - - - - - 25c882db by Ben Gamari at 2022-11-15T08:57:34-05:00 rts: Always use atomics for context_switch and interrupt Since these are modified by the timer handler. - - - - - 5aa58633 by Ben Gamari at 2022-11-15T08:57:34-05:00 GET_INFO_ACQUIRE - - - - - 6e025e84 by Ben Gamari at 2022-11-15T08:57:34-05:00 fences - - - - - cc3df670 by Ben Gamari at 2022-11-15T08:57:34-05:00 fence - - - - - 28136cb0 by Ben Gamari at 2022-11-15T08:57:34-05:00 nonmoving: Silence benign data race warning from TSAN - - - - - 5a055d5d by Ben Gamari at 2022-11-15T08:57:34-05:00 nonmoving: Fix race in marking of blackholes We must use an acquire-fence when marking to ensure that the indirectee is visible. - - - - - b3c08c05 by Ben Gamari at 2022-11-15T08:57:34-05:00 fences - - - - - 859ca5b8 by Ben Gamari at 2022-11-15T08:57:34-05:00 nonmoving: Fix segment list races - - - - - 4bd329ba by Ben Gamari at 2022-11-15T08:57:34-05:00 nonmoving: Use atomic when looking at bd->gen - - - - - 0b7ece26 by Ben Gamari at 2022-11-15T08:57:34-05:00 nonmoving: Eliminate race in bump_static_flag - - - - - 66ec2cd9 by Ben Gamari at 2022-11-15T08:57:34-05:00 nonmoving: Ensure that mutable fields have acquire barrier - - - - - ea5da0d9 by Ben Gamari at 2022-11-15T08:57:34-05:00 rts/Timer: Always use atomic operations As noted in #22447, the existence of the pthread-based ITimer implementation means that we cannot assume that the program is single-threaded. - - - - - ad79e1a4 by Ben Gamari at 2022-11-15T08:57:34-05:00 rts: Encapsulate recent_activity access - - - - - 69c50120 by Ben Gamari at 2022-11-15T08:57:34-05:00 Updates - - - - - 0df05cdf by Ben Gamari at 2022-11-15T08:57:34-05:00 nonmoving: Collection running - - - - - 69236490 by Ben Gamari at 2022-11-15T08:57:34-05:00 Mark epoch - - - - - b2ea2ef6 by Ben Gamari at 2022-11-15T08:57:34-05:00 Segment state - - - - - f3fefa73 by Ben Gamari at 2022-11-15T08:57:34-05:00 capabilities - - - - - 1299da8b by Ben Gamari at 2022-11-15T08:57:34-05:00 rts: Encapsulate sched_state - - - - - 61e374f5 by Ben Gamari at 2022-11-15T08:57:34-05:00 rts/Proftimer: Encapsulate - - - - - 9feeb7ad by Ben Gamari at 2022-11-15T08:57:34-05:00 hadrian: Don't enable TSAN in stage0 build - - - - - 542553de by Ben Gamari at 2022-11-15T08:57:34-05:00 PrimOps: Fix benign MutVar race - - - - - 19e407ce by Ben Gamari at 2022-11-15T08:57:35-05:00 rts: Style fix - - - - - 617a46d7 by Ben Gamari at 2022-11-15T08:57:35-05:00 nonmoving: Refactor update remembered set initialization This avoids a lock inversion between the storage manager mutex and the stable pointer table mutex. - - - - - 26 changed files: - compiler/GHC.hs - compiler/GHC/Builtin/Names.hs - compiler/GHC/Builtin/PrimOps.hs - compiler/GHC/Builtin/Types.hs - compiler/GHC/Builtin/Types.hs-boot - compiler/GHC/Builtin/Types/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/Config.hs - compiler/GHC/Cmm/ContFlowOpt.hs - compiler/GHC/Cmm/Dataflow/Block.hs - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Lexer.x - compiler/GHC/Cmm/MachOp.hs - compiler/GHC/Cmm/Parser.y - compiler/GHC/Cmm/Pipeline.hs - compiler/GHC/Cmm/Reg.hs - + compiler/GHC/Cmm/ThreadSanitizer.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/CodeGen.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/daf2511f2b25790a5b47e9c242c039885a61ed6f...617a46d7005861fe2919403d87995f3f955d3b27 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/daf2511f2b25790a5b47e9c242c039885a61ed6f...617a46d7005861fe2919403d87995f3f955d3b27 You're receiving 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 Nov 15 15:50:52 2022 From: gitlab at gitlab.haskell.org (Sylvain Henry (@hsyl20)) Date: Tue, 15 Nov 2022 10:50:52 -0500 Subject: [Git][ghc/ghc][wip/javascript-backend] Source emsdk script before pushd Message-ID: <6373b55c12ad9_38f79f1264a95840932e@gitlab.mail> Sylvain Henry pushed to branch wip/javascript-backend at Glasgow Haskell Compiler / GHC Commits: 09a435c3 by Sylvain Henry at 2022-11-15T16:54:24+01:00 Source emsdk script before pushd - - - - - 1 changed file: - .gitlab/ci.sh Changes: ===================================== .gitlab/ci.sh ===================================== @@ -547,6 +547,11 @@ function make_install_destdir() { # install the binary distribution in directory $1 to $2. function install_bindist() { + case "${CONFIGURE_WRAPPER:-}" in + emconfigure) source emsdk/emsdk_env.sh ;; + *) ;; + esac + local bindist="$1" local instdir="$2" pushd "$bindist" @@ -564,11 +569,6 @@ function install_bindist() { args+=( "--target=$CROSS_TARGET" "--host=$CROSS_TARGET" ) fi - case "${CONFIGURE_WRAPPER:-}" in - emconfigure) source emsdk/emsdk_env.sh ;; - *) ;; - esac - run ${CONFIGURE_WRAPPER:-} ./configure \ --prefix="$instdir" \ "${args[@]+"${args[@]}"}" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/09a435c30f4c2c3fff51affd15e686983f590a05 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/09a435c30f4c2c3fff51affd15e686983f590a05 You're receiving 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 Nov 15 18:25:24 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 15 Nov 2022 13:25:24 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: Expand on the need to clone local binders. Message-ID: <6373d99444fe_38f79f528b44532d7@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - d20dcacb by ARATA Mizuki at 2022-11-15T13:25:10-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 86167fc6 by Bodigrim at 2022-11-15T13:25:15-05:00 Fix capitalization in haddock for TestEquality - - - - - 8 changed files: - compiler/GHC/CoreToStg/Prep.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Iface/Type.hs - compiler/GHC/Stg/Subst.hs - libraries/base/Data/Type/Equality.hs - m4/find_llvm_prog.m4 - testsuite/tests/ghci/should_run/T18594.script - testsuite/tests/ghci/should_run/T18594.stdout Changes: ===================================== compiler/GHC/CoreToStg/Prep.hs ===================================== @@ -112,6 +112,17 @@ The goal of this pass is to prepare for code generation. and doing so would be tiresome because then we'd need to substitute in types and coercions. + We need to clone ids for two reasons: + + Things associated with labels in the final code must be truly unique in + order to avoid labels being shadowed in the final output. + + Even binders without info tables like function arguments or alternative + bound binders must be unique at least in their type/unique combination. + We only emit a single declaration for each binder when compiling to C + so if binders are not unique we would either get duplicate declarations + or misstyped variables. The later happend in #22402. + + We heavily use unique-keyed maps in the backend which can go wrong when + ids with the same unique are meant to represent the same variable. + 7. Give each dynamic CCall occurrence a fresh unique; this is rather like the cloning step above. ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -44,7 +44,8 @@ module GHC.Iface.Syntax ( import GHC.Prelude -import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey ) +import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey, + constraintKindTyConKey ) import GHC.Types.Unique ( hasKey ) import GHC.Iface.Type import GHC.Iface.Recomp.Binary @@ -988,7 +989,8 @@ pprIfaceDecl ss (IfaceSynonym { ifName = tc -- See Note [Printing type abbreviations] in GHC.Iface.Type ppr_tau | tc `hasKey` liftedTypeKindTyConKey || - tc `hasKey` unrestrictedFunTyConKey + tc `hasKey` unrestrictedFunTyConKey || + tc `hasKey` constraintKindTyConKey = updSDocContext (\ctx -> ctx { sdocPrintTypeAbbreviations = False }) $ ppr tau | otherwise = ppr tau ===================================== compiler/GHC/Iface/Type.hs ===================================== @@ -846,7 +846,7 @@ Note [Printing type abbreviations] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Normally, we pretty-print `TYPE 'LiftedRep` as `Type` (or `*`) - `CONSTRAINT 'LiftedRep` as `Constraint` (or `*`) + `CONSTRAINT 'LiftedRep` as `Constraint` `FUN 'Many` as `(->)`. This way, error messages don't refer to representation polymorphism or linearity if it is not necessary. Normally we'd would represent @@ -856,14 +856,16 @@ command we specifically expand synonyms (see GHC.Tc.Module.tcRnExpr). So here in the pretty-printing we effectively collapse back Type and Constraint to their synonym forms. A bit confusing! -However, when printing the definition of Type or (->) with :info, +However, when printing the definition of Type, Constraint or (->) with :info, this would give confusing output: `type (->) = (->)` (#18594). Solution: detect when we are in :info and disable displaying the synonym with the SDoc option sdocPrintTypeAbbreviations. +If you are creating a similar synonym, make sure it is listed in pprIfaceDecl, +see reference to this Note. If there will be a need, in the future we could expose it as a flag --fprint-type-abbreviations or even two separate flags controlling -TYPE 'LiftedRep and FUN 'Many. +-fprint-type-abbreviations or even three separate flags controlling +TYPE 'LiftedRep, CONSTRAINT 'LiftedRep and FUN 'Many. -} -- | Do we want to suppress kind annotations on binders? ===================================== compiler/GHC/Stg/Subst.hs ===================================== @@ -12,6 +12,13 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Panic +-- TODO: This code might make folly of the work done in CorePrep where +-- we clone local ids in order to ensure *all* local binders are unique. +-- It's my understanding that here we use "the rapier"/uniqAway which makes up +-- uniques based on the ids in scope. Which can give the same unique to different +-- binders as long as they are in different scopes. A guarantee which isn't +-- strong enough for code generation in general. See Note [CorePrep Overview]. + -- | A renaming substitution from 'Id's to 'Id's. Like 'RnEnv2', but not -- maintaining pairs of substitutions. Like 'GHC.Core.Subst.Subst', but -- with the domain being 'Id's instead of entire 'CoreExpr'. ===================================== libraries/base/Data/Type/Equality.hs ===================================== @@ -152,14 +152,14 @@ deriving instance a ~~ b => Bounded (a :~~: b) -- The result should be @Just Refl@ if and only if the types applied to @f@ are -- equal: -- --- @TestEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b@ +-- @testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b@ -- -- Typically, only singleton types should inhabit this class. In that case type -- argument equality coincides with term equality: -- --- @TestEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y@ +-- @testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y@ -- --- @isJust (TestEquality x y) = x == y@ +-- @isJust (testEquality x y) = x == y@ -- -- Singleton types are not required, however, and so the latter two would-be -- laws are not in fact valid in general. ===================================== m4/find_llvm_prog.m4 ===================================== @@ -11,7 +11,7 @@ # AC_DEFUN([FIND_LLVM_PROG],[ # Test for program with and without version name. - PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $4 -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0 $2$llvmVersion"; done) + PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $(($4-1)) -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0 $2$llvmVersion"; done) AC_CHECK_TOOLS([$1], [$PROG_VERSION_CANDIDATES $2], []) AS_IF([test x"$$1" != x],[ PROG_VERSION=`$$1 --version | awk '/.*version [[0-9\.]]+/{for(i=1;i<=NF;i++){ if(\$i ~ /^[[0-9\.]]+$/){print \$i}}}'` ===================================== testsuite/tests/ghci/should_run/T18594.script ===================================== @@ -1,5 +1,6 @@ :m GHC.Types :i (->) +:i Constraint :set -XStarIsType :i Type :set -XNoStarIsType ===================================== testsuite/tests/ghci/should_run/T18594.stdout ===================================== @@ -7,6 +7,9 @@ instance Semigroup b => Semigroup (a -> b) -- Defined in ‘GHC.Base’ instance Applicative ((->) r) -- Defined in ‘GHC.Base’ instance Functor ((->) r) -- Defined in ‘GHC.Base’ instance Monad ((->) r) -- Defined in ‘GHC.Base’ +type Constraint :: * +type Constraint = CONSTRAINT LiftedRep + -- Defined in ‘GHC.Types’ type Type :: * type Type = TYPE LiftedRep -- Defined in ‘GHC.Types’ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/612cc569bcb1f77db8d9a9ced006156c0f73e0af...86167fc6e6d907c65638ff59bae4a2b5c5c3c2b3 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/612cc569bcb1f77db8d9a9ced006156c0f73e0af...86167fc6e6d907c65638ff59bae4a2b5c5c3c2b3 You're receiving 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 Nov 15 19:59:04 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 15 Nov 2022 14:59:04 -0500 Subject: [Git][ghc/ghc][wip/T22428] Fix contification with stable unfoldings (#22428) Message-ID: <6373ef889bd24_38f79f52904468334@gitlab.mail> Sebastian Graf pushed to branch wip/T22428 at Glasgow Haskell Compiler / GHC Commits: e86e3664 by Sebastian Graf at 2022-11-15T20:52:44+01:00 Fix contification with stable unfoldings (#22428) ... by predicting the join arity of a recursive RHS. See `Note [Join arity prediction for recursive functions]`. I also adjusted `Note [Join points and unfoldings/rules]` to account for the usage of predicted join arity in `occAnalRules` and `occAnalUnfolding` which now takes note of #22428. I also renamed * `occAnalLam` to `occAnalLamTail` * `occAnalRhs` to `occAnalLamTailFixed` * `adjustRhsUsage` to `adjustTailUsage` * a few other less important functions and properly documented the that each call of `occAnalLamTail` must pair up with `adjustTailUsage`. I removed `Note [Unfoldings and join points]` because it was redundant with `Note [Occurrences in stable unfoldings]`. Fixes #22428. - - - - - 4 changed files: - compiler/GHC/Core/Opt/OccurAnal.hs - + testsuite/tests/simplCore/should_compile/T22428.hs - + testsuite/tests/simplCore/should_compile/T22428.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/OccurAnal.hs ===================================== @@ -608,6 +608,24 @@ tail call with `n` arguments (counting both value and type arguments). Otherwise 'occ_tail' will be 'NoTailCallInfo'. The tail call info flows bottom-up with the rest of 'OccInfo' until it goes on the binder. +Note [Join arity prediction for recursive functions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For recursive functions, we can predict the only possible join arity: +It's the manifest join arity, e.g., the number of leading lambda binders in the +RHS. No different join arity would do: + + * If join arity would be lower, then the leading lambda would spoil any + recursive tail calls in the RHS and hence join-point-hood of the whole letrec. + * If join arity would be higher, then we'd have to eta expand the RHS first. + It is the job of Arity Analysis, Call Arity and Demand Analysis to decide + whether that won't lose sharing and outside the scope of occurrence analysis + to check for. + +For non-recursive functions, we can make no such prediction; the join arity +may be both higher than manifest join arity (in which case the Simplifier will +eta-expand; it's simple to see that no sharing can be lost) or lower than the +manifest join arity. + Note [Join points and unfoldings/rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider @@ -618,7 +636,7 @@ Consider Before j is inlined, we'll have occurrences of j2 in both j's RHS and in its stable unfolding. We want to discover -j2 as a join point. So we must do the adjustRhsUsage thing +j2 as a join point. So we must do the adjustTailUsage thing on j's RHS. That's why we pass mb_join_arity to calcUnfolding. Same with rules. Suppose we have: @@ -636,14 +654,18 @@ up. So provided the join-point arity of k matches the args of the rule we can allow the tail-call info from the RHS of the rule to propagate. -* Wrinkle for Rec case. In the recursive case we don't know the - join-point arity in advance, when calling occAnalUnfolding and - occAnalRules. (See makeNode.) We don't want to pass Nothing, - because then a recursive joinrec might lose its join-poin-hood - when SpecConstr adds a RULE. So we just make do with the - *current* join-poin-hood, stored in the Id. +* Wrinkle for Rec case. We need to know the potential join arity 'makeNode', + so that 'occAnalRules' and 'occAnalUnfolding' don't spoil potential + join-point-hood of the letrec. This is especially important given that otherwise + * RULEs added by SpecConstr might otherwise lose join-point-hood of + previously detected join points + * Stable unfoldings might prevent contification (#22428) + So as per Note [Join arity prediction for recursive functions] we pick + 'manifestJoinArity' to do the job. Note that in case the letrec won't become + a join point, we'll 'adjustTailUsage' eventually in 'occAnalRec'. - In the non-recursive case things are simple: see occAnalNonRecBind + In the non-recursive case things are simple, because we know the join arity + from the body_usage: see occAnalNonRecBind * Wrinkle for RULES. Suppose the example was a bit different: let j :: Int -> Int @@ -669,13 +691,6 @@ propagate. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -Note [Unfoldings and join points] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We assume that anything in an unfolding occurs multiple times, since -unfoldings are often copied (that's the whole point!). But we still -need to track tail calls for the purpose of finding join points. - - ------------------------------------------------------------ Note [Adjusting right-hand sides] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -707,21 +722,24 @@ lambda) get marked: There are a few other caveats; most importantly, if we're marking a binding as 'AlwaysTailCalled', it's *going* to be a join point, so we treat it as one so that the effect cascades properly. Consequently, at the time the RHS is -analysed, we won't know what adjustments to make; thus 'occAnalLamOrRhs' must -return the unadjusted 'UsageDetails', to be adjusted by 'adjustRhsUsage' once -join-point-hood has been decided. +analysed, we won't know what adjustments to make; thus 'occAnalLamTail' must +return the unadjusted 'UsageDetails', to be adjusted by 'adjustTailUsage' once +join-point-hood has been decided and eventual one-shot annotations have been +added through 'markNonRecJoinOneShots'. Thus the overall sequence taking place in 'occAnalNonRecBind' and 'occAnalRecBind' is as follows: - 1. Call 'occAnalLamOrRhs' to find usage information for the RHS. + 1. Call 'occAnalLamTail' to find usage information for the RHS. 2. Call 'tagNonRecBinder' or 'tagRecBinders', which decides whether to make the binding a join point. - 3. Call 'adjustRhsUsage' accordingly. (Done as part of 'tagRecBinders' when + 3. Call 'markNonRecJoinOneShots' so that we recognise every non-recursive join + point as one-shot + 4. Call 'adjustTailUsage' accordingly. (Done as part of 'tagRecBinders' when recursive.) (In the recursive case, this logic is spread between 'makeNode' and -'occAnalRec'.) +the 'AcyclicSCC' case of 'occAnalRec'.) -} @@ -754,12 +772,11 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage = WithUsageDetails body_usage [] | otherwise -- It's mentioned in the body - = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs'] + = WithUsageDetails (body_usage' `andUDs` rhs_usage) [NonRec final_bndr rhs2] where (body_usage', tagged_bndr) = tagNonRecBinder lvl body_usage bndr final_bndr = tagged_bndr `setIdUnfolding` unf' `setIdSpecialisation` mkRuleInfo rules' - rhs_usage = rhs_uds `andUDs` unf_uds `andUDs` rule_uds -- Get the join info from the *new* decision -- See Note [Join points and unfoldings/rules] @@ -773,16 +790,21 @@ occAnalNonRecBind !env lvl imp_rule_edges bndr rhs body_usage -- See Note [Sources of one-shot information] rhs_env = env1 { occ_one_shots = argOneShots dmd } - (WithUsageDetails rhs_uds rhs') = occAnalRhs rhs_env NonRecursive mb_join_arity rhs + (WithUsageDetails rhs_uds rhs1) = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage directly below + rhs2 = markNonRecJoinOneShots mb_join_arity rhs1 + rhs_usage = adjustTailUsage mb_join_arity rhs1 $ + rhs_uds `andUDs` unf_uds `andUDs` rule_uds --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf | isId bndr = idUnfolding bndr | otherwise = NoUnfolding - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env NonRecursive mb_join_arity unf + (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env mb_join_arity unf --------- Rules --------- -- See Note [Rules are extra RHSs] and Note [Rule dependency info] + -- and Note [Join points and unfoldings/rules] rules_w_uds = occAnalRules rhs_env mb_join_arity bndr rules' = map fstOf3 rules_w_uds imp_rule_uds = impRulesScopeUsage (lookupImpRules imp_rule_edges bndr) @@ -848,10 +870,14 @@ occAnalRec !_ lvl (AcyclicSCC (ND { nd_bndr = bndr, nd_rhs = rhs | otherwise -- It's mentioned in the body = WithUsageDetails (body_uds' `andUDs` rhs_uds') - (NonRec tagged_bndr rhs : binds) + (NonRec tagged_bndr rhs' : binds) where (body_uds', tagged_bndr) = tagNonRecBinder lvl body_uds bndr - rhs_uds' = adjustRhsUsage mb_join_arity rhs rhs_uds + rhs' = markNonRecJoinOneShots mb_join_arity rhs + rhs_uds' = adjustTailUsage mb_join_arity rhs' rhs_uds + -- corresponding call to occAnalLamTail is in makeNode + -- rhs_uds is for a non-recursive join point; we should to do the same + -- as occAnalNonRecBind, so we do 'markNonRecJoinOneShots' before. mb_join_arity = willBeJoinId_maybe tagged_bndr -- The Rec case is the interesting one @@ -1412,27 +1438,33 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) -- and the unfolding together. -- See Note [inl_fvs] - mb_join_arity = isJoinId_maybe bndr - -- Get join point info from the *current* decision - -- We don't know what the new decision will be! - -- Using the old decision at least allows us to - -- preserve existing join point, even RULEs are added - -- See Note [Join points and unfoldings/rules] + + -- See Note [Join arity prediction for recursive functions] + -- and Note [Join points and unfoldings/rules] + pred_join_arity = Just (manifestJoinArity rhs) --------- Right hand side --------- -- Constructing the edges for the main Rec computation -- See Note [Forming Rec groups] - -- Do not use occAnalRhs because we don't yet know the final - -- answer for mb_join_arity; instead, do the occAnalLam call from - -- occAnalRhs, and postpone adjustRhsUsage until occAnalRec + -- Compared to occAnalLamTailFixed, we can't yet adjust the RHS because + -- (a) we don't yet know the final answer for pred_join_arity. It might be + -- Nothing! + -- (b) we don't even know whether it stays a recursive RHS after the SCC + -- analysis we are about to seed! So we can't markAllInsideLam in + -- advance, because if it ends up as a non-recursive join point we'll + -- consider it as one-shot and don't need to markAllInsideLam. + -- Instead, do the occAnalLamTail call from occAnalLamTailFixed, and postpone + -- adjustTailUsage until occAnalRec. In effect, we pretend that the RHS + -- becomes a non-recursive join point and fix up later with adjustTailUsage. rhs_env = rhsCtxt env - (WithUsageDetails rhs_uds rhs') = occAnalLam rhs_env rhs + (WithUsageDetails rhs_uds rhs') = occAnalLamTail rhs_env rhs + -- corresponding call to adjustTailUsage in occAnalRec and tagRecBinders --------- Unfolding --------- - -- See Note [Unfoldings and join points] + -- See Note [Join points and unfoldings/rules] unf = realIdUnfolding bndr -- realIdUnfolding: Ignore loop-breaker-ness -- here because that is what we are setting! - (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env Recursive mb_join_arity unf + (WithUsageDetails unf_uds unf') = occAnalUnfolding rhs_env pred_join_arity unf --------- IMP-RULES -------- is_active = occ_rule_act env :: Activation -> Bool @@ -1441,8 +1473,9 @@ makeNode !env imp_rule_edges bndr_set (bndr, rhs) imp_rule_fvs = impRulesActiveFvs is_active bndr_set imp_rule_info --------- All rules -------- + -- See Note [Join points and unfoldings/rules] rules_w_uds :: [(CoreRule, UsageDetails, UsageDetails)] - rules_w_uds = occAnalRules rhs_env mb_join_arity bndr + rules_w_uds = occAnalRules rhs_env pred_join_arity bndr rules' = map fstOf3 rules_w_uds rule_uds = foldr add_rule_uds imp_rule_uds rules_w_uds @@ -1748,7 +1781,7 @@ lambda and casts, e.g. * Occurrence analyser: we just mark each binder in the lambda-group (here: x,y,z) with its occurrence info in the *body* of the - lambda-group. See occAnalLam. + lambda-group. See occAnalLamTail. * Simplifier. The simplifier is careful when partially applying lambda-groups. See the call to zapLambdaBndrs in @@ -1804,7 +1837,7 @@ zapLambdaBndrs fun arg_count zap_bndr b | isTyVar b = b | otherwise = zapLamIdInfo b -occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) +occAnalLamTail :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) -- See Note [Occurrence analysis for lambda binders] -- It does the following: -- * Sets one-shot info on the lambda binder from the OccEnv, and @@ -1815,12 +1848,16 @@ occAnalLam :: OccEnv -> CoreExpr -> (WithUsageDetails CoreExpr) -- This function does /not/ do -- markAllInsideLam or -- markAllNonTail --- The caller does that, either in occAnal (Lam {}), or in adjustRhsUsage +-- The caller does that, either in occAnalLamTailFixed, or calling adjustTailUsage directly. +-- Every call site links to its respective adjustTailUsage call and vice versa. +-- +-- In effect, the analysis result is for a non-recursive join point with +-- manifest arity and adjustTailUsage does the fixup. -- See Note [Adjusting right-hand sides] -occAnalLam env (Lam bndr expr) +occAnalLamTail env (Lam bndr expr) | isTyVar bndr - = let (WithUsageDetails usage expr') = occAnalLam env expr + = let (WithUsageDetails usage expr') = occAnalLamTail env expr in WithUsageDetails usage (Lam bndr expr') -- Important: Keep the 'env' unchanged so that with a RHS like -- \(@ x) -> K @x (f @x) @@ -1839,14 +1876,14 @@ occAnalLam env (Lam bndr expr) env1 = env { occ_encl = OccVanilla, occ_one_shots = env_one_shots' } env2 = addOneInScope env1 bndr - (WithUsageDetails usage expr') = occAnalLam env2 expr + (WithUsageDetails usage expr') = occAnalLamTail env2 expr (usage', bndr2) = tagLamBinder usage bndr1 in WithUsageDetails usage' (Lam bndr2 expr') -- For casts, keep going in the same lambda-group -- See Note [Occurrence analysis for lambda binders] -occAnalLam env (Cast expr co) - = let (WithUsageDetails usage expr') = occAnalLam env expr +occAnalLamTail env (Cast expr co) + = let (WithUsageDetails usage expr') = occAnalLamTail env expr -- usage1: see Note [Gather occurrences of coercion variables] usage1 = addManyOccs usage (coVarsOfCo co) @@ -1856,15 +1893,15 @@ occAnalLam env (Cast expr co) _ -> usage1 -- usage3: you might think this was not necessary, because of - -- the markAllNonTail in adjustRhsUsage; but not so! For a - -- join point, adjustRhsUsage doesn't do this; yet if there is + -- the markAllNonTail in adjustTailUsage; but not so! For a + -- join point, adjustTailUsage doesn't do this; yet if there is -- a cast, we must! Also: why markAllNonTail? See -- GHC.Core.Lint: Note Note [Join points and casts] usage3 = markAllNonTail usage2 in WithUsageDetails usage3 (Cast expr' co) -occAnalLam env expr = occAnal env expr +occAnalLamTail env expr = occAnal env expr {- Note [Occ-anal and cast worker/wrapper] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1884,8 +1921,8 @@ RHS. So it'll get a Many occ-info. (Maybe Cast w/w should create a stable unfolding, which would obviate this Note; but that seems a bit of a heavyweight solution.) -We only need to this in occAnalLam, not occAnal, because the top leve -of a right hand side is handled by occAnalLam. +We only need to this in occAnalLamTail, not occAnal, because the top leve +of a right hand side is handled by occAnalLamTail. -} @@ -1895,51 +1932,30 @@ of a right hand side is handled by occAnalLam. * * ********************************************************************* -} -occAnalRhs :: OccEnv -> RecFlag -> Maybe JoinArity - -> CoreExpr -- RHS - -> WithUsageDetails CoreExpr -occAnalRhs !env is_rec mb_join_arity rhs - = let (WithUsageDetails usage rhs1) = occAnalLam env rhs - -- We call occAnalLam here, not occAnalExpr, so that it doesn't - -- do the markAllInsideLam and markNonTailCall stuff before - -- we've had a chance to help with join points; that comes next - rhs2 = markJoinOneShots is_rec mb_join_arity rhs1 - rhs_usage = adjustRhsUsage mb_join_arity rhs2 usage - in WithUsageDetails rhs_usage rhs2 - - - -markJoinOneShots :: RecFlag -> Maybe JoinArity -> CoreExpr -> CoreExpr --- For a /non-recursive/ join point we can mark all --- its join-lambda as one-shot; and it's a good idea to do so -markJoinOneShots NonRecursive (Just join_arity) rhs - = go join_arity rhs +occAnalLamTailFixed :: OccEnv -> Maybe JoinArity + -> CoreExpr -- RHS + -> WithUsageDetails CoreExpr +-- ^ This function immediately does adjustTailUsage with the fixed join arity +-- after the call to occAnalLamTail. +-- It's useful for anonymous lambdas and unfoldings. +occAnalLamTailFixed !env mb_join_arity rhs + = WithUsageDetails (adjustTailUsage mb_join_arity rhs' usage) rhs' where - go 0 rhs = rhs - go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) - (go (n-1) rhs) - go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. - -- e.g. let j = case ... in j True - -- This will become an arity-1 join point after the - -- simplifier has eta-expanded it; but it may not have - -- enough lambdas /yet/. (Lint checks that JoinIds do - -- have enough lambdas.) -markJoinOneShots _ _ rhs - = rhs + WithUsageDetails usage rhs' = occAnalLamTail env rhs + occAnalUnfolding :: OccEnv - -> RecFlag -> Maybe JoinArity -- See Note [Join points and unfoldings/rules] -> Unfolding -> WithUsageDetails Unfolding -- Occurrence-analyse a stable unfolding; --- discard a non-stable one altogether. -occAnalUnfolding !env is_rec mb_join_arity unf +-- discard a non-stable one altogether and return empty usage details. +occAnalUnfolding !env mb_join_arity unf = case unf of unf@(CoreUnfolding { uf_tmpl = rhs, uf_src = src }) | isStableSource src -> let - (WithUsageDetails usage rhs') = occAnalRhs env is_rec mb_join_arity rhs + (WithUsageDetails usage rhs') = occAnalLamTailFixed env mb_join_arity rhs unf' | noBinderSwaps env = unf -- Note [Unfoldings and rules] | otherwise = unf { uf_tmpl = rhs' } @@ -1958,9 +1974,7 @@ occAnalUnfolding !env is_rec mb_join_arity unf where env' = env `addInScope` bndrs (WithUsageDetails usage args') = occAnalList env' args - final_usage = markAllManyNonTail (delDetailsList usage bndrs) - `addLamCoVarOccs` bndrs - `delDetailsList` bndrs + final_usage = usage `addLamCoVarOccs` bndrs `delDetailsList` bndrs -- delDetailsList; no need to use tagLamBinders because we -- never inline DFuns so the occ-info on binders doesn't matter @@ -1989,8 +2003,8 @@ occAnalRules !env mb_join_arity bndr (WithUsageDetails rhs_uds rhs') = occAnal env' rhs -- Note [Rules are extra RHSs] -- Note [Rule dependency info] - rhs_uds' = markAllNonTailIf (not exact_join) $ - markAllMany $ + rhs_uds' = markAllNonTailIf (not exact_join) $ -- Nearly adjustTailUsage, but we don't want to + markAllMany $ -- build `mkLams (map _ args) rhs` just for the call rhs_uds `delDetailsList` bndrs exact_join = exactJoin mb_join_arity args @@ -2031,6 +2045,8 @@ Another way to think about it: if we inlined g as-is into multiple call sites, now there's be multiple calls to f. Bottom line: treat all occurrences in a stable unfolding as "Many". +We still leave tail call information in tact, though, as to not spoil +potential join points. Note [Unfoldings and rules] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2208,10 +2224,7 @@ occAnal env app@(App _ _) = occAnalApp env (collectArgsTicks tickishFloatable app) occAnal env expr@(Lam {}) - = let (WithUsageDetails usage expr') = occAnalLam env expr - final_usage = markAllInsideLamIf (not (isOneShotFun expr')) $ - markAllNonTail usage - in WithUsageDetails final_usage expr' + = occAnalLamTailFixed env Nothing expr -- mb_join_arity == Nothing <=> markAllManyNonTail occAnal env (Case scrut bndr ty alts) = let @@ -2286,7 +2299,7 @@ occAnalApp !env (Var fun, args, ticks) -- This caused #18296 | fun `hasKey` runRWKey , [t1, t2, arg] <- args - , let (WithUsageDetails usage arg') = occAnalRhs env NonRecursive (Just 1) arg + , WithUsageDetails usage arg' <- occAnalLamTailFixed env (Just 1) arg = WithUsageDetails usage (mkTicks ticks $ mkApps (Var fun) [t1, t2, arg']) occAnalApp env (Var fun_id, args, ticks) @@ -3132,11 +3145,11 @@ flattenUsageDetails ud@(UD { ud_env = env }) ------------------- -- See Note [Adjusting right-hand sides] -adjustRhsUsage :: Maybe JoinArity - -> CoreExpr -- Rhs, AFTER occ anal +adjustTailUsage :: Maybe JoinArity + -> CoreExpr -- Rhs, AFTER occAnalLamTail -> UsageDetails -- From body of lambda -> UsageDetails -adjustRhsUsage mb_join_arity rhs usage +adjustTailUsage mb_join_arity rhs usage = -- c.f. occAnal (Lam {}) markAllInsideLamIf (not one_shot) $ markAllNonTailIf (not exact_join) $ @@ -3146,6 +3159,28 @@ adjustRhsUsage mb_join_arity rhs usage exact_join = exactJoin mb_join_arity bndrs (bndrs,_) = collectBinders rhs +-- | IF rhs becomes a join point, then `manifestJoinArity rhs` returns the +-- exact join arity of `rhs`. +manifestJoinArity :: CoreExpr -> JoinArity +manifestJoinArity rhs = length $ fst $ collectBinders rhs + +markNonRecJoinOneShots :: Maybe JoinArity -> CoreExpr -> CoreExpr +-- For a /non-recursive/ join point we can mark all +-- its join-lambda as one-shot; and it's a good idea to do so +markNonRecJoinOneShots Nothing rhs = rhs +markNonRecJoinOneShots (Just join_arity) rhs + = go join_arity rhs + where + go 0 rhs = rhs + go n (Lam b rhs) = Lam (if isId b then setOneShotLambda b else b) + (go (n-1) rhs) + go _ rhs = rhs -- Not enough lambdas. This can legitimately happen. + -- e.g. let j = case ... in j True + -- This will become an arity-1 join point after the + -- simplifier has eta-expanded it; but it may not have + -- enough lambdas /yet/. (Lint checks that JoinIds do + -- have enough lambdas.) + exactJoin :: Maybe JoinArity -> [a] -> Bool exactJoin Nothing _ = False exactJoin (Just join_arity) args = args `lengthIs` join_arity @@ -3224,7 +3259,7 @@ tagRecBinders lvl body_uds details_s -- 2. Adjust usage details of each RHS, taking into account the -- join-point-hood decision - rhs_udss' = [ adjustRhsUsage (mb_join_arity bndr) rhs rhs_uds + rhs_udss' = [ adjustTailUsage (mb_join_arity bndr) rhs rhs_uds -- matching occAnalLamTail in makeNode | ND { nd_bndr = bndr, nd_uds = rhs_uds , nd_rhs = rhs } <- details_s ] ===================================== testsuite/tests/simplCore/should_compile/T22428.hs ===================================== @@ -0,0 +1,9 @@ +module T22428 where + +f :: Integer -> Integer -> Integer +f x y = go y + where + go :: Integer -> Integer + go 0 = x + go n = go (n-1) + {-# INLINE go #-} ===================================== testsuite/tests/simplCore/should_compile/T22428.stderr ===================================== @@ -0,0 +1,45 @@ + +==================== Tidy Core ==================== +Result size of Tidy Core + = {terms: 32, types: 14, coercions: 0, joins: 1/1} + +-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0} +T22428.f1 :: Integer +[GblId, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 10}] +T22428.f1 = GHC.Num.Integer.IS 1# + +-- RHS size: {terms: 28, types: 10, coercions: 0, joins: 1/1} +f :: Integer -> Integer -> Integer +[GblId, + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 0] 156 0}] +f = \ (x :: Integer) (y :: Integer) -> + joinrec { + go [InlPrag=INLINE (sat-args=1), Occ=LoopBreaker, Dmd=SC(S,L)] + :: Integer -> Integer + [LclId[JoinId(1)(Just [!])], + Arity=1, + Str=<1L>, + Unf=Unf{Src=StableUser, TopLvl=False, Value=True, ConLike=True, + WorkFree=True, Expandable=True, + Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=False)}] + go (ds :: Integer) + = case ds of wild { + GHC.Num.Integer.IS x1 -> + case x1 of { + __DEFAULT -> jump go (GHC.Num.Integer.integerSub wild T22428.f1); + 0# -> x + }; + GHC.Num.Integer.IP x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1); + GHC.Num.Integer.IN x1 -> + jump go (GHC.Num.Integer.integerSub wild T22428.f1) + }; } in + jump go y + + + ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -447,3 +447,6 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) + +# go should become a join point +test('T22428', [grep_errmsg(r'jump go') ], compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeable-binds -dsuppress-unfoldings']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e86e366483e51fcfe30c43801b3209f37a5266dd -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e86e366483e51fcfe30c43801b3209f37a5266dd You're receiving 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 Nov 15 20:36:07 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 15 Nov 2022 15:36:07 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T22317 Message-ID: <6373f83774b0b_38f79f1264a9584787e@gitlab.mail> Sebastian Graf pushed new branch wip/T22317 at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T22317 You're receiving 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 Nov 15 20:36:48 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Tue, 15 Nov 2022 15:36:48 -0500 Subject: [Git][ghc/ghc][wip/T22317] Simplifier: Consider `seq` as a `BoringCtxt` (#22317) Message-ID: <6373f8601de96_38f79f5265c47899f@gitlab.mail> Sebastian Graf pushed to branch wip/T22317 at Glasgow Haskell Compiler / GHC Commits: 57e13cf3 by Sebastian Graf at 2022-11-15T21:36:18+01:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 5 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Unfold.hs - + testsuite/tests/simplCore/should_compile/T22317.hs - + testsuite/tests/simplCore/should_compile/T22317.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -740,8 +740,8 @@ Note [Interesting call context] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want to avoid inlining an expression where there can't possibly be any gain, such as in an argument position. Hence, if the continuation -is interesting (eg. a case scrutinee, application etc.) then we -inline, otherwise we don't. +is interesting (eg. a case scrutinee that isn't just a seq, application etc.) +then we inline, otherwise we don't. Previously some_benefit used to return True only if the variable was applied to some value arguments. This didn't work: @@ -781,6 +781,39 @@ expression into the branches of any case in f's unfolding. So, to reduce unnecessary code expansion, we just make the context look boring. This made a small compile-time perf improvement in perf/compiler/T6048, and it looks plausible to me. + +Note [Seq is boring] +~~~~~~~~~~~~~~~~~~~~ +Consider T22317 + + data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) + + m :: Maybe a -> Maybe a -> Maybe a + m = \ (@a_az7) (ds_dAn :: Maybe a_az7) (ds_dAo :: Maybe a_az7) -> + case ds_dAn of { + Nothing -> ds_dAo; + Just v1_awh -> + case ds_dAo of wild_X2 { + Nothing -> GHC.Maybe.Just @a_az7 v1_awh; + Just ipv_sAC -> ds_dAo + } + } + {-# INLINE m #-} + + f :: T -> T -> T + f = \ (ds_dAv :: T) (ds_dAw :: T) -> + case ds_dAv of { T a1_awj b1_awk c1_awl d1_awm -> + case ds_dAw of { T a2_awn b2_awo c2_awp d2_awq -> + case m @Bool a1_awj a2_awn of a_X3 { __DEFAULT -> + case m @Bool b1_awk b2_awo of b_X4 { __DEFAULT -> + case m @Bool c1_awl c2_awp of c_X6 { __DEFAULT -> + case m @Bool d1_awm d2_awq of d_X8 { __DEFAULT -> + Lib.T a_X3 b_X4 c_X6 d_X8 }}}}}} + +Here we gain absolutely nothing by inlining `m`, just a bunch of join points +from `m`'s definition and and case-of-case, bloating up the code. +Hence even though case-of-case would fire here, we refrain from inlining `m`. +We do so by regarding a seq context as a `BoringCtxt` (not `CaseCxt`). -} lazyArgContext :: ArgInfo -> CallCtxt @@ -811,10 +844,11 @@ interestingCallContext :: SimplEnv -> SimplCont -> CallCtxt interestingCallContext env cont = interesting cont where - interesting (Select {}) - | seCaseCase env = CaseCtxt - | otherwise = BoringCtxt - -- See Note [No case of case is boring] + interesting (Select {sc_alts=alts}) + | not (seCaseCase env) = BoringCtxt -- See Note [No case of case is boring] + | [Alt DEFAULT _ _] <- alts = BoringCtxt -- See Note [Seq is boring] + | otherwise = CaseCtxt + interesting (ApplyToVal {}) = ValAppCtxt -- Can happen if we have (f Int |> co) y ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -1347,8 +1347,11 @@ call is at least CONLIKE. At least for the cases where we use ArgCtxt for the RHS of a 'let', we only profit from the inlining if we get a CONLIKE thing (modulo lets). -Note [Lone variables] See also Note [Interaction of exprIsWorkFree and lone variables] -~~~~~~~~~~~~~~~~~~~~~ which appears below +Note [Lone variables] +~~~~~~~~~~~~~~~~~~~~~ +See also Note [Interaction of exprIsWorkFree and lone variables] +which appears below + The "lone-variable" case is important. I spent ages messing about with unsatisfactory variants, but this is nice. The idea is that if a variable appears all alone ===================================== testsuite/tests/simplCore/should_compile/T22317.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE BangPatterns #-} + +module T22317 where + +data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) + + +m :: Maybe a -> Maybe a -> Maybe a +m (Just v1) Nothing = Just v1 +m _ mb = mb +{-# INLINE m #-} + +f :: T -> T -> T +f (T a1 b1 c1 d1) (T a2 b2 c2 d2) + = let j1 !a = let j2 !b = let j3 !c = let j4 !d = T a b c d + in j4 (m d1 d2) + in j3 (m c1 c2) + in j2 (m b1 b2) + in j1 (m a1 a2) +{-# OPAQUE f #-} ===================================== testsuite/tests/simplCore/should_compile/T22317.stderr ===================================== @@ -0,0 +1,256 @@ +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -449,3 +449,5 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) +# Should not inline m, so there shouldn't be a single YES +test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m -ddebug-output']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/57e13cf3930733205396b7e69ea8be56ea82381c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/57e13cf3930733205396b7e69ea8be56ea82381c You're receiving 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 Nov 15 20:55:37 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 15 Nov 2022 15:55:37 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: configure: Don't check for an unsupported version of LLVM Message-ID: <6373fcc97613e_38f79f5290448624b@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: df137f68 by ARATA Mizuki at 2022-11-15T15:55:29-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 77e0e36f by Bodigrim at 2022-11-15T15:55:30-05:00 Fix capitalization in haddock for TestEquality - - - - - 2 changed files: - libraries/base/Data/Type/Equality.hs - m4/find_llvm_prog.m4 Changes: ===================================== libraries/base/Data/Type/Equality.hs ===================================== @@ -152,14 +152,14 @@ deriving instance a ~~ b => Bounded (a :~~: b) -- The result should be @Just Refl@ if and only if the types applied to @f@ are -- equal: -- --- @TestEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b@ +-- @testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b@ -- -- Typically, only singleton types should inhabit this class. In that case type -- argument equality coincides with term equality: -- --- @TestEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y@ +-- @testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y@ -- --- @isJust (TestEquality x y) = x == y@ +-- @isJust (testEquality x y) = x == y@ -- -- Singleton types are not required, however, and so the latter two would-be -- laws are not in fact valid in general. ===================================== m4/find_llvm_prog.m4 ===================================== @@ -11,7 +11,7 @@ # AC_DEFUN([FIND_LLVM_PROG],[ # Test for program with and without version name. - PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $4 -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0 $2$llvmVersion"; done) + PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $(($4-1)) -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0 $2$llvmVersion"; done) AC_CHECK_TOOLS([$1], [$PROG_VERSION_CANDIDATES $2], []) AS_IF([test x"$$1" != x],[ PROG_VERSION=`$$1 --version | awk '/.*version [[0-9\.]]+/{for(i=1;i<=NF;i++){ if(\$i ~ /^[[0-9\.]]+$/){print \$i}}}'` View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86167fc6e6d907c65638ff59bae4a2b5c5c3c2b3...77e0e36f9590033638a60a80765154e15712d252 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/86167fc6e6d907c65638ff59bae4a2b5c5c3c2b3...77e0e36f9590033638a60a80765154e15712d252 You're receiving 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 Nov 15 21:07:21 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 15 Nov 2022 16:07:21 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 4 commits: TmpFs: Eliminate data race Message-ID: <6373ff89ea083_38f79f5287849138c@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 72af74f5 by Ben Gamari at 2022-11-15T15:36:30-05:00 TmpFs: Eliminate data race Previously we used readIORef concurrently on a IORef. - - - - - 0dd2f66e by Ben Gamari at 2022-11-15T15:47:54-05:00 compiler: Use release store in eager blackholing - - - - - 2dab1e51 by Ben Gamari at 2022-11-15T15:48:29-05:00 rts: Fix ordering of makeStableName - - - - - 46683a0f by Ben Gamari at 2022-11-15T15:49:02-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - 4 changed files: - compiler/GHC/StgToCmm/Bind.hs - compiler/GHC/Utils/TmpFs.hs - rts/PrimOps.cmm - rts/include/Cmm.h Changes: ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -703,8 +703,8 @@ emitBlackHoleCode node = do whenUpdRemSetEnabled $ emitUpdRemSetPushThunk node emitStore (cmmOffsetW platform node (fixedHdrSizeW profile)) currentTSOExpr -- See Note [Heap memory barriers] in SMP.h. - emitPrimCall [] MO_WriteBarrier [] - emitStore node (CmmReg (CmmGlobal EagerBlackholeInfo)) + let w = wordWidth platform + emitPrimCall [] (MO_AtomicWrite w MemOrderCstSeq) [node, CmmReg (CmmGlobal EagerBlockholeInfo)] setupUpdate :: ClosureInfo -> LocalReg -> FCode () -> FCode () -- Nota Bene: this function does not change Node (even if it's a CAF), ===================================== compiler/GHC/Utils/TmpFs.hs ===================================== @@ -196,7 +196,7 @@ changeTempFilesLifetime tmpfs lifetime files = do FilesToClean { ftcCurrentModule = cm_files , ftcGhcSession = gs_files - } <- readIORef (tmp_files_to_clean tmpfs) + } <- atomicReadIORef (tmp_files_to_clean tmpfs) let old_set = case lifetime of TFL_CurrentModule -> gs_files TFL_GhcSession -> cm_files @@ -257,11 +257,14 @@ newTempLibName logger tmpfs tmp_dir lifetime extn return (filename, dir, libname) +atomicReadIORef :: IORef a -> IO a +atomicReadIORef ref = atomicModifyIORef' ref $ \x -> (x,x) + -- Return our temporary directory within tmp_dir, creating one if we -- don't have one yet. getTempDir :: Logger -> TmpFs -> TempDir -> IO FilePath getTempDir logger tmpfs (TempDir tmp_dir) = do - mapping <- readIORef dir_ref + mapping <- atomicReadIORef dir_ref case Map.lookup tmp_dir mapping of Nothing -> do pid <- getProcessID ===================================== rts/PrimOps.cmm ===================================== @@ -1728,7 +1728,7 @@ stg_takeMVarzh ( P_ mvar /* :: MVar a */ ) // Write barrier before we make the new MVAR_TSO_QUEUE // visible to other cores. // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -1895,7 +1895,7 @@ stg_putMVarzh ( P_ mvar, /* :: MVar a */ SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -2104,7 +2104,7 @@ stg_readMVarzh ( P_ mvar, /* :: MVar a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgTSO__link(CurrentTSO) = q; StgTSO_block_info(CurrentTSO) = mvar; @@ -2237,7 +2237,7 @@ stg_readIOPortzh ( P_ ioport /* :: IOPort a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgMVar_head(ioport) = q; StgTSO__link(CurrentTSO) = q; @@ -2389,7 +2389,8 @@ stg_makeStableNamezh ( P_ obj ) /* Is there already a StableName for this heap object? * stable_name_table is a pointer to an array of snEntry structs. */ - if ( snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) == NULL ) { + sn_obj = %acquire snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + if (sn_obj == NULL) { // At this point we have a snEntry, but it doesn't look as used to the // GC yet because we don't have a StableName object for the sn_obj field // (remember that sn_obj == NULL means the entry is free). So if we call @@ -2406,10 +2407,7 @@ stg_makeStableNamezh ( P_ obj ) // This will make the StableName# object visible to other threads; // be sure that its completely visible to other cores. // See Note [Heap memory barriers] in SMP.h. - prim_write_barrier; - snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; - } else { - sn_obj = snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + %release snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; } return (sn_obj); ===================================== rts/include/Cmm.h ===================================== @@ -280,8 +280,7 @@ // "used". #define LOAD_INFO_ACQUIRE(ret,x) \ - info = %INFO_PTR(UNTAG(x)); \ - prim_read_barrier; + info = %acquire StgHeader_info(UNTAG(x)); #define UNTAG_IF_PROF(x) UNTAG(x) @@ -291,8 +290,7 @@ if (GETTAG(x) != 0) { \ ret(x); \ } \ - info = %INFO_PTR(x); \ - prim_read_barrier; + info = %acquire StgHeader_info(x); #define UNTAG_IF_PROF(x) (x) /* already untagged */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/617a46d7005861fe2919403d87995f3f955d3b27...46683a0f6025c67522900c5460f2eb7bb7c3fdcb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/617a46d7005861fe2919403d87995f3f955d3b27...46683a0f6025c67522900c5460f2eb7bb7c3fdcb You're receiving 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 Nov 15 21:10:31 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 15 Nov 2022 16:10:31 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 3 commits: compiler: Use release store in eager blackholing Message-ID: <637400479125a_38f79f528a04918b5@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 3a64c9ac by Ben Gamari at 2022-11-15T16:10:26-05:00 compiler: Use release store in eager blackholing - - - - - 1b049b0a by Ben Gamari at 2022-11-15T16:10:26-05:00 rts: Fix ordering of makeStableName - - - - - e7ac076a by Ben Gamari at 2022-11-15T16:10:26-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - 3 changed files: - compiler/GHC/StgToCmm/Bind.hs - rts/PrimOps.cmm - rts/include/Cmm.h Changes: ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -703,8 +703,8 @@ emitBlackHoleCode node = do whenUpdRemSetEnabled $ emitUpdRemSetPushThunk node emitStore (cmmOffsetW platform node (fixedHdrSizeW profile)) currentTSOExpr -- See Note [Heap memory barriers] in SMP.h. - emitPrimCall [] MO_WriteBarrier [] - emitStore node (CmmReg (CmmGlobal EagerBlackholeInfo)) + let w = wordWidth platform + emitPrimCall [] (MO_AtomicWrite w MemOrderRelease) [node, CmmReg (CmmGlobal EagerBlockholeInfo)] setupUpdate :: ClosureInfo -> LocalReg -> FCode () -> FCode () -- Nota Bene: this function does not change Node (even if it's a CAF), ===================================== rts/PrimOps.cmm ===================================== @@ -1728,7 +1728,7 @@ stg_takeMVarzh ( P_ mvar /* :: MVar a */ ) // Write barrier before we make the new MVAR_TSO_QUEUE // visible to other cores. // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -1895,7 +1895,7 @@ stg_putMVarzh ( P_ mvar, /* :: MVar a */ SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -2104,7 +2104,7 @@ stg_readMVarzh ( P_ mvar, /* :: MVar a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgTSO__link(CurrentTSO) = q; StgTSO_block_info(CurrentTSO) = mvar; @@ -2237,7 +2237,7 @@ stg_readIOPortzh ( P_ ioport /* :: IOPort a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgMVar_head(ioport) = q; StgTSO__link(CurrentTSO) = q; @@ -2389,7 +2389,8 @@ stg_makeStableNamezh ( P_ obj ) /* Is there already a StableName for this heap object? * stable_name_table is a pointer to an array of snEntry structs. */ - if ( snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) == NULL ) { + sn_obj = %acquire snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + if (sn_obj == NULL) { // At this point we have a snEntry, but it doesn't look as used to the // GC yet because we don't have a StableName object for the sn_obj field // (remember that sn_obj == NULL means the entry is free). So if we call @@ -2406,10 +2407,7 @@ stg_makeStableNamezh ( P_ obj ) // This will make the StableName# object visible to other threads; // be sure that its completely visible to other cores. // See Note [Heap memory barriers] in SMP.h. - prim_write_barrier; - snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; - } else { - sn_obj = snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + %release snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; } return (sn_obj); ===================================== rts/include/Cmm.h ===================================== @@ -280,8 +280,7 @@ // "used". #define LOAD_INFO_ACQUIRE(ret,x) \ - info = %INFO_PTR(UNTAG(x)); \ - prim_read_barrier; + info = %acquire StgHeader_info(UNTAG(x)); #define UNTAG_IF_PROF(x) UNTAG(x) @@ -291,8 +290,7 @@ if (GETTAG(x) != 0) { \ ret(x); \ } \ - info = %INFO_PTR(x); \ - prim_read_barrier; + info = %acquire StgHeader_info(x); #define UNTAG_IF_PROF(x) (x) /* already untagged */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/46683a0f6025c67522900c5460f2eb7bb7c3fdcb...e7ac076ab11fc0304ff2c1bc3013068a2b13ed93 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/46683a0f6025c67522900c5460f2eb7bb7c3fdcb...e7ac076ab11fc0304ff2c1bc3013068a2b13ed93 You're receiving 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 Nov 15 21:11:37 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 15 Nov 2022 16:11:37 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 3 commits: compiler: Use release store in eager blackholing Message-ID: <63740089d7321_38f79f52864492381@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: efd1ef46 by Ben Gamari at 2022-11-15T16:11:32-05:00 compiler: Use release store in eager blackholing - - - - - 020f1077 by Ben Gamari at 2022-11-15T16:11:32-05:00 rts: Fix ordering of makeStableName - - - - - de0a6eff by Ben Gamari at 2022-11-15T16:11:32-05:00 rts: Use ordered accesses instead of explicit barriers - - - - - 3 changed files: - compiler/GHC/StgToCmm/Bind.hs - rts/PrimOps.cmm - rts/include/Cmm.h Changes: ===================================== compiler/GHC/StgToCmm/Bind.hs ===================================== @@ -703,8 +703,8 @@ emitBlackHoleCode node = do whenUpdRemSetEnabled $ emitUpdRemSetPushThunk node emitStore (cmmOffsetW platform node (fixedHdrSizeW profile)) currentTSOExpr -- See Note [Heap memory barriers] in SMP.h. - emitPrimCall [] MO_WriteBarrier [] - emitStore node (CmmReg (CmmGlobal EagerBlackholeInfo)) + let w = wordWidth platform + emitPrimCall [] (MO_AtomicWrite w MemOrderRelease) [node, CmmReg (CmmGlobal EagerBlackholeInfo)] setupUpdate :: ClosureInfo -> LocalReg -> FCode () -> FCode () -- Nota Bene: this function does not change Node (even if it's a CAF), ===================================== rts/PrimOps.cmm ===================================== @@ -1728,7 +1728,7 @@ stg_takeMVarzh ( P_ mvar /* :: MVar a */ ) // Write barrier before we make the new MVAR_TSO_QUEUE // visible to other cores. // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -1895,7 +1895,7 @@ stg_putMVarzh ( P_ mvar, /* :: MVar a */ SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; if (StgMVar_head(mvar) == stg_END_TSO_QUEUE_closure) { StgMVar_head(mvar) = q; @@ -2104,7 +2104,7 @@ stg_readMVarzh ( P_ mvar, /* :: MVar a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgTSO__link(CurrentTSO) = q; StgTSO_block_info(CurrentTSO) = mvar; @@ -2237,7 +2237,7 @@ stg_readIOPortzh ( P_ ioport /* :: IOPort a */ ) SET_HDR(q, stg_MVAR_TSO_QUEUE_info, CCS_SYSTEM); // See Note [Heap memory barriers] - prim_write_barrier; + RELEASE_FENCE; StgMVar_head(ioport) = q; StgTSO__link(CurrentTSO) = q; @@ -2389,7 +2389,8 @@ stg_makeStableNamezh ( P_ obj ) /* Is there already a StableName for this heap object? * stable_name_table is a pointer to an array of snEntry structs. */ - if ( snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) == NULL ) { + sn_obj = %acquire snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + if (sn_obj == NULL) { // At this point we have a snEntry, but it doesn't look as used to the // GC yet because we don't have a StableName object for the sn_obj field // (remember that sn_obj == NULL means the entry is free). So if we call @@ -2406,10 +2407,7 @@ stg_makeStableNamezh ( P_ obj ) // This will make the StableName# object visible to other threads; // be sure that its completely visible to other cores. // See Note [Heap memory barriers] in SMP.h. - prim_write_barrier; - snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; - } else { - sn_obj = snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry); + %release snEntry_sn_obj(W_[stable_name_table] + index*SIZEOF_snEntry) = sn_obj; } return (sn_obj); ===================================== rts/include/Cmm.h ===================================== @@ -280,8 +280,7 @@ // "used". #define LOAD_INFO_ACQUIRE(ret,x) \ - info = %INFO_PTR(UNTAG(x)); \ - prim_read_barrier; + info = %acquire StgHeader_info(UNTAG(x)); #define UNTAG_IF_PROF(x) UNTAG(x) @@ -291,8 +290,7 @@ if (GETTAG(x) != 0) { \ ret(x); \ } \ - info = %INFO_PTR(x); \ - prim_read_barrier; + info = %acquire StgHeader_info(x); #define UNTAG_IF_PROF(x) (x) /* already untagged */ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e7ac076ab11fc0304ff2c1bc3013068a2b13ed93...de0a6eff379bc2c92717aec5e3513296b631305f -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/e7ac076ab11fc0304ff2c1bc3013068a2b13ed93...de0a6eff379bc2c92717aec5e3513296b631305f You're receiving 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 Nov 16 00:16:02 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 15 Nov 2022 19:16:02 -0500 Subject: [Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: configure: Don't check for an unsupported version of LLVM Message-ID: <63742bc2b0e7f_38f79f52904522566@gitlab.mail> Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 57f0fe19 by ARATA Mizuki at 2022-11-15T19:15:51-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 1388e381 by Bodigrim at 2022-11-15T19:15:55-05:00 Fix capitalization in haddock for TestEquality - - - - - 2 changed files: - libraries/base/Data/Type/Equality.hs - m4/find_llvm_prog.m4 Changes: ===================================== libraries/base/Data/Type/Equality.hs ===================================== @@ -152,14 +152,14 @@ deriving instance a ~~ b => Bounded (a :~~: b) -- The result should be @Just Refl@ if and only if the types applied to @f@ are -- equal: -- --- @TestEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b@ +-- @testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b@ -- -- Typically, only singleton types should inhabit this class. In that case type -- argument equality coincides with term equality: -- --- @TestEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y@ +-- @testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y@ -- --- @isJust (TestEquality x y) = x == y@ +-- @isJust (testEquality x y) = x == y@ -- -- Singleton types are not required, however, and so the latter two would-be -- laws are not in fact valid in general. ===================================== m4/find_llvm_prog.m4 ===================================== @@ -11,7 +11,7 @@ # AC_DEFUN([FIND_LLVM_PROG],[ # Test for program with and without version name. - PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $4 -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0 $2$llvmVersion"; done) + PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $(($4-1)) -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0 $2$llvmVersion"; done) AC_CHECK_TOOLS([$1], [$PROG_VERSION_CANDIDATES $2], []) AS_IF([test x"$$1" != x],[ PROG_VERSION=`$$1 --version | awk '/.*version [[0-9\.]]+/{for(i=1;i<=NF;i++){ if(\$i ~ /^[[0-9\.]]+$/){print \$i}}}'` View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77e0e36f9590033638a60a80765154e15712d252...1388e38149b7098791fef82feef54aeaecd637fe -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/77e0e36f9590033638a60a80765154e15712d252...1388e38149b7098791fef82feef54aeaecd637fe You're receiving 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 Nov 16 01:23:34 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 15 Nov 2022 20:23:34 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] 3 commits: getCapability Message-ID: <63743b9621a68_38f79f5286453148e@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 4d5cbb90 by Ben Gamari at 2022-11-15T17:52:32-05:00 getCapability - - - - - 723b92f3 by Ben Gamari at 2022-11-15T17:52:33-05:00 rts: Statically allocate capabilities This is a rather simplistic way of solving #17289. - - - - - 526e6fb8 by Ben Gamari at 2022-11-15T20:23:26-05:00 Fix it - - - - - 6 changed files: - rts/Capability.c - rts/Capability.h - rts/IOManager.c - rts/Schedule.c - rts/Stats.c - rts/include/rts/Config.h Changes: ===================================== rts/Capability.c ===================================== @@ -45,7 +45,7 @@ uint32_t enabled_capabilities = 0; // Capabilities, because there may be pointers to them in use // (e.g. threads in waitForCapability(), see #8209), so this is // an array of Capability* rather than an array of Capability. -Capability **capabilities = NULL; +Capability *capabilities[MAX_N_CAPABILITIES]; // Holds the Capability which last became free. This is used so that // an in-call has a chance of quickly finding a free Capability. @@ -388,6 +388,12 @@ void initCapabilities (void) } #endif + if (RtsFlags.ParFlags.nCapabilities > MAX_N_CAPABILITIES) { + errorBelch("warning: this GHC runtime system only supports up to %d capabilities", + MAX_N_CAPABILITIES); + RtsFlags.ParFlags.nCapabilities = MAX_N_CAPABILITIES; + } + n_capabilities = 0; moreCapabilities(0, RtsFlags.ParFlags.nCapabilities); n_capabilities = RtsFlags.ParFlags.nCapabilities; @@ -395,7 +401,6 @@ void initCapabilities (void) #else /* !THREADED_RTS */ n_capabilities = 1; - capabilities = stgMallocBytes(sizeof(Capability*), "initCapabilities"); capabilities[0] = &MainCapability; initCapability(&MainCapability, 0); @@ -408,7 +413,7 @@ void initCapabilities (void) // a worker Task to each Capability, which will quickly put the // Capability on the free list when it finds nothing to do. for (i = 0; i < n_numa_nodes; i++) { - last_free_capability[i] = capabilities[0]; + last_free_capability[i] = getCapability(0); } } @@ -416,8 +421,6 @@ void moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) { #if defined(THREADED_RTS) - Capability **new_capabilities = stgMallocBytes(to * sizeof(Capability*), "moreCapabilities"); - // We must disable the timer while we do this since the tick handler may // call contextSwitchAllCapabilities, which may see the capabilities array // as we free it. The alternative would be to protect the capabilities @@ -429,30 +432,22 @@ moreCapabilities (uint32_t from USED_IF_THREADS, uint32_t to USED_IF_THREADS) // THREADED_RTS must work on builds that don't have a mutable // BaseReg (eg. unregisterised), so in this case // capabilities[0] must coincide with &MainCapability. - new_capabilities[0] = &MainCapability; + capabilities[0] = &MainCapability; initCapability(&MainCapability, 0); } else { for (uint32_t i = 0; i < to; i++) { - if (i < from) { - new_capabilities[i] = capabilities[i]; - } else { - new_capabilities[i] = stgMallocBytes(sizeof(Capability), + if (i >= from) { + capabilities[i] = stgMallocBytes(sizeof(Capability), "moreCapabilities"); - initCapability(new_capabilities[i], i); + initCapability(capabilities[i], i); } } } debugTrace(DEBUG_sched, "allocated %d more capabilities", to - from); - Capability **old_capabilities = ACQUIRE_LOAD(&capabilities); - RELEASE_STORE(&capabilities, new_capabilities); - if (old_capabilities != NULL) { - stgFree(old_capabilities); - } - startTimer(); #endif } @@ -828,8 +823,7 @@ static Capability * find_capability_for_task(const Task * task) { if (task->preferred_capability != -1) { // Does the task have a preferred capability? If so, use it - return capabilities[task->preferred_capability % - enabled_capabilities]; + return getCapability(task->preferred_capability % enabled_capabilities); } else { // Try last_free_capability first Capability *cap = RELAXED_LOAD(&last_free_capability[task->node]); ===================================== rts/Capability.h ===================================== @@ -261,11 +261,11 @@ INLINE_HEADER void releaseCapability_ (Capability* cap STG_UNUSED, // extern uint32_t enabled_capabilities; // Array of all the capabilities -extern Capability **capabilities; +extern Capability *capabilities[MAX_N_CAPABILITIES]; INLINE_HEADER Capability *getCapability(uint32_t i) { - return RELAXED_LOAD(&capabilities)[i]; + return RELAXED_LOAD(&capabilities[i]); } // ===================================== rts/IOManager.c ===================================== @@ -140,7 +140,7 @@ void setIOManagerControlFd(uint32_t cap_no USED_IF_THREADS, int fd USED_IF_THREADS) { #if defined(THREADED_RTS) if (cap_no < n_capabilities) { - RELAXED_STORE(&capabilities[cap_no]->io_manager_control_wr_fd, fd); + RELAXED_STORE(&getCapability(cap_no)->io_manager_control_wr_fd, fd); } else { errorBelch("warning: setIOManagerControlFd called with illegal capability number."); } ===================================== rts/Schedule.c ===================================== @@ -1839,7 +1839,7 @@ delete_threads_and_gc: tmp_cap = getCapability(i); ASSERT(tmp_cap->disabled); if (i != cap->no) { - dest_cap = capabilities[i % enabled_capabilities]; + dest_cap = getCapability(i % enabled_capabilities); while (!emptyRunQueue(tmp_cap)) { tso = popRunQueue(tmp_cap); migrateThread(tmp_cap, tso, dest_cap); @@ -2600,9 +2600,9 @@ scheduleThreadOn(Capability *cap, StgWord cpu USED_IF_THREADS, StgTSO *tso) if (cpu == cap->no) { appendToRunQueue(cap,tso); } else { - migrateThread(cap, tso, capabilities[cpu]); + migrateThread(cap, tso, getCapability(cpu)); } - contextSwitchCapability(capabilities[cpu], false); + contextSwitchCapability(getCapability(cpu), false); #else appendToRunQueue(cap,tso); contextSwitchCapability(cap, false); ===================================== rts/Stats.c ===================================== @@ -1351,14 +1351,14 @@ stat_exitReport (void) sum.bound_task_count = taskCount - workerCount; for (uint32_t i = 0; i < getNumCapabilities(); i++) { - sum.sparks.created += capabilities[i]->spark_stats.created; - sum.sparks.dud += capabilities[i]->spark_stats.dud; + sum.sparks.created += getCapability(i)->spark_stats.created; + sum.sparks.dud += getCapability(i)->spark_stats.dud; sum.sparks.overflowed+= - capabilities[i]->spark_stats.overflowed; + getCapability(i)->spark_stats.overflowed; sum.sparks.converted += - capabilities[i]->spark_stats.converted; - sum.sparks.gcd += capabilities[i]->spark_stats.gcd; - sum.sparks.fizzled += capabilities[i]->spark_stats.fizzled; + getCapability(i)->spark_stats.converted; + sum.sparks.gcd += getCapability(i)->spark_stats.gcd; + sum.sparks.fizzled += getCapability(i)->spark_stats.fizzled; } sum.sparks_count = sum.sparks.created @@ -1650,10 +1650,10 @@ statDescribeGens(void) mut = 0; for (i = 0; i < getNumCapabilities(); i++) { - mut += countOccupied(capabilities[i]->mut_lists[g]); + mut += countOccupied(getCapability(i)->mut_lists[g]); // Add the pinned object block. - bd = capabilities[i]->pinned_object_block; + bd = getCapability(i)->pinned_object_block; if (bd != NULL) { gen_live += bd->free - bd->start; gen_blocks += bd->blocks; ===================================== rts/include/rts/Config.h ===================================== @@ -76,3 +76,9 @@ code. #if defined(DEBUG) #define PROF_SPIN #endif + +#if defined(THREADED_RTS) +#define MAX_N_CAPABILITIES 256 +#else +#define MAX_N_CAPABILITIES 1 +#endif View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de0a6eff379bc2c92717aec5e3513296b631305f...526e6fb85f29270337ad5b4d6761347a996bea03 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/de0a6eff379bc2c92717aec5e3513296b631305f...526e6fb85f29270337ad5b4d6761347a996bea03 You're receiving 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 Nov 16 01:27:49 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 15 Nov 2022 20:27:49 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] MutVar Message-ID: <63743c95b2b10_38f79f5294053193f@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: e4b9f92d by Ben Gamari at 2022-11-15T20:27:43-05:00 MutVar - - - - - 1 changed file: - rts/PrimOps.cmm Changes: ===================================== rts/PrimOps.cmm ===================================== @@ -829,7 +829,7 @@ stg_atomicModifyMutVarzuzh ( gcptr mv, gcptr f ) StgThunk_payload(z,0) = f; retry: - x = StgMutVar_var(mv); + x = %relaxed StgMutVar_var(mv); StgThunk_payload(z,1) = x; #if defined(THREADED_RTS) (h) = prim %cmpxchgW(mv + SIZEOF_StgHeader + OFFSET_StgMutVar_var, x, z); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e4b9f92d9aa27033dff4b9ebf10b2583d9826ade -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e4b9f92d9aa27033dff4b9ebf10b2583d9826ade You're receiving 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 Nov 16 02:36:22 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 15 Nov 2022 21:36:22 -0500 Subject: [Git][ghc/ghc][master] configure: Don't check for an unsupported version of LLVM Message-ID: <63744ca62193_38f79f5288c543413@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 1 changed file: - m4/find_llvm_prog.m4 Changes: ===================================== m4/find_llvm_prog.m4 ===================================== @@ -11,7 +11,7 @@ # AC_DEFUN([FIND_LLVM_PROG],[ # Test for program with and without version name. - PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $4 -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0 $2$llvmVersion"; done) + PROG_VERSION_CANDIDATES=$(for llvmVersion in `seq $(($4-1)) -1 $3`; do echo "$2-$llvmVersion $2-$llvmVersion.0 $2$llvmVersion"; done) AC_CHECK_TOOLS([$1], [$PROG_VERSION_CANDIDATES $2], []) AS_IF([test x"$$1" != x],[ PROG_VERSION=`$$1 --version | awk '/.*version [[0-9\.]]+/{for(i=1;i<=NF;i++){ if(\$i ~ /^[[0-9\.]]+$/){print \$i}}}'` View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/94549f8fd6b40072a58125cffd21e387e709dd9c -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/94549f8fd6b40072a58125cffd21e387e709dd9c You're receiving 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 Nov 16 02:37:04 2022 From: gitlab at gitlab.haskell.org (Marge Bot (@marge-bot)) Date: Tue, 15 Nov 2022 21:37:04 -0500 Subject: [Git][ghc/ghc][master] Fix capitalization in haddock for TestEquality Message-ID: <63744cd0cb11e_38f79f5265c5472cf@gitlab.mail> Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 1 changed file: - libraries/base/Data/Type/Equality.hs Changes: ===================================== libraries/base/Data/Type/Equality.hs ===================================== @@ -152,14 +152,14 @@ deriving instance a ~~ b => Bounded (a :~~: b) -- The result should be @Just Refl@ if and only if the types applied to @f@ are -- equal: -- --- @TestEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b@ +-- @testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b@ -- -- Typically, only singleton types should inhabit this class. In that case type -- argument equality coincides with term equality: -- --- @TestEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y@ +-- @testEquality (x :: f a) (y :: f b) = Just Refl ⟺ a = b ⟺ x = y@ -- --- @isJust (TestEquality x y) = x == y@ +-- @isJust (testEquality x y) = x == y@ -- -- Singleton types are not required, however, and so the latter two would-be -- laws are not in fact valid in general. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/02d3511b8d248ea9429512830f8f17b31688a6a6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/02d3511b8d248ea9429512830f8f17b31688a6a6 You're receiving 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 Nov 16 04:14:06 2022 From: gitlab at gitlab.haskell.org (Ben Gamari (@bgamari)) Date: Tue, 15 Nov 2022 23:14:06 -0500 Subject: [Git][ghc/ghc][wip/tsan/codegen] Cap Message-ID: <6374638e5408d_38f79f528c85498d@gitlab.mail> Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC Commits: 5e3ff9e7 by Ben Gamari at 2022-11-15T20:36:29-05:00 Cap - - - - - 1 changed file: - rts/Capability.c Changes: ===================================== rts/Capability.c ===================================== @@ -1281,7 +1281,6 @@ freeCapabilities (void) #else freeCapability(&MainCapability); #endif - stgFree(capabilities); traceCapsetDelete(CAPSET_OSPROCESS_DEFAULT); traceCapsetDelete(CAPSET_CLOCKDOMAIN_DEFAULT); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e3ff9e71f6219a5a8ae2bb6709a34dd79783243 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e3ff9e71f6219a5a8ae2bb6709a34dd79783243 You're receiving 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 Nov 16 07:50:32 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 16 Nov 2022 02:50:32 -0500 Subject: [Git][ghc/ghc] Pushed new branch wip/T21623-tycon Message-ID: <637496483fc7a_38f79f528a0570977@gitlab.mail> Simon Peyton Jones pushed new branch wip/T21623-tycon at Glasgow Haskell Compiler / GHC -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/T21623-tycon You're receiving 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 Nov 16 09:28:07 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 16 Nov 2022 04:28:07 -0500 Subject: [Git][ghc/ghc][wip/T21623-tycon] 2 commits: Wibbles Message-ID: <6374ad27bfb9a_38f79f528786016d0@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623-tycon at Glasgow Haskell Compiler / GHC Commits: 81dd780e by Simon Peyton Jones at 2022-11-16T09:29:37+00:00 Wibbles - - - - - eb5b644b by Simon Peyton Jones at 2022-11-16T09:29:43+00:00 Update haddock submodule - - - - - 4 changed files: - compiler/GHC/Core/TyCon.hs - compiler/GHC/Tc/Gen/Splice.hs - compiler/GHC/Tc/TyCl.hs - utils/haddock Changes: ===================================== compiler/GHC/Core/TyCon.hs ===================================== @@ -96,7 +96,7 @@ module GHC.Core.TyCon( tyConFamInst_maybe, tyConFamInstSig_maybe, tyConFamilyCoercion_maybe, tyConFamilyResVar_maybe, synTyConDefn_maybe, synTyConRhs_maybe, - famTyConFlav_maybe, famTcResVar, + famTyConFlav_maybe, algTyConRhs, newTyConRhs, newTyConEtadArity, newTyConEtadRhs, unwrapNewTyCon_maybe, unwrapNewTyConEtad_maybe, @@ -926,15 +926,15 @@ data TyConDetails = -- arguments to the type constructor; see the use -- of tyConArity in generaliseTcTyCon - tcTyConScopedTyVars :: [(Name,TcTyVar)], + tctc_scoped_tvs :: [(Name,TcTyVar)], -- ^ Scoped tyvars over the tycon's body -- The range is always a skolem or TcTyVar, be -- MonoTcTyCon only: see Note [Scoped tyvars in a TcTyCon] - tcTyConIsPoly :: Bool, -- ^ Is this TcTyCon already generalized? - -- Used only to make zonking more efficient + tctc_is_poly :: Bool, -- ^ Is this TcTyCon already generalized? + -- Used only to make zonking more efficient - tcTyConFlavour :: TyConFlavour + tctc_flavour :: TyConFlavour -- ^ What sort of 'TyCon' this represents. } @@ -1877,9 +1877,9 @@ mkTcTyCon :: Name -> TyCon mkTcTyCon name binders res_kind scoped_tvs poly flav = mkTyCon name binders res_kind (constRoles binders Nominal) $ - TcTyCon { tcTyConScopedTyVars = scoped_tvs - , tcTyConIsPoly = poly - , tcTyConFlavour = flav } + TcTyCon { tctc_scoped_tvs = scoped_tvs + , tctc_is_poly = poly + , tctc_flavour = flav } -- | No scoped type variables (to be used with mkTcTyCon). noTcTyConScopedTyVars :: [(Name, TcTyVar)] @@ -2345,29 +2345,6 @@ tyConCType_maybe (TyCon { tyConDetails = details }) | AlgTyCon { tyConCType = mb_ctype} <- details = mb_ctype | otherwise = Nothing --- | Is this a TcTyCon? (That is, one only used during type-checking?) -isTcTyCon :: TyCon -> Bool -isTcTyCon (TyCon { tyConDetails = details }) - | TcTyCon {} <- details = True - | otherwise = False - -setTcTyConKind :: TyCon -> Kind -> TyCon --- Update the Kind of a TcTyCon --- The new kind is always a zonked version of its previous --- kind, so we don't need to update any other fields. --- See Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType -setTcTyConKind tc kind - = assert (isMonoTcTyCon tc) $ - let tc' = tc { tyConKind = kind - , tyConNullaryTy = mkNakedTyConTy tc' } - -- See Note [Sharing nullary TyConApps] - in tc' - -isMonoTcTyCon :: TyCon -> Bool -isMonoTcTyCon (TyCon { tyConDetails = details }) - | TcTyCon { tcTyConIsPoly = is_poly } <- details = not is_poly - | otherwise = False - -- | Does this 'TyCon' have a syntactically fixed RuntimeRep when fully applied, -- as per Note [Fixed RuntimeRep] in GHC.Tc.Utils.Concrete? -- @@ -2428,6 +2405,40 @@ isConcreteTyConFlavour = \case BuiltInTypeFlavour -> True PromotedDataConFlavour -> True +{- +----------------------------------------------- +-- TcTyCon +----------------------------------------------- +-} + +-- | Is this a TcTyCon? (That is, one only used during type-checking?) +isTcTyCon :: TyCon -> Bool +isTcTyCon (TyCon { tyConDetails = details }) + | TcTyCon {} <- details = True + | otherwise = False + +setTcTyConKind :: TyCon -> Kind -> TyCon +-- Update the Kind of a TcTyCon +-- The new kind is always a zonked version of its previous +-- kind, so we don't need to update any other fields. +-- See Note [The Purely Kinded Type Invariant (PKTI)] in GHC.Tc.Gen.HsType +setTcTyConKind tc kind + = assert (isMonoTcTyCon tc) $ + let tc' = tc { tyConKind = kind + , tyConNullaryTy = mkNakedTyConTy tc' } + -- See Note [Sharing nullary TyConApps] + in tc' + +isMonoTcTyCon :: TyCon -> Bool +isMonoTcTyCon (TyCon { tyConDetails = details }) + | TcTyCon { tctc_is_poly = is_poly } <- details = not is_poly + | otherwise = False + +tcTyConScopedTyVars :: TyCon -> [(Name,TcTyVar)] +tcTyConScopedTyVars tc@(TyCon { tyConDetails = details }) + | TcTyCon { tctc_scoped_tvs = scoped_tvs } <- details = scoped_tvs + | otherwise = pprPanic "tcTyConScopedTyVars" (ppr tc) + {- ----------------------------------------------- -- Expand type-constructor applications @@ -2801,7 +2812,7 @@ tyConFlavour (TyCon { tyConDetails = details }) | SynonymTyCon {} <- details = TypeSynonymFlavour | PrimTyCon {} <- details = BuiltInTypeFlavour | PromotedDataCon {} <- details = PromotedDataConFlavour - | TcTyCon { tcTyConFlavour = flav } <-details = flav + | TcTyCon { tctc_flavour = flav } <-details = flav -- | Can this flavour of 'TyCon' appear unsaturated? tcFlavourMustBeSaturated :: TyConFlavour -> Bool ===================================== compiler/GHC/Tc/Gen/Splice.hs ===================================== @@ -2121,7 +2121,7 @@ reifyTyCon tc | isTypeFamilyTyCon tc = do { let tvs = tyConTyVars tc res_kind = tyConResKind tc - resVar = famTcResVar tc + resVar = tyConFamilyResVar_maybe tc ; kind' <- reifyKind res_kind ; let (resultSig, injectivity) = ===================================== compiler/GHC/Tc/TyCl.hs ===================================== @@ -5177,8 +5177,7 @@ addVDQNote :: TcTyCon -> TcM a -> TcM a -- See Note [Inferring visible dependent quantification] -- Only types without a signature (CUSK or SAK) here addVDQNote tycon thing_inside - | assertPpr (isTcTyCon tycon) (ppr tycon) $ - assertPpr (not (tcTyConIsPoly tycon)) (ppr tycon $$ ppr tc_kind) + | assertPpr (isMonoTcTyCon tycon) (ppr tycon $$ ppr tc_kind) has_vdq = addLandmarkErrCtxt vdq_warning thing_inside | otherwise ===================================== utils/haddock ===================================== @@ -1 +1 @@ -Subproject commit 2ffde83344bab8ed0aee3e8ef46f43856c7ca6ef +Subproject commit 9f3d49deb0463294c86af35d7bda5e577360298f View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8dc40e9a9e51acc2626eb5a3b0b30c0190e3c06...eb5b644b3805c13f8be09b1bb0fc80e30b9ac686 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d8dc40e9a9e51acc2626eb5a3b0b30c0190e3c06...eb5b644b3805c13f8be09b1bb0fc80e30b9ac686 You're receiving 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 Nov 16 10:51:26 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 16 Nov 2022 05:51:26 -0500 Subject: [Git][ghc/ghc][wip/T22317] Simplifier: Consider `seq` as a `BoringCtxt` (#22317) Message-ID: <6374c0ae148a6_38f79f528646177a@gitlab.mail> Sebastian Graf pushed to branch wip/T22317 at Glasgow Haskell Compiler / GHC Commits: 8c81c480 by Sebastian Graf at 2022-11-16T11:51:17+01:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 5 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Unfold.hs - + testsuite/tests/simplCore/should_compile/T22317.hs - + testsuite/tests/simplCore/should_compile/T22317.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -740,8 +740,8 @@ Note [Interesting call context] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want to avoid inlining an expression where there can't possibly be any gain, such as in an argument position. Hence, if the continuation -is interesting (eg. a case scrutinee, application etc.) then we -inline, otherwise we don't. +is interesting (eg. a case scrutinee that isn't just a seq, application etc.) +then we inline, otherwise we don't. Previously some_benefit used to return True only if the variable was applied to some value arguments. This didn't work: @@ -781,6 +781,53 @@ expression into the branches of any case in f's unfolding. So, to reduce unnecessary code expansion, we just make the context look boring. This made a small compile-time perf improvement in perf/compiler/T6048, and it looks plausible to me. + +Note [Seq is boring] +~~~~~~~~~~~~~~~~~~~~ +Consider T22317 + + data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) + + m :: Maybe a -> Maybe a -> Maybe a + m = \ (@a_az7) (ds_dAn :: Maybe a_az7) (ds_dAo :: Maybe a_az7) -> + case ds_dAn of { + Nothing -> ds_dAo; + Just v1_awh -> + case ds_dAo of wild_X2 { + Nothing -> GHC.Maybe.Just @a_az7 v1_awh; + Just ipv_sAC -> ds_dAo + } + } + {-# INLINE m #-} + + f :: T -> T -> T + f = \ (ds_dAv :: T) (ds_dAw :: T) -> + case ds_dAv of { T a1_awj b1_awk c1_awl d1_awm -> + case ds_dAw of { T a2_awn b2_awo c2_awp d2_awq -> + case m @Bool a1_awj a2_awn of a_X3 { __DEFAULT -> + case m @Bool b1_awk b2_awo of b_X4 { __DEFAULT -> + case m @Bool c1_awl c2_awp of c_X6 { __DEFAULT -> + case m @Bool d1_awm d2_awq of d_X8 { __DEFAULT -> + Lib.T a_X3 b_X4 c_X6 d_X8 }}}}}} + +Here we gain absolutely nothing by inlining `m`, just a bunch of join points +from `m`'s definition and and case-of-case, bloating up the code. +Hence even though case-of-case would fire here, we refrain from inlining `m`. +We do so by regarding a seq context as a `BoringCtxt` (not `CaseCxt`). + +On the other hand, T14955 gives a compelling example where we want to +inline a CPR'd wrapper + + test3 xs = case xs of [] -> True; (x:xs) -> test3 xs + ==> + $wtest3 xs = case xs of [] -> (##); (x:xs) -> case test3 xs of __DEFAULT -> (##) + test3 xs = case $wtest3 xs of (##) -> True + +And it would be stupid not to inline test3 into $wtest3. +Crucially, the case binder is dead in the latter example but not in the +former, so the latter is much more likely to cancel away the result of +test3 (and indeed it does), whereas a non-dead case binder indicates that +the thing is going to be put in a field. -} lazyArgContext :: ArgInfo -> CallCtxt @@ -811,10 +858,12 @@ interestingCallContext :: SimplEnv -> SimplCont -> CallCtxt interestingCallContext env cont = interesting cont where - interesting (Select {}) - | seCaseCase env = CaseCtxt - | otherwise = BoringCtxt - -- See Note [No case of case is boring] + interesting (Select {sc_alts=alts, sc_bndr=case_bndr}) + | not (seCaseCase env) = BoringCtxt -- See Note [No case of case is boring] + | [Alt DEFAULT _ _] <- alts + , not (isDeadBinder case_bndr) = BoringCtxt -- See Note [Seq is boring] + | otherwise = CaseCtxt + interesting (ApplyToVal {}) = ValAppCtxt -- Can happen if we have (f Int |> co) y ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -1347,8 +1347,11 @@ call is at least CONLIKE. At least for the cases where we use ArgCtxt for the RHS of a 'let', we only profit from the inlining if we get a CONLIKE thing (modulo lets). -Note [Lone variables] See also Note [Interaction of exprIsWorkFree and lone variables] -~~~~~~~~~~~~~~~~~~~~~ which appears below +Note [Lone variables] +~~~~~~~~~~~~~~~~~~~~~ +See also Note [Interaction of exprIsWorkFree and lone variables] +which appears below + The "lone-variable" case is important. I spent ages messing about with unsatisfactory variants, but this is nice. The idea is that if a variable appears all alone ===================================== testsuite/tests/simplCore/should_compile/T22317.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE BangPatterns #-} + +module T22317 where + +data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) + + +m :: Maybe a -> Maybe a -> Maybe a +m (Just v1) Nothing = Just v1 +m _ mb = mb +{-# INLINE m #-} + +f :: T -> T -> T +f (T a1 b1 c1 d1) (T a2 b2 c2 d2) + = let j1 !a = let j2 !b = let j3 !c = let j4 !d = T a b c d + in j4 (m d1 d2) + in j3 (m c1 c2) + in j2 (m b1 b2) + in j1 (m a1 a2) +{-# OPAQUE f #-} ===================================== testsuite/tests/simplCore/should_compile/T22317.stderr ===================================== @@ -0,0 +1,256 @@ +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -449,3 +449,5 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) +# Should not inline m, so there shouldn't be a single YES +test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m -ddebug-output']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8c81c480df60466a290b05c4337315cfbe8779f6 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8c81c480df60466a290b05c4337315cfbe8779f6 You're receiving 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 Nov 16 10:59:26 2022 From: gitlab at gitlab.haskell.org (Sebastian Graf (@sgraf812)) Date: Wed, 16 Nov 2022 05:59:26 -0500 Subject: [Git][ghc/ghc][wip/T22317] 2 commits: Make OpaqueNo* tests less noisy to unrelated changes Message-ID: <6374c28ea1fae_38f79f1264a958618069@gitlab.mail> Sebastian Graf pushed to branch wip/T22317 at Glasgow Haskell Compiler / GHC Commits: 34b55d44 by Sebastian Graf at 2022-11-16T11:59:18+01:00 Make OpaqueNo* tests less noisy to unrelated changes - - - - - 6b589a07 by Sebastian Graf at 2022-11-16T11:59:18+01:00 Simplifier: Consider `seq` as a `BoringCtxt` (#22317) See `Note [Seq is boring]` for the rationale. Fixes #22317. - - - - - 6 changed files: - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Unfold.hs - + testsuite/tests/simplCore/should_compile/T22317.hs - + testsuite/tests/simplCore/should_compile/T22317.stderr - testsuite/tests/simplCore/should_compile/T22375.stderr - testsuite/tests/simplCore/should_compile/all.T Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Utils.hs ===================================== @@ -740,8 +740,8 @@ Note [Interesting call context] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We want to avoid inlining an expression where there can't possibly be any gain, such as in an argument position. Hence, if the continuation -is interesting (eg. a case scrutinee, application etc.) then we -inline, otherwise we don't. +is interesting (eg. a case scrutinee that isn't just a seq, application etc.) +then we inline, otherwise we don't. Previously some_benefit used to return True only if the variable was applied to some value arguments. This didn't work: @@ -781,6 +781,53 @@ expression into the branches of any case in f's unfolding. So, to reduce unnecessary code expansion, we just make the context look boring. This made a small compile-time perf improvement in perf/compiler/T6048, and it looks plausible to me. + +Note [Seq is boring] +~~~~~~~~~~~~~~~~~~~~ +Consider T22317 + + data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) + + m :: Maybe a -> Maybe a -> Maybe a + m = \ (@a_az7) (ds_dAn :: Maybe a_az7) (ds_dAo :: Maybe a_az7) -> + case ds_dAn of { + Nothing -> ds_dAo; + Just v1_awh -> + case ds_dAo of wild_X2 { + Nothing -> GHC.Maybe.Just @a_az7 v1_awh; + Just ipv_sAC -> ds_dAo + } + } + {-# INLINE m #-} + + f :: T -> T -> T + f = \ (ds_dAv :: T) (ds_dAw :: T) -> + case ds_dAv of { T a1_awj b1_awk c1_awl d1_awm -> + case ds_dAw of { T a2_awn b2_awo c2_awp d2_awq -> + case m @Bool a1_awj a2_awn of a_X3 { __DEFAULT -> + case m @Bool b1_awk b2_awo of b_X4 { __DEFAULT -> + case m @Bool c1_awl c2_awp of c_X6 { __DEFAULT -> + case m @Bool d1_awm d2_awq of d_X8 { __DEFAULT -> + Lib.T a_X3 b_X4 c_X6 d_X8 }}}}}} + +Here we gain absolutely nothing by inlining `m`, just a bunch of join points +from `m`'s definition and and case-of-case, bloating up the code. +Hence even though case-of-case would fire here, we refrain from inlining `m`. +We do so by regarding a seq context as a `BoringCtxt` (not `CaseCxt`). + +On the other hand, T14955 gives a compelling example where we want to +inline a CPR'd wrapper + + test3 xs = case xs of [] -> True; (x:xs) -> test3 xs + ==> + $wtest3 xs = case xs of [] -> (##); (x:xs) -> case test3 xs of __DEFAULT -> (##) + test3 xs = case $wtest3 xs of (##) -> True + +And it would be stupid not to inline test3 into $wtest3. +Crucially, the case binder is dead in the latter example but not in the +former, so the latter is much more likely to cancel away the result of +test3 (and indeed it does), whereas a non-dead case binder indicates that +the thing is going to be put in a field. -} lazyArgContext :: ArgInfo -> CallCtxt @@ -811,10 +858,12 @@ interestingCallContext :: SimplEnv -> SimplCont -> CallCtxt interestingCallContext env cont = interesting cont where - interesting (Select {}) - | seCaseCase env = CaseCtxt - | otherwise = BoringCtxt - -- See Note [No case of case is boring] + interesting (Select {sc_alts=alts, sc_bndr=case_bndr}) + | not (seCaseCase env) = BoringCtxt -- See Note [No case of case is boring] + | [Alt DEFAULT _ _] <- alts + , not (isDeadBinder case_bndr) = BoringCtxt -- See Note [Seq is boring] + | otherwise = CaseCtxt + interesting (ApplyToVal {}) = ValAppCtxt -- Can happen if we have (f Int |> co) y ===================================== compiler/GHC/Core/Unfold.hs ===================================== @@ -1347,8 +1347,11 @@ call is at least CONLIKE. At least for the cases where we use ArgCtxt for the RHS of a 'let', we only profit from the inlining if we get a CONLIKE thing (modulo lets). -Note [Lone variables] See also Note [Interaction of exprIsWorkFree and lone variables] -~~~~~~~~~~~~~~~~~~~~~ which appears below +Note [Lone variables] +~~~~~~~~~~~~~~~~~~~~~ +See also Note [Interaction of exprIsWorkFree and lone variables] +which appears below + The "lone-variable" case is important. I spent ages messing about with unsatisfactory variants, but this is nice. The idea is that if a variable appears all alone ===================================== testsuite/tests/simplCore/should_compile/T22317.hs ===================================== @@ -0,0 +1,20 @@ +{-# LANGUAGE BangPatterns #-} + +module T22317 where + +data T = T (Maybe Bool) (Maybe Bool) (Maybe Bool) (Maybe Bool) + + +m :: Maybe a -> Maybe a -> Maybe a +m (Just v1) Nothing = Just v1 +m _ mb = mb +{-# INLINE m #-} + +f :: T -> T -> T +f (T a1 b1 c1 d1) (T a2 b2 c2 d2) + = let j1 !a = let j2 !b = let j3 !c = let j4 !d = T a b c d + in j4 (m d1 d2) + in j3 (m c1 c2) + in j2 (m b1 b2) + in j1 (m a1 a2) +{-# OPAQUE f #-} ===================================== testsuite/tests/simplCore/should_compile/T22317.stderr ===================================== @@ -0,0 +1,256 @@ +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO +Considering inlining: m + arg infos [TrivArg, TrivArg] + interesting continuation BoringCtxt + some_benefit False + is exp: True + is work-free: True + guidance ALWAYS_IF(arity=2,unsat_ok=False,boring_ok=False) + ANSWER = NO ===================================== testsuite/tests/simplCore/should_compile/T22375.stderr ===================================== @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 71, types: 31, coercions: 0, joins: 0/0} + = {terms: 76, types: 37, coercions: 0, joins: 0/0} -- RHS size: {terms: 14, types: 7, coercions: 0, joins: 0/0} T22375.$fEqX_$c== :: X -> X -> Bool @@ -46,7 +46,24 @@ T22375.$fEqX [InlPrag=CONLIKE] :: Eq X T22375.$fEqX = GHC.Classes.C:Eq @X T22375.$fEqX_$c== T22375.$fEqX_$c/= --- RHS size: {terms: 32, types: 5, coercions: 0, joins: 0/0} +-- RHS size: {terms: 24, types: 3, coercions: 0, joins: 0/0} +T22375.$wf [InlPrag=[2]] :: X -> GHC.Prim.Int# -> GHC.Prim.Int# +[GblId[StrictWorker([!])], + Arity=2, + Str=<1L>, + Unf=Unf{Src=, TopLvl=True, Value=True, ConLike=True, + WorkFree=True, Expandable=True, Guidance=IF_ARGS [64 0] 55 0}] +T22375.$wf + = \ (x :: X) (ww :: GHC.Prim.Int#) -> + case x of { + A -> GHC.Prim.+# 1# ww; + B -> GHC.Prim.+# 2# ww; + C -> GHC.Prim.+# 3# ww; + D -> GHC.Prim.+# 4# ww; + E -> GHC.Prim.+# 5# ww + } + +-- RHS size: {terms: 12, types: 5, coercions: 0, joins: 0/0} f [InlPrag=[2]] :: X -> Int -> Int [GblId, Arity=2, @@ -57,13 +74,7 @@ f [InlPrag=[2]] :: X -> Int -> Int Guidance=ALWAYS_IF(arity=2,unsat_ok=True,boring_ok=False)}] f = \ (x :: X) (v :: Int) -> case v of { GHC.Types.I# ww -> - case x of { - A -> GHC.Types.I# (GHC.Prim.+# 1# ww); - B -> GHC.Types.I# (GHC.Prim.+# 2# ww); - C -> GHC.Types.I# (GHC.Prim.+# 3# ww); - D -> GHC.Types.I# (GHC.Prim.+# 4# ww); - E -> GHC.Types.I# (GHC.Prim.+# 5# ww) - } + case T22375.$wf x ww of ww1 { __DEFAULT -> GHC.Types.I# ww1 } } ===================================== testsuite/tests/simplCore/should_compile/all.T ===================================== @@ -388,15 +388,15 @@ test('T20820', normal, compile, ['-O0']) # Verify that the letrec is still there test('T20895', [ grep_errmsg(r'\s*=\s*letrec') ], compile, ['-O0 -ddump-simpl -dsuppress-all -fno-local-float-out-top-level']) -test('OpaqueNoAbsentArgWW', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoAbsentArgWW', [ grep_errmsg(r'$wf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('OpaqueNoCastWW', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) -test('OpaqueNoRebox', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) -test('OpaqueNoRebox2', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) -test('OpaqueNoRebox3', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) -test('OpaqueNoSpecConstr', req_interp, compile, ['-O -ddump-simpl -dsuppress-uniques']) -test('OpaqueNoSpecialise', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) -test('OpaqueNoStrictArgWW', normal, compile, ['-O -fworker-wrapper-cbv -ddump-simpl -dsuppress-uniques']) -test('OpaqueNoWW', normal, compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoRebox', [ grep_errmsg(r'$wf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoRebox2', [ grep_errmsg(r'$wf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoRebox3', [ grep_errmsg(r'$wf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoSpecConstr', [ req_interp, grep_errmsg(r'$sloop') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoSpecialise', [ grep_errmsg(r'$sf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoStrictArgWW', [ grep_errmsg(r'$wf') ], compile, ['-O -fworker-wrapper-cbv -ddump-simpl -dsuppress-uniques']) +test('OpaqueNoWW', [ grep_errmsg(r'$wf') ], compile, ['-O -ddump-simpl -dsuppress-uniques']) test('T21144', normal, compile, ['-O']) @@ -449,3 +449,5 @@ test('T22375', normal, compile, ['-O -ddump-simpl -dsuppress-uniques -dno-typeab # One module, T21851_2.hs, has OPTIONS_GHC -ddump-simpl # Expecting to see $s$wwombat test('T21851_2', [grep_errmsg(r'wwombat') ], multimod_compile, ['T21851_2', '-O -dno-typeable-binds -dsuppress-uniques']) +# Should not inline m, so there shouldn't be a single YES +test('T22317', [grep_errmsg(r'ANSWER = YES') ], compile, ['-O -dinline-check m -ddebug-output']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c81c480df60466a290b05c4337315cfbe8779f6...6b589a0730494413d5f7e0468ba1a7c3b26a40b1 -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8c81c480df60466a290b05c4337315cfbe8779f6...6b589a0730494413d5f7e0468ba1a7c3b26a40b1 You're receiving 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 Nov 16 11:16:15 2022 From: gitlab at gitlab.haskell.org (Simon Peyton Jones (@simonpj)) Date: Wed, 16 Nov 2022 06:16:15 -0500 Subject: [Git][ghc/ghc][wip/T21623-tycon] Add GHC.Core.TyCo.FVs.hs-boot Message-ID: <6374c67f90926_38f79f52878622091@gitlab.mail> Simon Peyton Jones pushed to branch wip/T21623-tycon at Glasgow Haskell Compiler / GHC Commits: c9e5bf5d by Simon Peyton Jones at 2022-11-16T11:18:03+00:00 Add GHC.Core.TyCo.FVs.hs-boot - - - - - 1 changed file: - + compiler/GHC/Core/TyCo/FVs.hs-boot Changes: ===================================== compiler/GHC/Core/TyCo/FVs.hs-boot ===================================== @@ -0,0 +1,6 @@ +module GHC.Core.TyCo.FVs where + +import GHC.Prelude ( Bool ) +import {-# SOURCE #-} GHC.Core.TyCo.Rep ( Type ) + +noFreeVarsOfType :: Type -> Bool View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9e5bf5d8e267312f42d19105d8fa33538a412cb -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9e5bf5d8e267312f42d19105d8fa33538a412cb You're receiving 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 Nov 16 12:20:05 2022 From: gitlab at gitlab.haskell.org (Vladislav Zavialov (@int-index)) Date: Wed, 16 Nov 2022 07:20:05 -0500 Subject: [Git][ghc/ghc][wip/int-index/emb-type] 108 commits: Drop a kludge for binutils<2.17, which is now over 10 years old. Message-ID: <6374d57555cd3_38f79f5288c62665f@gitlab.mail> Vladislav Zavialov pushed to branch wip/int-index/emb-type at Glasgow Haskell Compiler / GHC Commits: d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - - - ce726cd2 by Ross Paterson at 2022-11-08T12:54:34-05:00 Fix TypeData issues (fixes #22315 and #22332) There were two bugs here: 1. Treating type-level constructors as PromotedDataCon doesn't always work, in particular because constructors promoted via DataKinds are called both T and 'T. (Tests T22332a, T22332b, T22315a, T22315b) Fix: guard these cases with isDataKindsPromotedDataCon. 2. Type-level constructors were sent to the code generator, producing things like constructor wrappers. (Tests T22332a, T22332b) Fix: test for them in isDataTyCon. Other changes: * changed the marking of "type data" DataCon's as suggested by SPJ. * added a test TDGADT for a type-level GADT. * comment tweaks * change tcIfaceTyCon to ignore IfaceTyConInfo, so that IfaceTyConInfo is used only for pretty printing, not for typechecking. (SPJ) - - - - - 132f8908 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Clarify msum/asum documentation - - - - - bb5888c5 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Add example for (<$) - - - - - 080fffa1 by Jade Lovelace at 2022-11-08T12:55:18-05:00 Document what Alternative/MonadPlus instances actually do - - - - - 92ccb8de by Giles Anderson at 2022-11-09T09:27:52-05:00 Use TcRnDiagnostic in GHC.Tc.TyCl.Instance (#20117) The following `TcRnDiagnostic` messages have been introduced: TcRnWarnUnsatisfiedMinimalDefinition TcRnMisplacedInstSig TcRnBadBootFamInstDeclErr TcRnIllegalFamilyInstance TcRnAssocInClassErr TcRnBadFamInstDecl TcRnNotOpenFamily - - - - - 90c5abd4 by Hécate Moonlight at 2022-11-09T09:28:30-05:00 GHCi tags generation phase 2 see #19884 - - - - - f9f17b68 by Simon Peyton Jones at 2022-11-10T12:20:03+00:00 Fire RULES in the Specialiser The Specialiser has, for some time, fires class-op RULES in the specialiser itself: see Note [Specialisation modulo dictionary selectors] This MR beefs it up a bit, so that it fires /all/ RULES in the specialiser, not just class-op rules. See Note [Fire rules in the specialiser] The result is a bit more specialisation; see test simplCore/should_compile/T21851_2 This pushed me into a bit of refactoring. I made a new data types GHC.Core.Rules.RuleEnv, which combines - the several source of rules (local, home-package, external) - the orphan-module dependencies in a single record for `getRules` to consult. That drove a bunch of follow-on refactoring, including allowing me to remove cr_visible_orphan_mods from the CoreReader data type. I moved some of the RuleBase/RuleEnv stuff into GHC.Core.Rule. The reorganisation in the Simplifier improve compile times a bit (geom mean -0.1%), but T9961 is an outlier Metric Decrease: T9961 - - - - - 2b3d0bee by Simon Peyton Jones at 2022-11-10T12:21:13+00:00 Make indexError work better The problem here is described at some length in Note [Boxity for bottoming functions] and Note [Reboxed crud for bottoming calls] in GHC.Core.Opt.DmdAnal. This patch adds a SPECIALISE pragma for indexError, which makes it much less vulnerable to the problem described in these Notes. (This came up in another line of work, where a small change made indexError do reboxing (in nofib/spectral/simple/table_sort) that didn't happen before my change. I've opened #22404 to document the fagility. - - - - - 399e921b by Simon Peyton Jones at 2022-11-10T12:21:14+00:00 Fix DsUselessSpecialiseForClassMethodSelector msg The error message for DsUselessSpecialiseForClassMethodSelector was just wrong (a typo in some earlier work); trivial fix - - - - - dac0682a by Sebastian Graf at 2022-11-10T21:16:01-05:00 WorkWrap: Unboxing unboxed tuples is not always useful (#22388) See Note [Unboxing through unboxed tuples]. Fixes #22388. - - - - - 1230c268 by Sebastian Graf at 2022-11-10T21:16:01-05:00 Boxity: Handle argument budget of unboxed tuples correctly (#21737) Now Budget roughly tracks the combined width of all arguments after unarisation. See the changes to `Note [Worker argument budgets]`. Fixes #21737. - - - - - 2829fd92 by Cheng Shao at 2022-11-11T00:26:54-05:00 autoconf: check getpid getuid raise This patch adds checks for getpid, getuid and raise in autoconf. These functions are absent in wasm32-wasi and thus needs to be checked. - - - - - f5dfd1b4 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add -Wwarn only for cross-compiling unix - - - - - 2e6ab453 by Cheng Shao at 2022-11-11T00:26:55-05:00 hadrian: add targetSupportsThreadedRts flag This patch adds a targetSupportsThreadedRts flag to indicate whether the target supports the threaded rts at all, different from existing targetSupportsSMP that checks whether -N is supported by the RTS. All existing flavours have also been updated accordingly to respect this flags. Some targets (e.g. wasm32-wasi) does not support the threaded rts, therefore this flag is needed for the default flavours to work. It makes more sense to have proper autoconf logic to check for threading support, but for the time being, we just set the flag to False iff the target is wasm32. - - - - - 8104f6f5 by Cheng Shao at 2022-11-11T00:26:55-05:00 Fix Cmm symbol kind - - - - - b2035823 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add the two key graph modules from Martin Erwig's FGL Martin Erwig's FGL (Functional Graph Library) provides an "inductive" representation of graphs. A general graph has labeled nodes and labeled edges. The key operation on a graph is to decompose it by removing one node, together with the edges that connect the node to the rest of the graph. There is also an inverse composition operation. The decomposition and composition operations make this representation of graphs exceptionally well suited to implement graph algorithms in which the graph is continually changing, as alluded to in #21259. This commit adds `GHC.Data.Graph.Inductive.Graph`, which defines the interface, and `GHC.Data.Graph.Inductive.PatriciaTree`, which provides an implementation. Both modules are taken from `fgl-5.7.0.3` on Hackage, with these changes: - Copyright and license text have been copied into the files themselves, not stored separately. - Some calls to `error` have been replaced with calls to `panic`. - Conditional-compilation support for older versions of GHC, `containers`, and `base` has been removed. - - - - - 3633a5f5 by Norman Ramsey at 2022-11-11T00:26:55-05:00 add new modules for reducibility and WebAssembly translation - - - - - df7bfef8 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add support for the wasm32-wasi target tuple This patch adds the wasm32-wasi tuple support to various places in the tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen logic will come in subsequent commits. - - - - - 32ae62e6 by Cheng Shao at 2022-11-11T00:26:55-05:00 deriveConstants: parse .ll output for wasm32 due to broken nm This patch makes deriveConstants emit and parse an .ll file when targeting wasm. It's a necessary workaround for broken llvm-nm on wasm, which isn't capable of reporting correct constant values when parsing an object. - - - - - 07e92c92 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: workaround cmm's improper variadic ccall breaking wasm32 typechecking Unlike other targets, wasm requires the function signature of the call site and callee to strictly match. So in Cmm, when we call a C function that actually returns a value, we need to add an _unused local variable to receive it, otherwise type error awaits. An even bigger problem is calling variadic functions like barf() and such. Cmm doesn't support CAPI calling convention yet, so calls to variadic functions just happen to work in some cases with some target's ABI. But again, it doesn't work with wasm. Fortunately, the wasm C ABI lowers varargs to a stack pointer argument, and it can be passed NULL when no other arguments are expected to be passed. So we also add the additional unused NULL arguments to those functions, so to fix wasm, while not affecting behavior on other targets. - - - - - 00124d12 by Cheng Shao at 2022-11-11T00:26:55-05:00 testsuite: correct sleep() signature in T5611 In libc, sleep() returns an integer. The ccall type signature should match the libc definition, otherwise it causes linker error on wasm. - - - - - d72466a9 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: prefer ffi_type_void over FFI_TYPE_VOID This patch uses ffi_type_void instead of FFI_TYPE_VOID in the interpreter code, since the FFI_TYPE_* macros are not available in libffi-wasm32 yet. The libffi public documentation also only mentions the lower-case ffi_type_* symbols, so we should prefer the lower-case API here. - - - - - 4d36a1d3 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't define RTS_USER_SIGNALS when signal.h is not present In the rts, we have a RTS_USER_SIGNALS macro, and most signal-related logic is guarded with RTS_USER_SIGNALS. This patch extends the range of code guarded with RTS_USER_SIGNALS, and define RTS_USER_SIGNALS iff signal.h is actually detected by autoconf. This is required for wasm32-wasi to work, which lacks signals. - - - - - 3f1e164f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: use HAVE_GETPID to guard subprocess related logic We've previously added detection of getpid() in autoconf. This patch uses HAVE_GETPID to guard some subprocess related logic in the RTS. This is required for certain targets like wasm32-wasi, where there isn't a process model at all. - - - - - 50bf5e77 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: IPE.c: don't do mutex stuff when THREADED_RTS is not defined This patch adds the missing THREADED_RTS CPP guard to mutex logic in IPE.c. - - - - - ed3b3da0 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: genericRaise: use exit() instead when not HAVE_RAISE We check existence of raise() in autoconf, and here, if not HAVE_RAISE, we should use exit() instead in genericRaise. - - - - - c0ba1547 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: checkSuid: don't do it when not HAVE_GETUID When getuid() is not present, don't do checkSuid since it doesn't make sense anyway on that target. - - - - - d2d6dfd2 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 placeholder linker This patch adds minimal placeholder linker logic for wasm32, just enough to unblock compiling rts on wasm32. RTS linker functionality is not properly implemented yet for wasm32. - - - - - 65ba3285 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: chdir to PWD on wasm32 This patch adds a wasm32-specific behavior to RtsStartup logic. When the PWD environment variable is present, we chdir() to it first. The point is to workaround an issue in wasi-libc: it's currently not possible to specify the initial working directory, it always defaults to / (in the virtual filesystem mapped from some host directory). For some use cases this is sufficient, but there are some other cases (e.g. in the testsuite) where the program needs to access files outside. - - - - - 65b82542 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: no timer for wasm32 Due to the lack of threads, on wasm32 there can't be a background timer that periodically resets the context switch flag. This patch disables timer for wasm32, and also makes the scheduler default to -C0 on wasm32 to avoid starving threads. - - - - - e007586f by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsSymbols: empty RTS_POSIX_ONLY_SYMBOLS for wasm32 The default RTS_POSIX_ONLY_SYMBOLS doesn't make sense on wasm32. - - - - - 0e33f667 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: Schedule: no FORKPROCESS_PRIMOP_SUPPORTED on wasm32 On wasm32 there isn't a process model at all, so no FORKPROCESS_PRIMOP_SUPPORTED. - - - - - 88bbdb31 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: LibffiAdjustor: adapt to ffi_alloc_prep_closure interface for wasm32 libffi-wasm32 only supports non-standard libffi closure api via ffi_alloc_prep_closure(). This patch implements ffi_alloc_prep_closure() via standard libffi closure api on other targets, and uses it to implement adjustor functionality. - - - - - 15138746 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: don't return memory to OS on wasm32 This patch makes the storage manager not return any memory on wasm32. The detailed reason is described in Note [Megablock allocator on wasm]. - - - - - 631af3cc by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: make flushExec a no-op on wasm32 This patch makes flushExec a no-op on wasm32, since there's no such thing as executable memory on wasm32 in the first place. - - - - - 654a3d46 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: RtsStartup: don't call resetTerminalSettings, freeThreadingResources on wasm32 This patch prevents resetTerminalSettings and freeThreadingResources to be called on wasm32, since there is no TTY or threading on wasm32 at all. - - - - - f271e7ca by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: OSThreads.h: stub types for wasm32 This patch defines stub Condition/Mutex/OSThreadId/ThreadLocalKey types for wasm32, just enough to unblock compiling RTS. Any threading-related functionality has been patched to be disabled on wasm32. - - - - - a6ac67b0 by Cheng Shao at 2022-11-11T00:26:55-05:00 Add register mapping for wasm32 This patch adds register mapping logic for wasm32. See Note [Register mapping on WebAssembly] in wasm32 NCG for more description. - - - - - d7b33982 by Cheng Shao at 2022-11-11T00:26:55-05:00 rts: wasm32 specific logic This patch adds the rest of wasm32 specific logic in rts. - - - - - 7f59b0f3 by Cheng Shao at 2022-11-11T00:26:55-05:00 base: fall back to using monotonic clock to emulate cputime on wasm32 On wasm32, we have to fall back to using monotonic clock to emulate cputime, since there's no native support for cputime as a clock id. - - - - - 5fcbae0b by Cheng Shao at 2022-11-11T00:26:55-05:00 base: more autoconf checks for wasm32 This patch adds more autoconf checks to base, since those functions and headers may exist on other POSIX systems but don't exist on wasm32. - - - - - 00a9359f by Cheng Shao at 2022-11-11T00:26:55-05:00 base: avoid using unsupported posix functionality on wasm32 This base patch avoids using unsupported posix functionality on wasm32. - - - - - 34b8f611 by Cheng Shao at 2022-11-11T00:26:55-05:00 autoconf: set CrossCompiling=YES in cross bindist configure This patch fixes the bindist autoconf logic to properly set CrossCompiling=YES when it's a cross GHC bindist. - - - - - 5ebeaa45 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: add util functions for UniqFM and UniqMap This patch adds addToUFM_L (backed by insertLookupWithKey), addToUniqMap_L and intersectUniqMap_C. These UniqFM/UniqMap util functions are used by the wasm32 NCG. - - - - - 177c56c1 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: avoid -Wl,--no-as-needed for wasm32 The driver used to pass -Wl,--no-as-needed for LLD linking. This is actually only supported for ELF targets, and must be avoided when linking for wasm32. - - - - - 06f01c74 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: allow big arith for wasm32 This patch enables Cmm big arithmetic on wasm32, since 64-bit arithmetic can be efficiently lowered to wasm32 opcodes. - - - - - df6bb112 by Cheng Shao at 2022-11-11T00:26:55-05:00 driver: pass -Wa,--no-type-check for wasm32 when runAsPhase This patch passes -Wa,--no-type-check for wasm32 when compiling assembly. See the added note for more detailed explanation. - - - - - c1fe4ab6 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: enforce cmm switch planning for wasm32 This patch forcibly enable Cmm switch planning for wasm32, since otherwise the switch tables we generate may exceed the br_table maximum allowed size. - - - - - a8adc71e by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: annotate CmmFileEmbed with blob length This patch adds the blob length field to CmmFileEmbed. The wasm32 NCG needs to know the precise size of each data segment. - - - - - 36340328 by Cheng Shao at 2022-11-11T00:26:55-05:00 compiler: wasm32 NCG This patch adds the wasm32 NCG. - - - - - 435f42ea by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add wasm32-wasi release bindist job - - - - - d8262fdc by Cheng Shao at 2022-11-11T00:26:55-05:00 ci: add a stronger test for cross bindists This commit adds a simple GHC API program that parses and reprints the original hello world program used for basic testing of cross bindists. Before there's full cross-compilation support in the test suite driver, this provides better coverage than the original test. - - - - - 8e6ae882 by Cheng Shao at 2022-11-11T00:26:55-05:00 CODEOWNERS: add wasm-specific maintainers - - - - - 707d5651 by Zubin Duggal at 2022-11-11T00:27:31-05:00 Clarify that LLVM upper bound is non-inclusive during configure (#22411) - - - - - 430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00 rts: Check for program_invocation_short_name via autoconf Instead of assuming support on all Linuxes. - - - - - 6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00 driver: Fix -fdefer-diagnostics flag The `withDeferredDiagnostics` wrapper wasn't doing anything because the session it was modifying wasn't used in hsc_env. Therefore the fix is simple, just push the `getSession` call into the scope of `withDeferredDiagnostics`. Fixes #22391 - - - - - d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00 Add a fast path for data constructor workers See Note [Fast path for data constructors] in GHC.Core.Opt.Simplify.Iteration This bypasses lots of expensive logic, in the special case of applications of data constructors. It is a surprisingly worthwhile improvement, as you can see in the figures below. Metrics: compile_time/bytes allocated ------------------------------------------------ CoOpt_Read(normal) -2.0% CoOpt_Singletons(normal) -2.0% ManyConstructors(normal) -1.3% T10421(normal) -1.9% GOOD T10421a(normal) -1.5% T10858(normal) -1.6% T11545(normal) -1.7% T12234(optasm) -1.3% T12425(optasm) -1.9% GOOD T13035(normal) -1.0% GOOD T13056(optasm) -1.8% T13253(normal) -3.3% GOOD T15164(normal) -1.7% T15304(normal) -3.4% T15630(normal) -2.8% T16577(normal) -4.3% GOOD T17096(normal) -1.1% T17516(normal) -3.1% T18282(normal) -1.9% T18304(normal) -1.2% T18698a(normal) -1.2% GOOD T18698b(normal) -1.5% GOOD T18923(normal) -1.3% T1969(normal) -1.3% GOOD T19695(normal) -4.4% GOOD T21839c(normal) -2.7% GOOD T21839r(normal) -2.7% GOOD T4801(normal) -3.8% GOOD T5642(normal) -3.1% GOOD T6048(optasm) -2.5% GOOD T9020(optasm) -2.7% GOOD T9630(normal) -2.1% GOOD T9961(normal) -11.7% GOOD WWRec(normal) -1.0% geo. mean -1.1% minimum -11.7% maximum +0.1% Metric Decrease: T10421 T12425 T13035 T13253 T16577 T18698a T18698b T1969 T19695 T21839c T21839r T4801 T5642 T6048 T9020 T9630 T9961 - - - - - 3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00 Use a more efficient printer for code generation (#21853) The changes in `GHC.Utils.Outputable` are the bulk of the patch and drive the rest. The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc` and support printing directly to a handle with `bPutHDoc`. See Note [SDoc versus HDoc] and Note [HLine versus HDoc]. The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF and dependencies (printing module names, labels etc.). Co-authored-by: Alexis King <lexi.lambda at gmail.com> Metric Decrease: CoOpt_Read ManyAlternatives ManyConstructors T10421 T12425 T12707 T13035 T13056 T13253 T13379 T18140 T18282 T18698a T18698b T1969 T20049 T21839c T21839r T3064 T3294 T4801 T5321FD T5321Fun T5631 T6048 T783 T9198 T9233 - - - - - 6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00 Weaken wrinkle 1 of Note [Scrutinee Constant Folding] Fixes #22375. Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com> - - - - - 154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Fix fragile RULE setup in GHC.Float In testing my type-vs-constraint patch I found that the handling of Natural literals was very fragile -- and I somehow tripped that fragility in my work. So this patch fixes the fragility. See Note [realToFrac natural-to-float] This made a big (9%) difference in one existing test in perf/should_run/T1-359 Metric Decrease: T10359 - - - - - 778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00 Type vs Constraint: finally nailed This big patch addresses the rats-nest of issues that have plagued us for years, about the relationship between Type and Constraint. See #11715/#21623. The main payload of the patch is: * To introduce CONSTRAINT :: RuntimeRep -> Type * To make TYPE and CONSTRAINT distinct throughout the compiler Two overview Notes in GHC.Builtin.Types.Prim * Note [TYPE and CONSTRAINT] * Note [Type and Constraint are not apart] This is the main complication. The specifics * New primitive types (GHC.Builtin.Types.Prim) - CONSTRAINT - ctArrowTyCon (=>) - tcArrowTyCon (-=>) - ccArrowTyCon (==>) - funTyCon FUN -- Not new See Note [Function type constructors and FunTy] and Note [TYPE and CONSTRAINT] * GHC.Builtin.Types: - New type Constraint = CONSTRAINT LiftedRep - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in * Exploit the fact that Type and Constraint are distinct throughout GHC - Get rid of tcView in favour of coreView. - Many tcXX functions become XX functions. e.g. tcGetCastedTyVar --> getCastedTyVar * Kill off Note [ForAllTy and typechecker equality], in (old) GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore the specified/inferred distinction when comparein two ForAllTys. But that wsa only weakly supported and (worse) implies that we need a separate typechecker equality, different from core equality. No no no. * GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it, and anyway now we have four of them! * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo See Note [FunCo] in that module. * GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT. The key new function is sORTKind_maybe; most other changes are built on top of that. See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`. * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type. (The bug was that before (forall (cv::t1 ~# t2). blah), where blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be (TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type. * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType. Of course, no tcEqType any more. * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module: tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only. * GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to have one for each /RuntimeRep/, rather than one for each /Type/. This dramatically widens the range of types we can auto-box. See Note [Boxing constructors] in GHC.Builtin.Types The boxing types themselves are declared in library ghc-prim:GHC.Types. GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially) types of kind Constraint. That allows the desugaring for arrows to work; it gathers up free variables (including dictionaries) into tuples. See Note [Big tuples] in GHC.Core.Make. There is still work to do here: #22336. But things are better than before. * GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint. Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make; see Note [inlineId magic]. * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called SelCo, and its fields are much more descriptive than the single Int we used to have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep. * GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to a single TyCon, so that the rough-map does not distinguish them. * GHC.Core.DataCon - Mainly just improve documentation * Some significant renamings: GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for) One --> OneTy GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder GHC.Core.Var TyCoVarBinder --> ForAllTyBinder AnonArgFlag --> FunTyFlag ArgFlag --> ForAllTyFlag GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder Many functions are renamed in consequence e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type data FunTyFlag = FTF_T_T -- (->) Type -> Type | FTF_T_C -- (-=>) Type -> Constraint | FTF_C_T -- (=>) Constraint -> Type | FTF_C_C -- (==>) Constraint -> Constraint * GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case of pprMismatchMsg. * I made the tyConUnique field of TyCon strict, because I saw code with lots of silly eval's. That revealed that GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because we pack the sum tag into a 6-bit field. (Lurking bug squashed.) Fixes * #21530 Updates haddock submodule slightly. Performance changes ~~~~~~~~~~~~~~~~~~~ I was worried that compile times would get worse, but after some careful profiling we are down to a geometric mean 0.1% increase in allocation (in perf/compiler). That seems fine. There is a big runtime improvement in T10359 Metric Decrease: LargeRecord MultiLayerModulesTH_OneShot T13386 T13719 Metric Increase: T8095 - - - - - 360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00 Indent closing "#-}" to silence HLint - - - - - e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00 Fix merge conflict in T18355.stderr Fixes #22446 - - - - - 294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00 Fix a trivial typo in dataConNonlinearType Fixes #22416 - - - - - 268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00 eventlog: Ensure that IPE output contains actual info table pointers The refactoring in 866c736e introduced a rather subtle change in the semantics of the IPE eventlog output, changing the eventlog field from encoding info table pointers to "TNTC pointers" (which point to entry code when tables-next-to-code is enabled). Fix this. Fixes #22452. - - - - - d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00 testsuite: Add tests for T22347 These are fixed in recent versions but might as well add regression tests. See #22347 - - - - - 8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00 testsuite: Improve output from tests which have failing pre_cmd There are two changes: * If a pre_cmd fails, then don't attempt to run the test. * If a pre_cmd fails, then print the stdout and stderr from running that command (which hopefully has a nice error message). For example: ``` =====> 1 of 1 [0, 0, 0] *** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2 ** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}". stdout: stderr: DefaultLifted.hs:19:13: error: [GHC-76037] Not in scope: type constructor or class ‘Typ’ Suggested fix: Perhaps use one of these: ‘Type’ (imported from GHC.Tc.Utils.TcType), data constructor ‘Type’ (imported from GHC.Plugins) | 19 | instance Eq Typ where | ^^^ make: *** [Makefile:17: package.test-defaulting-plugin] Error 1 Performance Metrics (test environment: local): ``` Fixes #22329 - - - - - 2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00 Implement UNPACK support for sum types. This is based on osa's unpack_sums PR from ages past. The meat of the patch is implemented in dataConArgUnpackSum and described in Note [UNPACK for sum types]. - - - - - 78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00 Expand on the need to clone local binders. Fixes #22402. - - - - - 65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00 Fix :i Constraint printing "type Constraint = Constraint" Since Constraint became a synonym for CONSTRAINT 'LiftedRep, we need the same code for handling printing as for the synonym Type = TYPE 'LiftedRep. This addresses the same bug as #18594, so I'm reusing the test. - - - - - 94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00 configure: Don't check for an unsupported version of LLVM The upper bound is not inclusive. Fixes #22449 - - - - - 02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00 Fix capitalization in haddock for TestEquality - - - - - 05faa910 by Vladislav Zavialov at 2022-11-16T14:29:34+03:00 WIP: Visible forall in types of terms - - - - - 30 changed files: - .gitignore - .gitlab-ci.yml - .gitlab/ci.sh - + .gitlab/hello.hs - CODEOWNERS - compiler/CodeGen.Platform.h - 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/Literals.hs - compiler/GHC/Builtin/Types/Prim.hs - − compiler/GHC/Builtin/Types/Prim.hs-boot - compiler/GHC/Builtin/Uniques.hs - compiler/GHC/ByteCode/Types.hs - compiler/GHC/Cmm.hs - compiler/GHC/Cmm/BlockId.hs - compiler/GHC/Cmm/CLabel.hs - compiler/GHC/Cmm/CLabel.hs-boot - compiler/GHC/Cmm/DebugBlock.hs - compiler/GHC/Cmm/Expr.hs - + compiler/GHC/Cmm/Reducibility.hs - compiler/GHC/Cmm/Reg.hs - compiler/GHC/Cmm/Utils.hs - compiler/GHC/CmmToAsm.hs - compiler/GHC/CmmToAsm/AArch64.hs - compiler/GHC/CmmToAsm/AArch64/Ppr.hs - compiler/GHC/CmmToAsm/AArch64/Regs.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7cdc9b2ace685a525afbf9732b096133cd2010e7...05faa91005c7921d2b9970e1526df418dacfc54d -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7cdc9b2ace685a525afbf9732b096133cd2010e7...05faa91005c7921d2b9970e1526df418dacfc54d You're receiving 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 Nov 16 12:32:48 2022 From: gitlab at gitlab.haskell.org (David (@knothed)) Date: Wed, 16 Nov 2022 07:32:48 -0500 Subject: [Git][ghc/ghc][wip/or-pats] 97 commits: CI: Don't run lint-submods on nightly Message-ID: <6374d87083c48_38f79f529046306bc@gitlab.mail> David pushed to branch wip/or-pats at Glasgow Haskell Compiler / GHC Commits: c2872f3f by Bryan Richter at 2022-10-28T11:36:34+03:00 CI: Don't run lint-submods on nightly Fixes #22325 - - - - - 270037fa by Hécate Moonlight at 2022-10-28T19:46:12-04:00 Start the deprecation process for GHC.Pack - - - - - d45d8cb3 by M Farkas-Dyck at 2022-11-01T12:47:21-04:00 Drop a kludge for binutils<2.17, which is now over 10 years old. - - - - - 8ee8b418 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: `name` argument of `createOSThread` can be `const` Since we don't intend to ever change the incoming string, declare this to be true. Also, in the POSIX implementation, the argument is no longer `STG_UNUSED` (since ee0deb8054da2a597fc5624469b4c44fd769ada2) in any code path. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 - - - - - 13b5f102 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix lifetime of `start_thread`s `name` value Since, unlike the code in ee0deb8054da2^, usage of the `name` value passed to `createOSThread` now outlives said function's lifetime, and could hence be released by the caller by the time the new thread runs `start_thread`, it needs to be copied. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2#note_460080 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - edd175c9 by Nicolas Trangez at 2022-11-01T12:47:58-04:00 rts: fix OS thread naming in ticker Since ee0deb805, the use of `pthread_setname_np` on Darwin was fixed when invoking `createOSThread`. However, the 'ticker' has some thread-creation code which doesn't rely on `createOSThread`, yet also uses `pthread_setname_np`. This patch enforces all thread creation to go through a single function, which uses the (correct) thread-naming code introduced in ee0deb805. See: https://gitlab.haskell.org/ghc/ghc/-/commit/ee0deb8054da2a597fc5624469b4c44fd769ada2 See: https://gitlab.haskell.org/ghc/ghc/-/issues/22206 See: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9066 - - - - - b7a00113 by Krzysztof Gogolewski at 2022-11-01T12:48:35-04:00 Typo: rename -fwrite-if-simplfied-core to -fwrite-if-simplified-core - - - - - 30e625e6 by Vladislav Zavialov at 2022-11-01T12:49:10-04:00 ThToHs: fix overzealous parenthesization Before this patch, when converting from TH.Exp to LHsExpr GhcPs, the compiler inserted more parentheses than required: ((f a) (b + c)) d This was happening because the LHS of the function application was parenthesized as if it was the RHS. Now we use funPrec and appPrec appropriately and produce sensibly parenthesized expressions: f a (b + c) d I also took the opportunity to remove the special case for LamE, which was not special at all and simply duplicated code. - - - - - 0560821f by Simon Peyton Jones at 2022-11-01T12:49:47-04:00 Add accurate skolem info when quantifying Ticket #22379 revealed that skolemiseQuantifiedTyVar was dropping the passed-in skol_info on the floor when it encountered a SkolemTv. Bad! Several TyCons thereby share a single SkolemInfo on their binders, which lead to bogus error reports. - - - - - 38d19668 by Fendor at 2022-11-01T12:50:25-04:00 Expose UnitEnvGraphKey for user-code - - - - - 77e24902 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Shrink test case for #22357 Ryan Scott offered a cut-down repro case (60 lines instead of more than 700 lines) - - - - - 4521f649 by Simon Peyton Jones at 2022-11-01T12:51:00-04:00 Add two tests for #17366 - - - - - 6b400d26 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_NORETURN` Instead of sprinkling the codebase with `GNU(C3)_ATTRIBUTE(__noreturn__)`, add a `STG_NORETURN` macro (for, basically, the same thing) similar to `STG_UNUSED` and others, and update the code to use this macro where applicable. - - - - - f9638654 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: consistently use `STG_UNUSED` - - - - - 81a58433 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_USED` Similar to `STG_UNUSED`, have a specific macro for `__attribute__(used)`. - - - - - 41e1f748 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: introduce (and use) `STG_MALLOC` Instead of using `GNUC3_ATTRIBUTE(__malloc__)`, provide a `STG_MALLOC` macro definition and use it instead. - - - - - 3a9a8bde by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `STG_UNUSED` - - - - - 9ab999de by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: specify deallocator of allocating functions This patch adds a new `STG_MALLOC1` macro (and its counterpart `STG_MALLOC2` for completeness) which allows to specify the deallocation function to be used with allocations of allocating functions, and applies it to `stg*allocBytes`. It also fixes a case where `free` was used to free up an `stgMallocBytes` allocation, found by the above change. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 81c0c7c9 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: use `alloc_size` attribute This patch adds the `STG_ALLOC_SIZE1` and `STG_ALLOC_SIZE2` macros which allow to set the `alloc_size` attribute on functions, when available. See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - 99a1d896 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: add and use `STG_RETURNS_NONNULL` See: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005fnonnull-function-attribute See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - c235b399 by Nicolas Trangez at 2022-11-02T12:06:48-04:00 rts: tag `stgStrndup` as `STG_MALLOC` See: https://gitlab.haskell.org/ghc/ghc/-/issues/22381 - - - - - ed81b448 by Oleg Grenrus at 2022-11-02T12:07:27-04:00 Move Symbol implementation note out of public haddock - - - - - 284fd39c by Ben Gamari at 2022-11-03T01:58:54-04:00 gen-dll: Drop it Currently it is only used by the make build system, which is soon to be retired, and it has not built since 41cf758b. We may need to reintroduce it when dynamic-linking support is introduced on Windows, but we will cross that bridge once we get there. Fixes #21753. - - - - - 24f4f54f by Matthew Pickering at 2022-11-03T01:59:30-04:00 Port foundation numeric tests to GHC testsuite This commit ports the numeric tests which found a regression in GHC-9.4. https://github.com/haskell-foundation/foundation/issues/571 Included in the commit is a simple random number generator and simplified QuickCheck implementation. In future these could be factored out of this standalone file and reused as a general purpose library which could be used for other QuickCheck style tests in the testsuite. See #22282 - - - - - d51bf7bd by M Farkas-Dyck at 2022-11-03T02:00:13-04:00 git: ignore HIE files. Cleans up git status if one sets -fwrite-ide-info in hadrian/ghci. - - - - - a9fc15b1 by Matthew Pickering at 2022-11-03T02:00:49-04:00 Clarify status of bindings in WholeCoreBindings Gergo points out that these bindings are tidied, rather than prepd as the variable claims. Therefore we update the name of the variable to reflect reality and add a comment to the data type to try to erase any future confusion. Fixes #22307 - - - - - 634da448 by Bodigrim at 2022-11-03T21:25:02+00:00 Fix haddocks for GHC.IORef - - - - - 31125154 by Andreas Klebinger at 2022-11-03T23:08:09-04:00 Export pprTrace and friends from GHC.Prelude. Introduces GHC.Prelude.Basic which can be used in modules which are a dependency of the ppr code. - - - - - bdc8cbb3 by Bryan Richter at 2022-11-04T10:27:37+02:00 CI: Allow hadrian-ghc-in-ghci to run in nightlies Since lint-submods doesn't run in nightlies, hadrian-ghc-in-ghci needs to mark it as "optional" so it can run if the job doesn't exist. Fixes #22396. - - - - - 3c0e3793 by Krzysztof Gogolewski at 2022-11-05T00:29:57-04:00 Minor refactor around FastStrings Pass FastStrings to functions directly, to make sure the rule for fsLit "literal" fires. Remove SDoc indirection in GHCi.UI.Tags and GHC.Unit.Module.Graph. - - - - - e41b2f55 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump unix submodule to 2.8.0.0 Also bumps process and ghc-boot bounds on unix. For hadrian, when cross-compiling, we add -Wwarn=unused-imports -Wwarn=unused-top-binds to validation flavour. Further fixes in unix and/or hsc2hs is needed to make it completely free of warnings; for the time being, this change is needed to unblock other cross-compilation related work. - - - - - 42938a58 by Matthew Pickering at 2022-11-05T14:18:10+00:00 Bump Win32 submodule to 2.13.4.0 Fixes #22098 - - - - - e7372bc5 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump ci-images revision ci-images has recently been updated, including changes needed for wasm32-wasi CI. - - - - - 88cb9492 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump gmp-tarballs submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 69427ce9 by Cheng Shao at 2022-11-06T13:15:22+00:00 Bump haskeline submodule Includes a fix for wasm support, doesn't impact other targets. - - - - - 5fe11fe6 by Carter Schonwald at 2022-11-07T13:22:14-05:00 bump llvm upper bound - - - - - 68f49874 by M Farkas-Dyck at 2022-11-08T12:53:55-05:00 Define `Infinite` list and use where appropriate. Also add perf test for infinite list fusion. In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names. Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists]. - - - -